Skip to content

fix(ci): run every bats unit file after a failure and cover build-*.sh in the cross-compile check - #4633

Merged
Aleksei Sviridkin (lexfrei) merged 2 commits into
mainfrom
fix/unit-lane-keep-going
Oct 1, 2026
Merged

Aleksei Sviridkin (lexfrei) merged 2 commits into
mainfrom
fix/unit-lane-keep-going

Conversation

@lexfrei

@lexfrei Aleksei Sviridkin (lexfrei) commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

Two fixes to the tooling of the unit lane.

A local run of the bats unit tests stopped at the first red file and never ran the files after it, while the output looked like a finished suite. Each bats file is its own make target, and without --keep-going make stops scheduling targets after the first failure. CI passes -k, so it was not affected. The target now runs the files in a --keep-going sub-make. That sub-make still exits non-zero if any file failed, and it shares the caller's -j slots and --output-sync. The new hack/bats-unit-keep-going.bats drives the real Makefile against two fixture files. It checks that both run and the target fails when the first one fails, that the target exits 0 when both pass, and that the sub-make still finds the root Makefile when MAKEFILES names another file. I split the exact-line check on this target in hack/bats-runner-coverage.bats in two to match the new recipe. A workflow comment and a test name that still called each file a prerequisite now call it a target.

The cross-compile check never looked at the multus-cni builder. It treated only a script named exactly *build.sh as a compile step, and multus runs upstream ./hack/build-go.sh. The pattern now allows a suffix after build but no /, and each case has a fixture test. Among the Dockerfiles the check scans under packages/, this matches exactly one new line, the multus stage, and that stage passes.

Closes #3692 for the make-level truncation. The in-file half, where hack/cozytest.sh ends a file at its first failing test, is tracked in #4620.

Closes #4500

Things I left out:

  • The multus stage passes because a curl ... TARGETARCH step sits in the same stage. The check does not see that build-go.sh reads TARGETPLATFORM. The test header already documents this per-stage limit.
  • The sub-make reads only the root Makefile, so an extra make -f other.mk given to the parent no longer reaches the bats targets. Command-line variables and MAKEFILES still do. Nothing in the repo calls it that way.

Screenshots

Not a UI change.

Downstream repositories

Release note

fix(ci): `make bats-unit-tests` runs every bats file after a failing one and still fails at the end, and the image cross-compile check now covers build scripts such as `build-go.sh`.

Summary by CodeRabbit

  • Bug Fixes
    • Unit tests now continue running across individual test-file failures while still reporting an overall failure if any file fails.
    • Build-stage detection now recognizes build scripts with names such as build-go.sh.
  • Tests
    • Added coverage for unit-test results and build-script detection.

…le check

The compile pattern only matched a script named exactly *build.sh, so
the multus-cni builder, which compiles through upstream
./hack/build-go.sh, was never classified as compiling and the check
skipped the stage while appearing to cover it. Allow a suffix after
"build" in the script name, but not a directory separator, so a path
through a build/ directory is not mistaken for a build script.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <[email protected]>
Each bats file is its own make target, so a plain `make bats-unit-tests`
stopped scheduling files at the first red one and never ran the rest,
while the output looked like a finished suite. CI passes -k and was not
affected; a local run was. The target now runs the files in a
--keep-going sub-make, which still exits non-zero when any file fails
and shares the caller's job slots and output sync.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <[email protected]>
@github-actions github-actions Bot added area/ci Issues or PRs related to CI workflows, GitHub Actions, automation kind/bug Categorizes issue or PR as related to a bug size/L This PR changes 100-499 lines, ignoring generated files labels Sep 30, 2026
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: cozystack/cozystack/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 69891ba7-09a5-45dd-8046-83a374eff6d6

📥 Commits

Reviewing files that changed from the base of the PR and between 0592d0e and 71a9432.

📒 Files selected for processing (6)
  • .github/workflows/pull-requests.yaml
  • Makefile
  • hack/bats-runner-coverage.bats
  • hack/bats-unit-keep-going.bats
  • hack/image-builders-cross-compile.bats
  • hack/unit-test-parallelism.bats

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The Makefile runs per-file BATS unit targets through a keep-going sub-make. New tests check execution and exit behavior. The cross-compile detector now recognizes build scripts by filename, with tests for matching and non-matching examples.

Changes

BATS unit-test execution

Layer / File(s) Summary
Run unit targets with keep-going
Makefile, .github/workflows/pull-requests.yaml, hack/bats-runner-coverage.bats, hack/bats-unit-keep-going.bats, hack/unit-test-parallelism.bats
bats-unit-tests invokes per-file targets through a keep-going sub-make. Tests check that files run after a failure, verify exit status, and confirm the target relationships. The workflow comment describes the shared four-slot jobserver. The parallelism test name now refers to independent Make targets.

Cross-compile stage detection

Layer / File(s) Summary
Recognize build scripts by filename
hack/image-builders-cross-compile.bats
The detector recognizes .sh filenames that contain build. Tests check that build-go.sh matches and build/install.sh does not.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 71a94

The changes address unit-test continuation and build-script detection, with focused regression coverage. No concrete merge-blocking issue is established; merge after normal checks pass.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes both primary changes: continuing BATS unit files after failures and covering build-*.sh in the cross-compile check. It is specific and clear.
Linked Issues check ✅ Passed The PR meets both active linked coding requirements. For [#3692], bats-unit-tests invokes all per-file targets in a --keep-going sub-make, so a failed file does not stop later files and the sub-ma…
Out of Scope Changes check ✅ Passed The changes stay within the linked issue scope. The Makefile change, unit-lane tests, coverage-model update, cross-compile detector change, detector tests, and related workflow wording support [#3692]…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files. (2 skipped: 2 …
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@IvanHunters IvanHunters left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Verdict

LGTM

Summary

I ran both halves instead of eyeballing them. make bats-unit-tests now runs its files under a sub-make with --keep-going, and the aggregated exit stays non-zero when any file fails, including when the sub-make inherits -k from the parent (which is how CI invokes it: make unit-tests test-controllers -j4 -k --output-sync=target). The widened cross-compile regex is a strict superset of the old one, and the build/-directory exclusion holds.

Checked and correct

  • Exit propagation: with a two-file fixture under the real Makefile, forcing the first-scheduled file to fail runs both files and exits 2; an all-pass run exits 0. This holds with and without the parent -k, so keeping going does not mask a red file.
  • Coverage fires: the new build-go.sh test passes and reverting the regex to build[.]sh reddens it. build-go.sh appears only in packages/system/multus/images/multus-cni/Dockerfile, in a build stage that already carries TARGETPLATFORM/TARGETARCH, so the wider match adds no newly-failing stage.
  • build/-directory exclusion: ./build/install.sh is correctly not treated as a build script, and allowing a slash in the bracket reddens that test.
  • ROOT_MAKEFILE := $(lastword $(MAKEFILE_LIST)) resolves to the root Makefile even when MAKEFILES names another file first, covered by the new test and confirmed on a run.
  • No negated-assertion masking: the touched bats files assert in positive [ ... ] form; the || true uses sit in count subshells, not in swallowed assertions.
  • The renamed unit-test-parallelism.bats test (prerequisite to target) keeps its body and still enforces per-file scheduling and the no-serial-loop guard.

Left unverified

  • Local make is 3.81, so unit-test-parallelism.bats test 1 self-skips and --output-sync grouping is not exercised here. The recursive make -n path was confirmed on 3.81, and the make 4.x path is covered by CI's green unit job on the reviewed head.
  • awk portability of the new [^[:space:]\/] bracket was not reproduced across awk variants locally (only BSD awk present); it is settled by the same CI job running the cross-compile bats green under the runner's awk.

Tested against: the branch merges cleanly into current main (per bootstrap), and the unit and controller CI job is green on the reviewed head.

@lexfrei
Aleksei Sviridkin (lexfrei) merged commit d8ec8f0 into main Oct 1, 2026
58 checks passed
@lexfrei
Aleksei Sviridkin (lexfrei) deleted the fix/unit-lane-keep-going branch October 1, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ci Issues or PRs related to CI workflows, GitHub Actions, automation kind/bug Categorizes issue or PR as related to a bug size/L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

2 participants