diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 397d28a..522d621 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,26 +5,30 @@ on: pull_request: jobs: - test: - name: Run Unit Tests + shellcheck: + name: Shellcheck runs-on: ubuntu-latest - steps: - name: Checkout repository - uses: actions/checkout@v2 - + uses: actions/checkout@v3 - name: Set up shell environment run: | sudo apt-get update sudo apt-get install -y shellcheck shell: bash - - name: Run shellcheck - run: shellcheck --severity warning scripts/upgrade.sh scripts/tests.sh + run: shellcheck --severity warning scripts/upgrade.sh scripts/tests.sh + test: + name: Run Unit Tests + runs-on: ubuntu-latest + container: + image: busybox + steps: + - name: Checkout repository + uses: actions/checkout@v1 - name: Run unit tests run: | cd scripts - chmod +x upgrade.sh tests.sh - ./tests.sh - shell: bash + chmod +x ./tests.sh + ./tests.sh \ No newline at end of file diff --git a/scripts/upgrade.sh b/scripts/upgrade.sh index 24b126c..f943a69 100755 --- a/scripts/upgrade.sh +++ b/scripts/upgrade.sh @@ -49,7 +49,7 @@ get_k3s_process_info() { if [ "$K3S_PID" = "1" ]; then K3S_BIN_PATH="/bin/k3s" else - K3S_BIN_PATH=$(awk 'NR==1 {print $1}' /host/proc/"${K3S_PID}"/cmdline) + K3S_BIN_PATH=$(awk 'NR==1 {print $1}' "/host/proc/${K3S_PID}/cmdline") fi if [ -z "$K3S_BIN_PATH" ]; then @@ -67,7 +67,7 @@ replace_binary() { fi info "Comparing old and new binaries" - BIN_CHECKSUMS="$(sha256sum $NEW_BINARY "$FULL_BIN_PATH")" + BIN_CHECKSUMS="$(sha256sum "$NEW_BINARY" "$FULL_BIN_PATH")" if [ "$?" != "0" ]; then fatal "Failed to calculate binary checksums" @@ -107,7 +107,7 @@ replace_binary() { K3S_CONTEXT=$(getfilecon "$FULL_BIN_PATH" 2>/dev/null | awk '{print $2}' || true) info "Deploying new k3s binary to $K3S_BIN_PATH" - cp $NEW_BINARY "$FULL_BIN_PATH" + cp "$NEW_BINARY" "$FULL_BIN_PATH" if [ -n "${K3S_CONTEXT}" ]; then info 'Restoring k3s bin context'