ci: make the reproducibility gate able to fail - #2
Open
zah wants to merge 1 commit into
Open
Conversation
The "Test reproducible builds" step could not detect an irreproducible build for two independent reasons: diff -r result-1 result-1-rebuild || echo "Build not reproducible ..." 1. A real difference was swallowed by `|| echo`: the step printed a message and still exited 0, so the job stayed green. 2. The "rebuild" invocations were plain `nix build` calls, which resolve to the store path that is already there instead of re-running the derivation. The two out-links therefore always pointed at the same store path and the comparison was vacuous even before the `|| echo`. The rebuild now uses `nix build --rebuild`, so Nix actually re-executes the derivation and compares the fresh output with the one in the store, and the comparison loop prints the full diff and exits non-zero when the outputs differ. This may turn the job red. If it does, the irreproducibility is pre-existing and was previously hidden, not introduced here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was broken
.github/workflows/ci.yml, jobdocumentation-reproducibility, step "Test reproducible builds". The entire assertion was:This gate could not detect an irreproducible build, for two independent reasons:
|| echoturns a real difference into a log line and an exit status of0. A reproducibility regression printed a message and the job stayed green.nix build. Nix resolves them to the store path that already exists instead of re-running the derivation, soresult-1andresult-1-rebuildwere two symlinks to the same store path.diff -rwas comparing a directory with itself. Even without the|| echo, the check would have passed unconditionally.Evidence for (2) from the last green
CI/CD Pipelinerun of this step (run27944090156, job Documentation & Reproducibility): the first twonix buildcalls build 15 derivations, and the two-rebuildcalls emit nothing at all except a settings warning before the step ends. No rebuild, no diff output.What changed
Only the one step. No new tolerances, no
continue-on-error, no skips.Two layers now do real work:
--rebuildmakes Nix itself fail the step when a re-execution produces a different output, and the explicitdiffloop prints the file-level diff and propagates a non-zero exit. Diagnostics are preserved — the diff is still printed in full — but the step can no longer report success on a real difference.Mutation verification
An argument is not evidence, so the new step body was executed against real, differing directories. The body was extracted verbatim from the committed YAML with
yq, and run with a stubnixonPATHthat materializes the-o <name>out-links from fixture directories — so the shell that runs is byte-for-byte the shell CI runs.Scenario A — an actual differing pair (
result-1/bin/rust-echo-service=BUILD-A,result-1-rebuild/bin/rust-echo-service=BUILD-B-DIFFERENT):Scenario B — an identical pair:
Scenario C — only the second component drifts (content change + an extra file), proving the loop does not short-circuit after the first pair:
Control — the old body against the exact same differing pair from Scenario A:
1vs0on identical inputs is the whole point of this PR.The
--rebuildhalf, verified independently--rebuildis the part that actually re-executes the derivation, so it was verified on a derivation that is nondeterministic by construction (date +%s%N > $out/stamp):A demonstrably nondeterministic derivation is re-"built" by the old command with exit code
0.--rebuildcatches it. Note--rebuildrequires the output to already be valid in the store, which is why the plain builds ofresult-1/result-2stay and run first.The new step body also passes
shellcheck -s bashcleanly.Is the build actually reproducible?
Yes — and this PR is the first time that has ever actually been checked.
Before this change there was no signal at all. Because of defect (2), the job never once re-executed either derivation, so the absence of a
Build not reproducibleline in past logs was not evidence of reproducibility — the check was comparing each out-link with itself.The hardened step ran on this PR (
CI/CD Pipelinerun31975702359, job Documentation & Reproducibility) and produced real verification:Those
checking outputs of ...lines are Nix genuinely re-running each derivation and byte-comparing the result with the store — they have never appeared in this job's logs before. The job's conclusion issuccess, and this time that means something.Independently confirmed on a local machine:
So the good news is that nothing is being hidden today. The point stands regardless: the gate that was supposed to protect this property could not have reported a regression, and now it can.
Other cannot-fail checks in this repo (reported, not changed here)
Found while auditing
ci.yml; none are touched by this PR, and each deserves its own decision:ci.yml:121-133— "Test<component>basic functionality" ends every branch in|| true. A binary that segfaults on startup passes this step exactly like one that runs fine. A meaningful version would assert the expected exit status (e.g.124fromtimeoutfor the long-running services,0for--help).ci.yml:174-186— coverage generation iscargo install ... || true/cargo tarpaulin ... || true, and the Codecov upload setsfail_ci_if_error: false. Defensible for coverage reporting, but it means a total coverage-tooling outage is invisible.ci.yml:213-216—chmod +x build/bin/* || true/ls -la build/bin/* || true. If the artifact download produced nothing, this step passes and the failure surfaces later as a confusing integration-test error.Justfile:212—ci-docs-reproducibility: check generate-docsis advertised as the local mirror of this CI job but performs no reproducibility check at all, sojust ci-maincannot catch a reproducibility regression either.ci.yml:221-229(pkill -f ... || truein the always-run cleanup step) is a legitimate use —pkillexits 1 when nothing matched — and is left alone. There is nocontinue-on-error:anywhere in the repository.🤖 Generated with Claude Code