Skip to content

Add CI workflow for coro library - #176

Merged
lalinsky merged 3 commits into
mainfrom
add-coro-workflow
Jan 6, 2026
Merged

lalinsky merged 3 commits into
mainfrom
add-coro-workflow

Conversation

@lalinsky

@lalinsky lalinsky commented Jan 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add dedicated CI workflow for testing the coro library
  • Triggers only when src/libs/coro/** is modified
  • Tests on multiple platforms: Linux, macOS, Windows, FreeBSD, NetBSD
  • Tests multiple architectures: x86_64, ARM, RISC-V, LoongArch
  • Tests both Debug and ReleaseSafe builds
  • Tests with Zig 0.15.2 and master

@coderabbitai

coderabbitai Bot commented Jan 6, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a new CI workflow for coroutine testing, changes CI test invocation to emit test binaries, extends build.zig with emit-test-bin and test-filter options plus a new coro_tests target, updates check.sh and docs, and enhances an aio thread pool test to track actual concurrency.

Changes

Cohort / File(s) Summary
New CI workflow
​.github/workflows/test-coro.yml
Adds "Test coro" matrix workflow covering Zig versions, optimization modes, native/cross/VM targets; installs Zig/QEMU conditionally, applies NetBSD patch for Zig master, and runs VM-based BSD/NetBSD test runners when needed.
CI invocation change
​.github/workflows/test.yml, check.sh
Replaces previous build-tests invocation with zig build test -Demit-test-bin -Doptimize=ReleaseSafe (CI and local script now emit test binaries and run them).
Build system
build.zig
Adds emit-test-bin (bool) and test-filter (bytes) options; introduces coro_tests target; changes unit/coro test install vs run behavior based on emit-test-bin; removes conditional libc auto-link for stack-overflow-demo. Review test target wiring and link flags.
Tests (behavioral)
src/libs/aio/src/test/thread_pool.zig
Replaces reliance on internal running thread count with atomic counters (active, max_active) to measure concurrency; injects counters into TestFn instances and asserts on observed max parallelism.
Docs / notes
CLAUDE.md
Updates example Windows test command to include -Demit-test-bin flag.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

Coroutines queued, a matrix springs to life,
Emitted bins line up, ready for the strife,
QEMU and BSD join the nightly run,
Atomics count the threads until the test is done,
CI hums, a small victory signed in compile-time light.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add CI workflow for coro library' directly matches the main change—a new GitHub Actions workflow specifically for testing the coro library.
Description check ✅ Passed The description accurately covers the key aspects of the changeset: the new CI workflow, trigger conditions, platforms, architectures, build modes, and Zig versions tested.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-coro-workflow

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI Agents
In @.github/workflows/test-coro.yml:
- Line 48: Replace the brittle grep/sed pipeline that sets ZIG_LIB with a
jq-based JSON extraction: call zig env with JSON output and use jq to extract
the ".lib_dir" key (via the .[".lib_dir"] accessor) and assign that value to
ZIG_LIB so the path is parsed robustly and safely.
🧹 Nitpick comments (1)
.github/workflows/test-coro.yml (1)

68-71: Add explicit shell specification for consistency.

While the default shell might work, other steps explicitly specify shell: bash (line 46, 61). Adding it here improves consistency and prevents potential issues on Windows runners.

🔎 Proposed fix
     - name: Build for VM
       if: matrix.config.vm
+      shell: bash
       run: zig test src/libs/coro/src/coroutines.zig -O${{ matrix.optimize }} -lc -target ${{ matrix.config.target }} --test-no-exec -femit-bin=test
       timeout-minutes: 5
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 71ee6f6 and 076a33b.

📒 Files selected for processing (1)
  • .github/workflows/test-coro.yml
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
Repo: lalinsky/zio PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-30T10:31:31.222Z
Learning: Applies to build.zig : To test Windows builds on Linux, use `zig build build-tests -Dtarget=x86_64-windows && wine zig-out/bin/test.exe`
Learnt from: CR
Repo: lalinsky/zio PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-30T10:31:31.222Z
Learning: Applies to build.zig.zon : Update version in build.zig.zon as part of release process
Learnt from: CR
Repo: lalinsky/zio PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-30T10:31:31.222Z
Learning: Applies to **/*.zig : Use `zig env` to get the path to the Zig standard library when needed
📚 Learning: 2025-11-30T10:31:31.222Z
Learnt from: CR
Repo: lalinsky/zio PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-30T10:31:31.222Z
Learning: Applies to build.zig : To test Windows builds on Linux, use `zig build build-tests -Dtarget=x86_64-windows && wine zig-out/bin/test.exe`

Applied to files:

  • .github/workflows/test-coro.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: test (0.15.2, ReleaseSafe, ubuntu-latest, x86_64-netbsd, netbsd)
  • GitHub Check: test (master, Debug, macos-15-intel, native)
  • GitHub Check: test (master, ReleaseSafe, ubuntu-latest, x86_64-netbsd, netbsd)
  • GitHub Check: test (0.15.2, ReleaseSafe, windows-latest, native)
  • GitHub Check: test (master, Debug, ubuntu-latest, x86_64-netbsd, netbsd)
  • GitHub Check: test (master, ReleaseSafe, windows-11-arm, native)
  • GitHub Check: test (master, ReleaseSafe, ubuntu-latest, riscv64-linux, true)
  • GitHub Check: test (master, ReleaseSafe, windows-latest, native)
  • GitHub Check: test (master, Debug, windows-11-arm, native)
  • GitHub Check: test (master, Debug, ubuntu-latest, riscv64-linux, true)
  • GitHub Check: test (master, ReleaseSafe, ubuntu-latest, x86_64-freebsd, freebsd)
  • GitHub Check: test (master, Debug, windows-latest, native)
  • GitHub Check: test (master, Debug, ubuntu-latest, loongarch64-linux, true)
  • GitHub Check: test (0.15.2, ReleaseSafe, windows-11-arm, native)
  • GitHub Check: test (0.15.2, Debug, macos-15-intel, native)
  • GitHub Check: test (0.15.2, ReleaseSafe, ubuntu-latest, x86_64-freebsd, freebsd)
  • GitHub Check: test (0.15.2, ReleaseSafe, ubuntu-24.04-arm, native)
  • GitHub Check: test (0.15.2, Debug, windows-11-arm, native)
  • GitHub Check: test (0.15.2, Debug, ubuntu-latest, x86_64-netbsd, netbsd)
  • GitHub Check: test (windows-11-arm)
🔇 Additional comments (5)
.github/workflows/test-coro.yml (5)

1-12: LGTM!

The trigger configuration correctly limits workflow runs to changes affecting the coro library or the workflow itself, preventing unnecessary CI runs.


14-31: Comprehensive test matrix covers the bases.

The matrix correctly tests multiple Zig versions, optimization modes, and target platforms. The mix of native builds, QEMU cross-compilation, and VM-based testing for BSD systems is appropriate.


53-57: LGTM!

QEMU installation is correctly conditioned on the matrix configuration flag.


59-66: Test execution command is well-structured.

The conditional logic for -target and -fqemu flags correctly adapts the test command based on matrix configuration. The 10-minute timeout provides a reasonable safety net.


44-51: This patch runs safely in an isolated environment per job.

GitHub Actions runs each matrix job on a dedicated, ephemeral runner—jobs don't share runners or environments. The patch only executes when zig_version == 'master' (20 out of 40 jobs), and each execution modifies only that job's isolated Zig installation. After the job finishes, the runner state is discarded.

The sed -i.bak syntax works on both GNU sed (Ubuntu runners) and BSD sed (macOS/BSD runners), so portability isn't a concern here either.

The NetBSD ___lwp_park60 symbol fix is a legitimate patch for Zig master compatibility on that platform.

Likely an incorrect or invalid review comment.

if: matrix.zig_version == 'master'
shell: bash
run: |
ZIG_LIB=$(zig env | grep '\.lib_dir' | sed 's/.*"\(.*\)".*/\1/')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Replace fragile JSON parsing with jq.

Parsing zig env JSON output with grep and sed is brittle and can break on formatting changes or special characters in paths.

🔎 Proposed fix using jq
-        ZIG_LIB=$(zig env | grep '\.lib_dir' | sed 's/.*"\(.*\)".*/\1/')
+        ZIG_LIB=$(zig env | jq -r '.lib_dir')
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ZIG_LIB=$(zig env | grep '\.lib_dir' | sed 's/.*"\(.*\)".*/\1/')
ZIG_LIB=$(zig env | jq -r '.lib_dir')
🤖 Prompt for AI Agents
In @.github/workflows/test-coro.yml at line 48, Replace the brittle grep/sed
pipeline that sets ZIG_LIB with a jq-based JSON extraction: call zig env with
JSON output and use jq to extract the ".lib_dir" key (via the .[".lib_dir"]
accessor) and assign that value to ZIG_LIB so the path is parsed robustly and
safely.

Comment thread .github/workflows/test-coro.yml Outdated
Comment on lines +73 to +84
- name: Run tests (FreeBSD VM)
if: matrix.config.vm == 'freebsd'
uses: vmactions/freebsd-vm@v1
with:
run: ./test

- name: Run tests (NetBSD VM)
if: matrix.config.vm == 'netbsd'
uses: vmactions/netbsd-vm@v1
with:
release: '10.1'
run: ./test

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

vmactions/freebsd-vm github action workspace mount access

💡 Result:

Short answer: the vmactions/freebsd-vm action does not automatically give the FreeBSD VM a live mount of the GitHub workspace. Use the action's rsync helpers (or SSH/sshfs) to copy the workspace into the VM and back. See notes and example commands below.

Why: GitHub Actions exposes the workspace to containerized actions/runners via mounts on the host; when you run a separate VM (as vmactions does) the VM won't see that host mount unless you explicitly sync or mount it inside the VM. This is a common docker/runner mounting limitation. [1][3][4]

Recommended minimal workflow pattern

  • Checkout on the runner:
    • uses: actions/checkout@v4
  • Copy workspace into the VM:
    • call the action's helper to rsync (example from users): bash /home/runner/work/_actions/vmactions/freebsd-vm/v1/run.sh rsyncToVM
  • Run commands in the VM (via the action's ssh/ssh-forwarding)
  • Copy results back:
    • bash /home/runner/work/_actions/vmactions/freebsd-vm/v1/run.sh rsyncFromVM

Example snippet (conceptual):

  • name: Checkout
    uses: actions/checkout@v4
  • name: Copy workspace to VM
    run: bash /home/runner/work/_actions/vmactions/freebsd-vm/v1/run.sh rsyncToVM
  • name: Run on FreeBSD
    run: ssh freebsd 'cd /home/freebsd/workspace && your_build_steps'
  • name: Copy results back
    run: bash /home/runner/work/_actions/vmactions/freebsd-vm/v1/run.sh rsyncFromVM

Notes and alternatives

  • sshfs is supported but often brittle (UID/GID mapping and OS differences); many users prefer rsync for reliability and speed. [6]
  • The general GitHub Actions mount behavior and docker-in-docker mount caveats are relevant if you try to mount host paths into another container/VM. [1][4][8]

Sources

  • GitHub Actions runner / workspace mounting reference. [1]
  • Real-world usage and recommendation to use rsync (copy) instead of sshfs for vmactions/freebsd-vm. [6]
  • Docker/Actions mounting explanation and containerized-action mount caveats (context for why direct mount doesn't work). [8]

🌐 Web query:

vmactions/netbsd-vm github action documentation

💡 Result:

I found the primary docs/usage examples and alternatives:

  • vmactions namespace listing (netbsd-vm package info / versions). [1]
  • cross-platform-actions (recommended cross-platform replacement supporting NetBSD). [2]
  • Examples of using vmactions/netbsd-vm in real workflows (haproxy and netatalk workflows showing inputs like prepare, run, usesh, copyback). [3][4]

If you want, I can open the specific README/source for vmactions/netbsd-vm (or fetch example workflow snippets) and summarize its inputs and example usage.


🏁 Script executed:

find . -name "test-coro.yml" -o -name "*test*.yml" | head -20

Repository: lalinsky/zio

Length of output: 203


🏁 Script executed:

cat -n ./.github/workflows/test-coro.yml

Repository: lalinsky/zio

Length of output: 3327


The test binary won't be accessible inside the VM without an explicit workspace sync.

The workflow builds the binary on the runner (line 70: -femit-bin=test) but vmactions/freebsd-vm and vmactions/netbsd-vm don't automatically mount the GitHub Actions workspace into the VM. You need to sync the workspace into the VM before running it.

Add explicit workspace sync steps using the action's rsync helpers:

Example fix for FreeBSD
    - name: Build for VM
      if: matrix.config.vm == 'freebsd'
      run: zig test src/libs/coro/src/coroutines.zig -O${{ matrix.optimize }} -lc -target ${{ matrix.config.target }} --test-no-exec -femit-bin=test

    - name: Run tests (FreeBSD VM)
      if: matrix.config.vm == 'freebsd'
      uses: vmactions/freebsd-vm@v1
      with:
        prepare: |
          pkg install -y rsync
        run: ./test

Alternatively, use the action's built-in rsync parameters if available, or SSH-based execution if the action supports it. Check the action's source or examples for the exact sync mechanism.

@lalinsky
lalinsky force-pushed the add-coro-workflow branch 3 times, most recently from 9428573 to 22e727f Compare January 6, 2026 09:04

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI Agents
In @.github/workflows/test-coro.yml:
- Around line 68-84: The VM steps use vmactions/freebsd-vm and
vmactions/netbsd-vm but the workspace is not synced into the VM, so the test
binary produced by the "Build for VM" step (zig build test-coro) won’t be
present when running ./zig-out/bin/test; fix by enabling the action's workspace
sync or copyback option (enable the sync/copyback input for vmactions/freebsd-vm
and vmactions/netbsd-vm), or add an explicit file copy/rsync step to transfer
./zig-out/bin/test into the VM before the "Run tests" steps, or upgrade to a
newer action version that documents automatic workspace sync and use its
documented inputs accordingly.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 076a33b and 22e727f.

📒 Files selected for processing (5)
  • .github/workflows/test-coro.yml
  • .github/workflows/test.yml
  • CLAUDE.md
  • build.zig
  • check.sh
🧰 Additional context used
📓 Path-based instructions (2)
**/*.zig

📄 CodeRabbit inference engine (CLAUDE.md)

Use zig env to get the path to the Zig standard library when needed

Files:

  • build.zig
build.zig

📄 CodeRabbit inference engine (CLAUDE.md)

To test Windows builds on Linux, use zig build build-tests -Dtarget=x86_64-windows && wine zig-out/bin/test.exe

Files:

  • build.zig
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: lalinsky/zio PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-30T10:31:31.222Z
Learning: Applies to build.zig : To test Windows builds on Linux, use `zig build build-tests -Dtarget=x86_64-windows && wine zig-out/bin/test.exe`
Learnt from: CR
Repo: lalinsky/zio PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-30T10:31:31.222Z
Learning: Applies to build.zig.zon : Update version in build.zig.zon as part of release process
📚 Learning: 2025-11-30T10:31:31.222Z
Learnt from: CR
Repo: lalinsky/zio PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-30T10:31:31.222Z
Learning: Applies to build.zig : To test Windows builds on Linux, use `zig build build-tests -Dtarget=x86_64-windows && wine zig-out/bin/test.exe`

Applied to files:

  • CLAUDE.md
  • .github/workflows/test.yml
  • check.sh
  • build.zig
  • .github/workflows/test-coro.yml
📚 Learning: 2025-11-30T10:31:31.222Z
Learnt from: CR
Repo: lalinsky/zio PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-30T10:31:31.222Z
Learning: Applies to build.zig.zon : Update version in build.zig.zon as part of release process

Applied to files:

  • CLAUDE.md
  • .github/workflows/test.yml
  • build.zig
  • .github/workflows/test-coro.yml
📚 Learning: 2025-11-30T10:31:31.222Z
Learnt from: CR
Repo: lalinsky/zio PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-30T10:31:31.222Z
Learning: Applies to **/*.zig : Use `zig env` to get the path to the Zig standard library when needed

Applied to files:

  • CLAUDE.md
  • check.sh
  • build.zig
  • .github/workflows/test-coro.yml
📚 Learning: 2025-11-30T10:31:31.222Z
Learnt from: CR
Repo: lalinsky/zio PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-30T10:31:31.222Z
Learning: Applies to docs/changelog.md : Update docs/changelog.md - change [Unreleased] to [X.Y.Z] with current date as part of release process

Applied to files:

  • CLAUDE.md
📚 Learning: 2025-11-30T10:31:31.222Z
Learnt from: CR
Repo: lalinsky/zio PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-30T10:31:31.222Z
Learning: Commit files with message "Release vX.Y.Z" and tag the commit with vX.Y.Z, then push commit and tags

Applied to files:

  • CLAUDE.md
📚 Learning: 2025-11-30T10:31:31.222Z
Learnt from: CR
Repo: lalinsky/zio PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-30T10:31:31.222Z
Learning: Use `./check.sh` to format code and run unit tests

Applied to files:

  • check.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: test (0.15.2, ReleaseSafe, windows-latest, native)
  • GitHub Check: test (0.15.2, Debug, windows-latest, native)
  • GitHub Check: test (master, Debug, windows-latest, native)
  • GitHub Check: test (master, ReleaseSafe, ubuntu-24.04, native)
  • GitHub Check: test (master, ReleaseSafe, windows-latest, native)
  • GitHub Check: test (macos-15-intel)
  • GitHub Check: test (windows-11-arm)
  • GitHub Check: test (windows-latest)
🔇 Additional comments (9)
.github/workflows/test.yml (1)

36-38: Looks good.

The switch to -Demit-test-bin matches the new build.zig option. Build + run flow is correct.

CLAUDE.md (1)

10-10: Docs updated correctly.

The Windows cross-compile test command now uses the new -Demit-test-bin flag. Matches the build.zig changes.

check.sh (1)

74-75: Solid change.

Two-step approach (build then run) is clean. Timeout is sensible. The env vars get picked up by the test runner at execution time, so this works.

.github/workflows/test-coro.yml (3)

1-12: Path triggers look right.

Workflow triggers on coro source changes and the workflow file itself. That's the correct pattern for a focused CI.


16-31: Good matrix coverage.

Native Linux/macOS/Windows on x86_64 and ARM, plus cross-compilation with QEMU for RISC-V and LoongArch, plus BSD VMs. That's thorough.

One thing: the matrix will produce 4 × 2 × 11 = 88 jobs. With fail-fast: false, if something fundamental breaks, all 88 jobs will run to completion. Might want to reconsider that if CI minutes become a concern.


59-66: Native/QEMU test path looks correct.

The conditional -Dtarget and -fqemu flags are constructed properly. 10-minute timeout is reasonable for emulated architectures.

build.zig (3)

103-103: Good option design.

Boolean with orelse false default keeps backward compatibility. Existing zig build test invocations continue to work.


111-116: Clean conditional logic.

Either emit the binary for later execution (cross-compile, VM targets) or run it directly. No redundant work.


118-134: Coro tests target added correctly.

Follows the same pattern as the main test step. Note that coro_tests doesn't use a custom test_runner like lib_unit_tests does (line 107). If that's intentional (e.g., coro tests don't need the custom test filtering/logging), then this is fine. If you want the same test runner behavior, you'd need to add it.

Comment on lines +68 to +84
- name: Build for VM
if: matrix.config.vm
run: zig build test-coro -Doptimize=${{ matrix.optimize }} -Dtarget=${{ matrix.config.target }} -Demit-test-bin
timeout-minutes: 5

- name: Run tests (FreeBSD VM)
if: matrix.config.vm == 'freebsd'
uses: vmactions/freebsd-vm@v1
with:
run: ./zig-out/bin/test

- name: Run tests (NetBSD VM)
if: matrix.config.vm == 'netbsd'
uses: vmactions/netbsd-vm@v1
with:
release: '10.1'
run: ./zig-out/bin/test

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

VM workspace sync issue still present.

This was flagged in a previous review. The vmactions/freebsd-vm and vmactions/netbsd-vm actions don't automatically mount the GitHub Actions workspace into the VM. The test binary built at line 70 won't be accessible when you try to run ./zig-out/bin/test inside the VM.

You need to either:

  1. Use the action's sync or copyback parameters
  2. Use rsync helpers to copy files into the VM
  3. Check if newer versions of these actions have changed this behavior
vmactions/freebsd-vm v1 sync workspace automatically 2024 2025
🤖 Prompt for AI Agents
In @.github/workflows/test-coro.yml around lines 68 - 84, The VM steps use
vmactions/freebsd-vm and vmactions/netbsd-vm but the workspace is not synced
into the VM, so the test binary produced by the "Build for VM" step (zig build
test-coro) won’t be present when running ./zig-out/bin/test; fix by enabling the
action's workspace sync or copyback option (enable the sync/copyback input for
vmactions/freebsd-vm and vmactions/netbsd-vm), or add an explicit file
copy/rsync step to transfer ./zig-out/bin/test into the VM before the "Run
tests" steps, or upgrade to a newer action version that documents automatic
workspace sync and use its documented inputs accordingly.

Test coroutines on multiple platforms:
- Linux (x86_64, ARM, RISC-V, LoongArch)
- macOS (Apple Silicon, Intel)
- Windows (x86_64, ARM)
- FreeBSD, NetBSD (via VMs)

Tests both Debug and ReleaseSafe builds with Zig 0.15.2 and master.

Add test-coro build target and -Demit-test-bin option for cross-compilation.
- Track max concurrent tasks instead of checking thread count after completion
- Mark test runs as having side effects for build summary

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
build.zig (2)

106-119: Consider explicit naming for the test binary.

When emit_test_bin is true, b.addInstallArtifact(lib_unit_tests, .{}) installs the test binary without an explicit name. This could result in a generic name like test, which might conflict with the coro_tests binary or cause confusion about which test suite is being run.

🔎 Suggested fix to add explicit test binary naming
     const lib_unit_tests = b.addTest(.{
+        .name = "test",
         .root_module = zio,
         .test_runner = .{ .path = b.path("test_runner.zig"), .mode = .simple },
         .filters = if (test_filter) |f| &.{f} else &.{},
     });

121-139: Add explicit naming for coro_tests to prevent conflicts.

Similar to the main test suite, coro_tests lacks an explicit name. When both test binaries are installed (via emit_test_bin), they might collide or create ambiguity about which binary is which.

🔎 Suggested fix to add explicit naming
     const coro_tests = b.addTest(.{
+        .name = "test-coro",
         .root_module = b.createModule(.{
             .root_source_file = b.path("src/libs/coro/src/coroutines.zig"),
             .target = target,
             .optimize = optimize,
             .link_libc = true,
         }),
         .filters = if (test_filter) |f| &.{f} else &.{},
     });
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 22e727f and 6731465.

📒 Files selected for processing (6)
  • .github/workflows/test-coro.yml
  • .github/workflows/test.yml
  • CLAUDE.md
  • build.zig
  • check.sh
  • src/libs/aio/src/test/thread_pool.zig
🚧 Files skipped from review as they are similar to previous changes (3)
  • .github/workflows/test.yml
  • check.sh
  • .github/workflows/test-coro.yml
🧰 Additional context used
📓 Path-based instructions (2)
**/*.zig

📄 CodeRabbit inference engine (CLAUDE.md)

Use zig env to get the path to the Zig standard library when needed

Files:

  • src/libs/aio/src/test/thread_pool.zig
  • build.zig
build.zig

📄 CodeRabbit inference engine (CLAUDE.md)

To test Windows builds on Linux, use zig build build-tests -Dtarget=x86_64-windows && wine zig-out/bin/test.exe

Files:

  • build.zig
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: lalinsky/zio PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-30T10:31:31.222Z
Learning: Applies to build.zig : To test Windows builds on Linux, use `zig build build-tests -Dtarget=x86_64-windows && wine zig-out/bin/test.exe`
Learnt from: CR
Repo: lalinsky/zio PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-30T10:31:31.222Z
Learning: Applies to build.zig.zon : Update version in build.zig.zon as part of release process
📚 Learning: 2025-11-30T10:31:31.222Z
Learnt from: CR
Repo: lalinsky/zio PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-30T10:31:31.222Z
Learning: Applies to build.zig : To test Windows builds on Linux, use `zig build build-tests -Dtarget=x86_64-windows && wine zig-out/bin/test.exe`

Applied to files:

  • build.zig
  • CLAUDE.md
📚 Learning: 2025-11-30T10:31:31.222Z
Learnt from: CR
Repo: lalinsky/zio PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-30T10:31:31.222Z
Learning: Applies to build.zig.zon : Update version in build.zig.zon as part of release process

Applied to files:

  • build.zig
  • CLAUDE.md
📚 Learning: 2025-11-30T10:31:31.222Z
Learnt from: CR
Repo: lalinsky/zio PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-30T10:31:31.222Z
Learning: Applies to **/*.zig : Use `zig env` to get the path to the Zig standard library when needed

Applied to files:

  • build.zig
  • CLAUDE.md
📚 Learning: 2025-10-16T14:33:19.718Z
Learnt from: lalinsky
Repo: lalinsky/zio PR: 48
File: src/core/ConcurrentAwaitableList.zig:254-269
Timestamp: 2025-10-16T14:33:19.718Z
Learning: In the zio repository's `src/core/ConcurrentAwaitableList.zig` and `src/core/Awaitable.zig`, the `in_list` field should remain debug-only (conditional compilation with `builtin.mode == .Debug`). Double-removal detection in `ConcurrentAwaitableList.remove()` uses pointer-based checks (comparing `prev`/`next` against `head`/`tail`) rather than relying on a regular `in_list` field.

Applied to files:

  • build.zig
📚 Learning: 2025-11-30T10:31:31.222Z
Learnt from: CR
Repo: lalinsky/zio PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-30T10:31:31.222Z
Learning: Applies to docs/changelog.md : Update docs/changelog.md - change [Unreleased] to [X.Y.Z] with current date as part of release process

Applied to files:

  • CLAUDE.md
📚 Learning: 2025-11-30T10:31:31.222Z
Learnt from: CR
Repo: lalinsky/zio PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-30T10:31:31.222Z
Learning: Commit files with message "Release vX.Y.Z" and tag the commit with vX.Y.Z, then push commit and tags

Applied to files:

  • CLAUDE.md
🔇 Additional comments (3)
src/libs/aio/src/test/thread_pool.zig (1)

51-91: Good addition of concurrency tracking.

The atomic counter approach directly measures actual concurrent execution instead of relying on thread pool internals. The memory ordering (acq_rel for updates, acquire for load) is appropriate for cross-thread synchronization, and the assertion max_active > 1 correctly verifies that tasks actually ran in parallel.

build.zig (1)

103-104: LGTM on the new build options.

The emit-test-bin and test-filter options provide the control needed for CI workflows to build test binaries separately from execution.

CLAUDE.md (1)

10-10: Verify the test binary output path and clarify the test step name.

The step name in the command is correct (zig build test), but there are two separate test steps: zig build test for lib_unit_tests and zig build test-coro for coro_tests. The binary name assumption needs verification—when using addInstallArtifact() without an explicit .name parameter, the actual output filename depends on Zig's default naming behavior. Check what executable name is actually produced in zig-out/bin/ after building with -Demit-test-bin, or explicitly set the .name parameter in build.zig to ensure predictable output.

@lalinsky
lalinsky merged commit 2e76b2e into main Jan 6, 2026
@lalinsky
lalinsky deleted the add-coro-workflow branch January 6, 2026 09:32
This was referenced Jan 7, 2026
This was referenced Jan 26, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Apr 16, 2026
1 of 4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant