Skip to content

fix(ci): install npm dependencies before check-affected runs suites - #9682

Merged
kyle-sexton merged 4 commits into
mainfrom
fix/9122-check-affected-npm-deps
Oct 24, 2026
Merged

kyle-sexton merged 4 commits into
mainfrom
fix/9122-check-affected-npm-deps

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Closes #9122

Summary

A fresh worktree's first scripts/check-affected.sh --tests run failed on missing npm packages (htmlhint at the root, yaml under .github/standards/runner-policy), not on the change, so each fresh worktree lost a verify cycle. That happened at least eight times across 2026-10-22 to 2026-10-24.

Fix

  • scripts/setup-env.sh gets --node, which runs only its Node step: npm ci in the root and runner-policy trees when the package-lock.json hash stamp is missing or stale. That step is now a function the full run also calls, with nice and quiet npm flags.
  • scripts/check-affected.sh --tests calls bash scripts/setup-env.sh --node once before the suites. A failed install fails the run naming that command and skips the suites; one that could not run (npm or nice missing, exit 127 or 2) is a SKIP and the suites still run, per the script's could-not-run contract. A tree with a current stamp installs nothing. A tree installed by plain npm ci has no stamp and reinstalls once; no CI job runs check-affected --tests or setup-env --node today.
  • One install path instead of two, and it also catches a stale install after a lockfile change.

Verification

  • bash scripts/check-affected.test.sh: 54 passed, 0 failed. npm is stubbed, and the cases cover missing, current, stale lockfile, failed install, and setup-env that could not run (that case fails without the fix).
  • node --test scripts/setup-env.test.mjs: 17 passed. The 4 new or changed cases fail against main's setup-env.sh.
  • A real check-affected.sh --tests in the fresh worktree installed both trees and passed (10 passed, 4 skipped, 56 s with the install); a second run installed nothing. shellcheck is clean.
  • Left out: scripts/setup-env.test.mjs keeps its existing space indentation, which Biome would rewrite throughout; that is unrelated to this change.

Related

  • Also affects the full setup-env.sh run used by the pr-run-activity-read/write workflows: same installs, plus quiet flags and one "installed" log line per tree.

🤖 Generated with Claude Code

kyle-sexton and others added 4 commits October 24, 2026 12:18
…suites

scripts/check-affected.sh --tests now runs npm ci at the root and in
.github/standards/runner-policy when that tree has a package.json and no
node_modules, so a fresh worktree's first verify run passes. A failed
install fails the run with the command named. CI lanes run npm ci first,
so there node_modules exists and nothing installs.

Fixes #9122

Co-Authored-By: Claude Opus 5.5 <[email protected]>
check-affected.sh --tests now calls scripts/setup-env.sh --node instead
of its own npm ci loop, so the lockfile-hash stamp also reinstalls a
stale node_modules after a lockfile change. --node runs only setup-env's
Node step, which now runs npm ci under nice with --no-audit --no-fund and
names each install. A failed run fails check-affected with that command
named and runs no suite.

Refs #9122

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n suites

A missing npm or nice (exit 127 or 2) is a tool that could not run, which
check-affected's contract makes a SKIP, not a failure.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review October 24, 2026 16:35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T16:37:29.298567Z f8e76bd Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed f8e76bdfd68da49bd7378758165a2136bde7f49b: 0 finding(s), 0 as inline comments.

No findings. I read the full diff and the PR context, and checked the changed code against the surrounding scripts/check-affected.sh and scripts/setup-env.sh. I did not run anything. The PR's test counts are author-claimed and unverified by me.

  • Exit handling: check-affected.sh runs without set -e (set -uo pipefail, line 75), so the grep '^setup-env: installed' on an all-current install returns 1 and does nothing. A non-zero exit from setup-env.sh --node is captured through || rc=$?.
  • Failure paths: exit 2 or 127 becomes a SKIP and the suites still run, matching run_check's contract. Any other exit fails the run with FAIL npm-deps ... Reproduce: bash scripts/setup-env.sh --node and skips the suites. The failed and skipped arrays and the $out.failures file are the ones run_check already uses.
  • setup-env.sh --node: the Node step is now a function the full run also calls. --node runs it and exits before the Python and ShellCheck steps. cd "$root" happens before the function runs, so the relative dir paths resolve correctly. The help sed -n '2,20p' range matches the new header length.
  • Tests: check-affected.test.sh covers setup-env failure, could-not-run, a missing install, a current install, a stale lockfile and a failed npm ci. setup-env.test.mjs updates the npm stub to take the last argument as the prefix, which fits the new flags.
  • Closing issue check-affected: a fresh worktree's first verify run fails on missing npm dependencies #9122: it asks that check-affected.sh either install what the suites need or stop early. The change installs first and fails fast on an install error, and tests exercise both paths, so the criterion is met and covered.

Design note, not a finding: the install runs before test selection, so a fresh worktree pays for npm ci even when the selected suites need no npm packages. The PR documents this trade-off.

No hold class applies. No trusted-actor, CODEOWNERS or .gitmodules files changed, no model or API spend was added, and no plugin manifests changed.

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed f8e76bdfd68da49bd7378758165a2136bde7f49b: 0 finding(s), 0 as inline comments.

I found no security issues in this pull request.

The diff has four files: scripts/check-affected.sh, scripts/check-affected.test.sh, scripts/setup-env.sh and scripts/setup-env.test.mjs. It adds a --node mode to setup-env.sh, which runs npm ci in the root and runner-policy trees. check-affected.sh --tests now calls that mode before it runs the suites.

  • Trust boundary: npm ci can run lifecycle scripts from the checked tree's lockfile. The foreign-tree path skips --tests entirely ("runs the checked tree's own test code"), so the install only runs on the operator's own tree. The suites already execute that tree's code, so this adds no new exposure.
  • Injection: setup-env.sh runs npm ci with only fixed directory names and quoted variables. check-affected.sh runs "$tools/scripts/setup-env.sh" from a path it resolves itself. No user-controlled input reaches a command line.
  • Plugin manifests and instruction surfaces: the diff changes no plugin.json, marketplace.json, CLAUDE.md, rules, skill or hook files, and it removes no guardrail.
  • Trust-gate paths: the diff touches none of them.
  • PR context: it holds no embedded directives.

critical-findings: 0

@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 24, 2026
Merged via the queue into main with commit fe63973 Oct 24, 2026
81 of 94 checks passed
@kyle-sexton
kyle-sexton deleted the fix/9122-check-affected-npm-deps branch October 24, 2026 17:09
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.

check-affected: a fresh worktree's first verify run fails on missing npm dependencies

1 participant