Skip to content

perf(setup): disable npm audit and fund in CI - #53

Merged
oxyc merged 2 commits into
masterfrom
perf/npm-no-audit
Jul 30, 2026
Merged

perf(setup): disable npm audit and fund in CI#53
oxyc merged 2 commits into
masterfrom
perf/npm-no-audit

Conversation

@oxyc

@oxyc oxyc commented Jul 30, 2026

Copy link
Copy Markdown
Member

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.

The evidence

Across the three most expensive repos, all with node_modules restored:

repo npm install warm webpack build
snellmanrecipes up to date, audited 1716 packages in 48s ~3s
beamex up to date, audited 1880 packages in 60s ~19s
kaskipuu up to date, audited 1930 packages in 1m 4 builds

snellmanrecipes' warm build is ~3s — the same as suomentyokalu's. It looked slower than the others purely because of this.

Measured end to end

Verified on snellmanrecipes by pinning both the caller and the internal setup@ ref at this branch, with node_modules warm in both runs:

npm install Install development packages job total
audit on (30557421507) 48s 72s 126s
audit off (30564858816) 4s — npm now just prints "up to date" 23s 81s

Against that repo's original 261s, this and the webpack filesystem cache together are −69%.

Why npm config rather than CLI flags

These installs happen inside projects' own composer build scripts (npm install && npm run build:production). Passing --no-audit would mean editing 19 composer.json files; setting it as npm config covers every invocation on the runner, so beamex and kaskipuu get ~60s back without any per-repo change.

Is dropping the audit safe

Yes. Dependency vulnerabilities are covered by the nightly vulnerability scan, which actually gates and opens PRs. npm's install-time audit summary gates nothing — it prints, and the build continues either way. npm audit remains available on demand.

🤖 Generated with Claude Code

test and others added 2 commits July 30, 2026 14:05
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>
@oxyc
oxyc merged commit b5c4901 into master Jul 30, 2026
@oxyc
oxyc deleted the perf/npm-no-audit branch July 30, 2026 17:25
oxyc pushed a commit that referenced this pull request Jul 30, 2026
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>
oxyc pushed a commit that referenced this pull request Jul 30, 2026
…he-integrity

* origin/master:
  perf(setup): disable npm audit and fund in CI (#53)
oxyc added a commit that referenced this pull request Jul 30, 2026
* perf(setup): disable npm audit and fund in CI

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>

* fix(tests): verify the semver cache works, not just that it exists

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>

* fix(ci): restore setup@v1 — the temporary ref belonged to #53

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>

---------

Co-authored-by: test <test@example.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: genero-bot <dev@genero.fi>
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