Skip to content

Commit

Permalink
fix some shellcheck and changing test workflow to run on busybox
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Cardoso <osodracnai@gmail.com>
  • Loading branch information
osodracnai committed Jul 25, 2023
1 parent 2f83444 commit 9d888e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ jobs:
test:
name: Run Unit Tests
runs-on: ubuntu-latest
container:
image: busybox
options: --user root

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
apk update
apk add shellcheck
shell: bash

- name: Run shellcheck
Expand All @@ -25,6 +27,5 @@ jobs:
- name: Run unit tests
run: |
cd scripts
chmod +x upgrade.sh tests.sh
./tests.sh
shell: bash
6 changes: 3 additions & 3 deletions scripts/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 9d888e8

Please sign in to comment.