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 4fb9234
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
24 changes: 14 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 4fb9234

Please sign in to comment.