fix(tests): verify the semver cache works, not just that it exists - #52
Merged
Conversation
npm install is the largest remaining cost in these jobs, and it is almost entirely the audit — a network round trip over the whole dependency tree on every run, even when node_modules was restored intact: snellmanrecipes up to date, audited 1716 packages in 48s beamex up to date, audited 1880 packages in 60s kaskipuu up to date, audited 1930 packages in 1m Locally on a 1250-package tree: 9s with audit, 1s without. Set via npm config rather than CLI flags so it covers every npm invocation, including the ones inside projects' composer build scripts, which is where these installs actually happen. Dependency vulnerabilities are covered by the nightly vulnerability scan, which gates and opens PRs. npm's install-time audit summary gates nothing. The internal setup ref is temporarily pointed at this branch to verify; that is reverted before merge. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Three of six composer-update test files were red on master. All three had the
same cause, and none of the symptoms pointed at it.
ensure_semver_vendor caches a composer/semver vendor dir and guarded it with
if [ ! -f "$cache/vendor/autoload.php" ]; then ... build ... fi
Existence is too weak. An interrupted `composer require` leaves autoload.php
and vendor/composer/ behind WITHOUT vendor/composer/ClassLoader.php — the local
cache here had exactly that shape, with composer/semver present but the
autoloader's own class file missing. The guard was satisfied, so the cache was
never rebuilt: every run copied a broken autoloader into the test project, the
PHP helpers fatally errored on the missing ClassLoader, and their non-JSON
output reached jq as
jq: parse error: Invalid numeric literal at line 2, column 8
which reads like a bug in the helper's JSON, not a missing dependency. The
partial cache is also sticky — once in that state it stays broken across every
future run.
Now the guard actually exercises the cache: require the autoloader and check
Composer\Semver\Semver resolves. If it does not, the cache is deleted and
rebuilt from scratch rather than built on top of a partial tree, and the
loud-failure path reports a *working* bootstrap could not be produced.
Suite goes from 3 of 6 files failing to 6 of 6 passing, with no change to any
assertion or to the scripts under test.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This branch carried
uses: generoi/github-actions/setup@perf/npm-no-audit
which is #53's verification branch, picked up from master when this branch was
cut. #53 has since merged, so the ref is both unnecessary and wrong: leaving it
would point every consumer of the shared test workflow at a feature branch
instead of the release tag.
Restored from master. Nothing else in this branch touches test.yml — the actual
change here is confined to composer-update/tests/lib.sh.
master and the v1/v2 tags were checked and both already carry @v1, so this
never reached downstream.
Second instance of this pattern; the first was a "tmp: point internal setup ref
at this branch for verification" commit carrying setup@fix/drop-vendor-cache,
caught and reverted before #50 was opened.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…he-integrity * origin/master: perf(setup): disable npm audit and fund in CI (#53)
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.
3 of 6 composer-update test files were failing on master. All three had the same cause, and none of the symptoms pointed at it.
The bug
ensure_semver_vendorcaches acomposer/semvervendor dir and guarded it with:Existence is too weak a test. An interrupted
composer requireleavesautoload.phpandvendor/composer/behind withoutvendor/composer/ClassLoader.php. The local cache had exactly that shape:composer/semverwas there. The autoloader's own class file wasn't.Why it stayed broken
The guard was satisfied, so the cache was never rebuilt. Every run copied a broken autoloader into the test project, the PHP helpers fatally errored on the missing
ClassLoader, and their non-JSON output reachedjqas:That reads like a bug in the helper's JSON output, not a missing dependency — which is why it sat unfixed. And it's sticky: once the cache is in that state it stays broken for every future run, on that machine, forever.
The fix
The guard now exercises the cache instead of inspecting it:
If it fails, the cache is deleted and rebuilt from scratch rather than built on top of a partial tree, and the loud-failure path now says a working bootstrap could not be produced.
Result
No assertion changed and no script under test changed — only the harness.
Why it matters
These are the tests covering
compute-min-safe-constraints.phpandis-still-vulnerable.php— the code that decides which version the vuln scanner bumps you to, and whether a "fix" actually leaves the affected range. Half the suite being red meant a regression there would not have been caught.This is the second bug of this class in the same helper; the first was
ensure_semver_vendorshelling out to the fakecomposershim (#41).🤖 Generated with Claude Code