From bd67be08173c744b426d99b5d03949677faf5ca2 Mon Sep 17 00:00:00 2001 From: Victor Benarbia Date: Thu, 5 Nov 2026 05:14:20 -0600 Subject: [PATCH] CI: run coverage on Linux arm64 and enforce 90% MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AI: Claude Opus 5.5 · effort unknown · main session: moved the kcov job off macOS, verified in a local Debian trixie arm64 container The macOS coverage job timed out on every run: kcov hung the unit-test binary under ptrace until the 15-minute step cap fired. Run it instead on ubuntu-24.04-arm in a debian:trixie container, which packages kcov 43 (Ubuntu 24.04 has none). kcov disables ASLR via personality(2), which Docker's default seccomp profile rejects, so the container runs with seccomp=unconfined. The job is no longer advisory and fails below 90% line coverage or when kcov reports no instrumented files. README coverage figure refreshed (94.01% without a key). Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 59 ++++++++++++++++++++++------------------ CHANGELOG.md | 3 ++ README.md | 12 ++++---- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 278315e..92509ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,50 +37,57 @@ jobs: zig build --build-file demo/flight_tracker/build.zig zig build test --build-file demo/wasm/build.zig --summary all - # Runs on macOS: kcov reads the unit-test binary's debug info there, - # while on Linux it reports zero instrumented files for that binary - # (the integration binary works on both). - # - # Advisory only: kcov has been observed to hang the unit-test binary under - # ptrace on macOS, so the job is time-boxed and does not fail the workflow. + # Runs on Linux arm64 inside Debian trixie, which packages kcov 43: + # - macOS: kcov hung the unit-test binary under ptrace on the hosted + # runner until the step timed out, on every run. + # - Linux x86_64: kcov reports zero instrumented files for Zig's Debug + # binaries. + # - Ubuntu 24.04: no kcov package. + # kcov disables ASLR with personality(2), which Docker's default seccomp + # profile rejects (kcov exits 255), hence seccomp=unconfined. coverage: - runs-on: macos-latest - # A generous backstop for the whole job (checkout/setup/brew), well - # above the coverage step's own 15m cap so that cap is what normally - # fires. A job-level timeout cancels the job, which continue-on-error - # cannot suppress, so it must not be the common case. - timeout-minutes: 30 - continue-on-error: true + runs-on: ubuntu-24.04-arm + container: + image: debian:trixie + options: --security-opt seccomp=unconfined + timeout-minutes: 15 steps: + - name: Install kcov + run: | + apt-get update -qq + apt-get install -y -qq --no-install-recommends \ + kcov python3 git ca-certificates curl xz-utils zstd - uses: actions/checkout@v4 - uses: mlugg/setup-zig@v2 with: version: 0.16.0 - - name: Install kcov - run: brew install kcov - name: Code coverage - timeout-minutes: 15 + timeout-minutes: 10 env: SERPAPI_KEY: ${{ secrets.SERPAPI_KEY }} run: | - zig build cov - for f in $(find zig-out/coverage -maxdepth 3 -name coverage.json); do - echo "$f: $(head -c 300 $f | tr -d '\n')" - done - python3 - <<'EOF' >> "$GITHUB_STEP_SUMMARY" - import json + zig build cov --summary all + python3 - <<'EOF' + import json, os, sys + minimum = 90.0 # REVIEW Q6 report = json.load(open("zig-out/coverage/merged/kcov-merged/coverage.json")) - print("## Code coverage: %s%%\n" % report["percent_covered"]) - print("| file | covered | total | percent |") - print("|---|---|---|---|") + total = float(report["percent_covered"]) + lines = ["## Code coverage: %.2f%% (minimum %.0f%%)\n" % (total, minimum), + "| file | covered | total | percent |", "|---|---|---|---|"] for f in report["files"]: - print("| %s | %s | %s | %s%% |" % ( + lines.append("| %s | %s | %s | %s%% |" % ( f["file"].split("/")[-1], f["covered_lines"], f["total_lines"], f["percent_covered"])) + print("\n".join(lines)) + with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as summary: + summary.write("\n".join(lines) + "\n") + if not report["files"] or total < minimum: + sys.exit("coverage %.2f%% is below %.0f%%" % (total, minimum)) EOF - name: Upload HTML report + if: ${{ !cancelled() }} uses: actions/upload-artifact@v4 with: name: coverage diff --git a/CHANGELOG.md b/CHANGELOG.md index 9412819..4492bbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ and refuses to start unless it runs from `master` with `SERPAPI_KEY` set and an empty `git status --porcelain` (the previous `git diff --quiet` missed staged and untracked files) +- CI: the coverage job runs on Linux arm64 (Debian trixie container) instead + of macOS, where kcov hung the unit-test binary until the step timed out on + every run. It is no longer advisory, and fails below 90% line coverage ### Behavior changes diff --git a/README.md b/README.md index 6116ac2..607cfa7 100644 --- a/README.md +++ b/README.md @@ -457,11 +457,13 @@ zig build cov open zig-out/coverage/merged/kcov-merged/index.html ``` -Current state: **90.4% of lines covered** (225 of 249 in `src/client.zig`) -without an API key, since the tests covering `html`, `md`, `searchArchive`, and -`account` skip themselves rather than fail. With `SERPAPI_KEY` set — as in -CI, which publishes the figure to every job summary — those paths execute -too and coverage rises accordingly. +Current state: **94.01% of lines covered** (596 of 634) without an API key, +since the tests covering `html`, `md`, `searchArchive`, and `account` skip +themselves rather than fail. With `SERPAPI_KEY` set — as in CI, which +publishes the figure to every job summary and fails below 90% — those paths +execute too and coverage rises accordingly. CI measures on Linux arm64 in a +Debian trixie container; kcov needs `--security-opt seccomp=unconfined` to +run inside Docker. The lines that remain uncovered either way are `errdefer` branches that only execute if the operating system refuses an allocation midway through a