From 93e8b5710c12170271d63bc4a9eb49f3605f02d0 Mon Sep 17 00:00:00 2001 From: Manlio Perillo Date: Sat, 29 Apr 2023 16:22:52 +0200 Subject: [PATCH 1/4] workflows: remove the custom windows only jobs Restore the job matrix to run on linux, macos and windows. Remove lines with extra whitespace. Improve the documentation of the Eowyn workflow. Remove the single quoting of the workflow names. --- .github/workflows/ci.yml | 25 ++++--------------------- .github/workflows/eowyn.yml | 27 ++++++--------------------- 2 files changed, 10 insertions(+), 42 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1633159..d071d8f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,4 @@ -name: 'CI' -# Makes some checks +name: CI on: pull_request: @@ -27,12 +26,12 @@ jobs: - name: Check compatibility with old Zig compilers run: ci/compat.sh - - test-linux_mac: + + test: name: Unit Tests strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, windows-latest, macos-latest] runs-on: ${{ matrix.os }} timeout-minutes: 30 steps: @@ -46,19 +45,3 @@ jobs: - name: Run unit tests run: zig build test - - test-windows: - name: Unit Test Windows - runs-on: windows-latest - timeout-minutes: 30 - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Zig - uses: goto-bus-stop/setup-zig@v2 - with: - version: master - - - name: Run unit tests - run: zig build test diff --git a/.github/workflows/eowyn.yml b/.github/workflows/eowyn.yml index 8128832..3ac48f7 100644 --- a/.github/workflows/eowyn.yml +++ b/.github/workflows/eowyn.yml @@ -1,5 +1,5 @@ -name: 'Eowyn' -# Tests all exercises +# Test that exercises work with the latest Zig compiler. +name: Eowyn on: pull_request: @@ -13,35 +13,20 @@ defaults: shell: bash jobs: - build-linux_mac: + build: strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, windows-latest, macos-latest] runs-on: ${{ matrix.os }} timeout-minutes: 30 steps: - name: Checkout uses: actions/checkout@v3 - - - name: Setup Zig - uses: goto-bus-stop/setup-zig@v2 - with: - version: master - - - name: Run Eowyn - run: patches/eowyn.sh - - build-windows: - runs-on: windows-latest - timeout-minutes: 30 - steps: - - name: Checkout - uses: actions/checkout@v3 - + - name: Setup Zig uses: goto-bus-stop/setup-zig@v2 with: version: master - + - name: Run Eowyn run: patches/eowyn.sh From 4b1e292ae448ab519d0681b49da7420130b5f312 Mon Sep 17 00:00:00 2001 From: Manlio Perillo Date: Sat, 29 Apr 2023 16:25:58 +0200 Subject: [PATCH 2/4] test: fix deadlock on windows when running tests The deadlock was caused by setting stdout behavior to ignore, when spawning the patch command. When the patch command writes to devnull it causes some errors and a deadlock. The cause of the bug is probably Zig using `\Device\Null` from `ntdll` while git-bash uses `NUL` from `kernel32`. --- test/tests.zig | 1 - 1 file changed, 1 deletion(-) diff --git a/test/tests.zig b/test/tests.zig index f91c4fd..f166fc2 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -336,7 +336,6 @@ fn heal(allocator: Allocator, exercises: []const Exercise, outdir: []const u8) ! const argv = &.{ "patch", "-i", patch, "-o", output, file }; var child = std.process.Child.init(argv, allocator); - child.stdout_behavior = .Ignore; // the POSIX standard says that stdout is not used _ = try child.spawnAndWait(); } } From 11d2279f4fb736c701c23c6420cb82657e2e61f4 Mon Sep 17 00:00:00 2001 From: Manlio Perillo Date: Sat, 29 Apr 2023 16:50:28 +0200 Subject: [PATCH 3/4] test: make the patch command silent The POSIX standard says that the patch command should not use stdout, but GNU patch writes the message: patching file patches/healed/xxx.zig (read from exercises/xxx.zig). Add the -s flag to suppress these messages. Note that the heal function from test/tests.zig is called when running `zig build -Dhealed` because it is executed in the configure phase. --- test/tests.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tests.zig b/test/tests.zig index f166fc2..f9ad9c4 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -333,7 +333,7 @@ fn heal(allocator: Allocator, exercises: []const Exercise, outdir: []const u8) ! }; const output = try join(allocator, &.{ outdir, ex.main_file }); - const argv = &.{ "patch", "-i", patch, "-o", output, file }; + const argv = &.{ "patch", "-i", patch, "-o", output, "-s", file }; var child = std.process.Child.init(argv, allocator); _ = try child.spawnAndWait(); From 0dc6b457705ad45262be4fa5e0ca49cb03f3612c Mon Sep 17 00:00:00 2001 From: Manlio Perillo Date: Sat, 29 Apr 2023 16:58:10 +0200 Subject: [PATCH 4/4] eowyn.sh: remove checking formatting one file at a time This avoids unnecessary output. Also remove the comment, since the message to stdout makes it unnecessary. --- patches/eowyn.sh | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/patches/eowyn.sh b/patches/eowyn.sh index bc2fb7c..95b2a1c 100755 --- a/patches/eowyn.sh +++ b/patches/eowyn.sh @@ -45,13 +45,8 @@ do fi done -# Test the correct formatting of the healed exercises. echo "Looking for non-conforming code formatting..." -for healed in patches/healed/*.zig -do - echo Check $(basename "$healed") - zig fmt --check "$healed" -done +zig fmt --check patches/healed # Test the healed exercises. May the compiler have mercy upon us. zig build -Dhealed