From 4b58de26d3196a9c344afb9bfea0a50afaf248f5 Mon Sep 17 00:00:00 2001 From: Manlio Perillo Date: Fri, 7 Apr 2023 16:22:52 +0200 Subject: [PATCH 1/5] eowyn: always quote variables Quote all the variables, even though we know that it is safe. Fix coding style. --- patches/eowyn.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/patches/eowyn.sh b/patches/eowyn.sh index a036acf..bc57249 100755 --- a/patches/eowyn.sh +++ b/patches/eowyn.sh @@ -14,7 +14,7 @@ # # We check ourselves before we wreck ourselves. -if [ ! -f 'patches/eowyn.sh' ] +if [ ! -f patches/eowyn.sh ] then echo "But I must be run from the project root directory." exit 1 @@ -27,18 +27,17 @@ mkdir -p patches/healed for broken in exercises/*.zig do # Remove the dir and extension, rendering the True Name. - true_name=$(basename $broken .zig) + true_name=$(basename "$broken" .zig) patch_name="patches/patches/$true_name.patch" - - if [ -f $patch_name ] + if [ -f "$patch_name" ] then # Apply the bandages to the wounds, grow new limbs, let # new life spring into the broken bodies of the fallen. - echo Healing $true_name... - patch --output=patches/healed/$true_name.zig $broken $patch_name + echo Healing "$true_name"... + patch --output="patches/healed/$true_name.zig" "$broken" "$patch_name" else - echo Cannot heal $true_name. No patch found. + echo Cannot heal "$true_name". No patch found. fi done From fd6f3eebbbd18324cd6dbe11c872965cc2d0d04e Mon Sep 17 00:00:00 2001 From: Manlio Perillo Date: Mon, 24 Apr 2023 18:09:47 +0200 Subject: [PATCH 2/5] eowyn.sh: set the -e option Currently, `zig fmt` exit status is ignored, making it useless. Ensure that the script terminates early if there is an error. Print a message to stdout before executing `zig fmt`, in order to make the possible error more visible. --- patches/eowyn.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/patches/eowyn.sh b/patches/eowyn.sh index bc57249..0c3b299 100755 --- a/patches/eowyn.sh +++ b/patches/eowyn.sh @@ -12,6 +12,7 @@ # using the patches in this directory and convey them # to convalesce in the healed directory. # +set -e # We check ourselves before we wreck ourselves. if [ ! -f patches/eowyn.sh ] @@ -41,7 +42,7 @@ do fi done -# Check the healed exercises formatting. +echo "Looking for non-conforming code formatting..." zig fmt --check patches/healed # Test the healed exercises. May the compiler have mercy upon us. From 49e7c51f9a230cce0464343d8279986e8eb5c3d3 Mon Sep 17 00:00:00 2001 From: Manlio Perillo Date: Mon, 24 Apr 2023 18:41:11 +0200 Subject: [PATCH 3/5] Fix formatting in exercise 99 The non-conforming formatting was not detected by the eowyn.sh script, due to a bug. --- exercises/099_formatting.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/099_formatting.zig b/exercises/099_formatting.zig index 074358b..fc73338 100644 --- a/exercises/099_formatting.zig +++ b/exercises/099_formatting.zig @@ -82,7 +82,7 @@ // // X | 1 2 3 4 5 ... // ---+---+---+---+---+---+ -// 1 | 1 2 3 4 5 +// 1 | 1 2 3 4 5 // // 2 | 2 4 6 8 10 // From b5036b776a405410e88e87e8eee978d37a66524c Mon Sep 17 00:00:00 2001 From: Manlio Perillo Date: Tue, 25 Apr 2023 15:13:38 +0200 Subject: [PATCH 4/5] workflows: use actions/checkout@v3 Use the new version of actions/checkout, since all Github Actions will begin running on Node16 instead of Node12. See https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. --- .github/workflows/ci.yml | 2 +- .github/workflows/eowyn.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ebeda5b..1d6b14d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: matrix: zig: [ 0.6.0, 0.7.0, 0.8.0, 0.9.0, 0.10.0 ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Zig uses: goto-bus-stop/setup-zig@v2 diff --git a/.github/workflows/eowyn.yml b/.github/workflows/eowyn.yml index a7133ca..cfa84a4 100644 --- a/.github/workflows/eowyn.yml +++ b/.github/workflows/eowyn.yml @@ -18,7 +18,7 @@ jobs: runs-on: ${{ matrix.os }} timeout-minutes: 60 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Zig uses: goto-bus-stop/setup-zig@v2 with: From 6effa7fe842dd7fc05b6497da825b9861231b2a1 Mon Sep 17 00:00:00 2001 From: Manlio Perillo Date: Tue, 25 Apr 2023 15:25:07 +0200 Subject: [PATCH 5/5] workflow: add a test job to ci.yml Add a job to run the ziglings unit tests, using `zig build test`. --- .github/workflows/ci.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d6b14d..57e8225 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,3 +23,19 @@ jobs: - name: Check compatibility with old Zig compilers run: ci/compat.sh + test: + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} + timeout-minutes: 60 + steps: + - uses: actions/checkout@v3 + + - name: Setup Zig + uses: goto-bus-stop/setup-zig@v2 + with: + version: master + + - name: Unit Test + run: zig build test