Skip to content

Commit 48b1e35

Browse files
trek-eclaudeCI Rebase Check
authored
fix(#431): enforce H1 shell policy (linux=bash, macOS=zsh, windows=pwsh) across PR + release gates (#434)
* test(#431): policy-shell-pinning linter — RED baseline (37 violations on origin/next) Adds scripts/workflow-policy.cjs: H1 shell-policy linter with POLICY map, VIOLATION enum, matrix expansion, effective-shell resolution order, and runPolicyLint({ workflowsDir }) entry point. Adds tests/policy-shell-pinning.test.cjs: 8 tests (baseline + 6 synthetic counter-tests). Synthetic tests 2–7 pass; baseline test is intentionally RED (37 violations: 28 in test.yml, 9 in install-smoke.yml — all macos/windows lanes using shell: bash instead of native zsh/pwsh). Adds js-yaml@4.1.1 as devDependency for YAML parsing. * fix(#431): switch ubuntu/windows lanes to native shells; extract bash-isms to Node Remove all explicit shell: bash pins from ubuntu-only jobs (changes, lint-tests, coverage, required-tests, smoke-unpacked) — ubuntu runner default is bash, which is both H1-compliant and the runner default, making the pin redundant. For the test and test-full mixed-OS jobs (ubuntu+windows, windows+macos): - Move bash-ism steps to shell-agnostic Node scripts: scripts/ci-guard-runner.cjs — RUNNER_ENVIRONMENT check scripts/ci-rebase-check.cjs — git fetch+merge PR base branch scripts/check-npm-integrity.cjs — Node port of check-npm-integrity.sh scripts/ci-prepare-test-scope.cjs — write .ci-selected-tests.txt scripts/ci-smoke-skip.cjs — set skip= output for full-only matrix entries - Remove shell: bash from simple npm/node command steps (runner default applies) This brings Windows violations from 19 to 0. Remaining 17 violations are all MACOS_MISSING_EXPLICIT_ZSH in mixed-OS matrix jobs (test-full: windows+macos, install-smoke smoke: ubuntu+macos) — these require job splitting to fix; see BLOCKER in PR description. * fix(#431): update workflow-shell-pinning test for H1 policy The old test required all Windows-targeting npm steps to pin shell: bash (to prevent pwsh stderr-swallow). Under H1, Windows runners must use pwsh (native, no pin needed) — shell: bash on Windows is now the violation, not the fix. Update findViolations() to flag npm steps with effectiveShell === 'bash' (rather than effectiveShell === null). Update synthetic tests to verify the H1-inverted semantics: defaults.run.shell: bash on Windows is now 2 violations, not 0. Update test name and assertion messages to describe the H1 constraint rather than the old missing-pin constraint. * fix(#431): extend policy linter to resolve matrix.shell expressions - expandRunsOn now captures all matrix.include row keys as realization context (os, node-version, shell, full_only, etc.) instead of only os - effectiveShell now accepts a realizationContext and resolves ${{ matrix.<key> }} expressions against it before checking policy - Unresolvable matrix key in shell expression emits UNRESOLVABLE_MATRIX - Add 3 new tests: positive (zsh+pwsh per row → 0 violations), counter (bash in macOS row → WRONG_SHELL_FOR_OS), counter (missing shell key → UNRESOLVABLE_MATRIX) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(#431): apply matrix.shell pattern to test-full and smoke jobs (clears BLOCKER) test-full job (test.yml): - Add shell: pwsh/zsh per matrix.include row (windows-latest→pwsh, macos-latest→zsh) - Add job-level defaults.run.shell: ${{ matrix.shell }} - No step-level shell pins existed to remove smoke job (install-smoke.yml): - Add shell: bash/zsh per matrix.include row (ubuntu→bash, macos→zsh) - Add job-level defaults.run.shell: ${{ matrix.shell }} - No step-level shell pins existed to remove Policy linter now reports 0 violations across all workflow files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(#431): migrate .sh check scripts to .cjs; remove .sh originals - Add scripts/check-env.cjs: Node.js port of check-env.sh with identical exit codes (0/1/2), human-readable and --json output, --help flag, and all 5 checks (node-version, npm-version, lockfile-present, lockfile-sync, version-manager-pin) - Migrate all callers: - package.json check:env → node scripts/check-env.cjs - package.json check:integrity → node scripts/check-npm-integrity.cjs - scripts/ci-test-scope.cjs path strings → .cjs equivalents - .github/workflows/release.yml rc+finalize jobs → node .cjs (drop chmod+x) - .github/workflows/security-scan.yml → node .cjs (drop chmod+x) - tests/check-env.test.cjs → spawn node process.execPath [.cjs] - tests/npm-integrity-gate.test.cjs → spawn node process.execPath [.cjs] - Delete scripts/check-env.sh and scripts/check-npm-integrity.sh Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(#431): update doc references from .sh to .cjs Update SECURITY.md and docs/contributing/bootstrap.md to reference the canonical Node invocation instead of the removed bash scripts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(#431): use per-step shell:matrix.shell instead of defaults.run.shell (GHA compat) GHA does not reliably resolve matrix expressions inside defaults.run.shell. Per-step shell: always resolves correctly. Removed the defaults.run.shell block from the test-full job (test.yml) and the smoke job (install-smoke.yml), and added shell: \${{ matrix.shell }} directly on every run: step in both jobs. Codex finding: defaults.run.shell with matrix expressions is not a GHA-supported pattern; per-step shell: is the safe form. * fix(#431): policy linter validates every matrix.include row independently Removed runner-label-only dedup from expandRunsOn() in workflow-policy.cjs. The prior guard (if !realizations.find(r => r.runner === runner)) collapsed two macos-latest rows with different node-version/shell contexts into one, hiding the second row's policy violation. Each matrix.include row is a distinct CI realization with its own context; validating it twice is harmless but skipping it causes false negatives. Added counter-test (Test 8) in tests/policy-shell-pinning.test.cjs: two macos-latest rows (shell:zsh compliant + shell:bash violation) must produce exactly one WRONG_SHELL_FOR_OS violation on the second row. * fix(#431): remove dedup-by-runner in Cartesian matrix.<key> expansion (Codex round 3) The base-list path in expandRunsOn (matrix.<key> arrays, e.g. matrix.os) previously guarded each push with `if (!realizations.find(r => r.runner === runner))`, collapsing duplicate runner values into a single realization and hiding policy violations on later rows of a Cartesian matrix. Remove the guard unconditionally; each entry in the base-list array now produces its own realization, matching the same fix already applied to the matrix.include path. Add counter-test "Cartesian matrix os × shell — dedup must not collapse rows by runner alone": matrix.os: [macos-latest, macos-latest] + shell: ${{ matrix.shell }} now yields 2 realizations (not 1). Documents that Cartesian cross-product expansion (carrying all keys into realization context) is a separate follow-up; current violations are UNRESOLVABLE_MATRIX pending that work. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(#431): remove 60s timeout regression on npm ci --dry-run (parity with check-env.sh) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(#431): ci-rebase-check.cjs — return truthy sentinel on success (Codex round 4) run() used execFileSync with stdio:'inherit', which returns null on success. Caller checked `result !== null`, always false → every successful fetch fell through to "failed after 3 attempts" exit-1 path. Fix: run() now returns true on success, false on failure. Update caller from `result !== null` to `if (result)`. Adds tests/ci-rebase-check.test.cjs (5 tests) covering the sentinel contract and a local-bare-remote integration smoke that verifies the full fetch+merge path exits 0 when fetch succeeds. --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: CI Rebase Check <ci@gsd-redux>
1 parent a5eceb1 commit 48b1e35

23 files changed

Lines changed: 2060 additions & 955 deletions

.github/workflows/install-smoke.yml

Lines changed: 15 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,24 @@ jobs:
6464
- os: ubuntu-latest
6565
node-version: 22
6666
full_only: false
67+
shell: bash
6768
- os: ubuntu-latest
6869
node-version: 24
6970
full_only: true
71+
shell: bash
7072
- os: macos-latest
7173
node-version: 24
7274
full_only: true
75+
shell: zsh
7376

7477
steps:
7578
- name: Skip full-only matrix entry on PR
7679
id: skip
77-
shell: bash
7880
env:
7981
EVENT: ${{ github.event_name }}
8082
FULL_ONLY: ${{ matrix.full_only }}
81-
run: |
82-
if [ "$EVENT" = "pull_request" ] && [ "$FULL_ONLY" = "true" ]; then
83-
echo "skip=true" >> "$GITHUB_OUTPUT"
84-
else
85-
echo "skip=false" >> "$GITHUB_OUTPUT"
86-
fi
83+
shell: ${{ matrix.shell }}
84+
run: node scripts/ci-smoke-skip.cjs
8785

8886
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
8987
if: steps.skip.outputs.skip != 'true'
@@ -102,20 +100,8 @@ jobs:
102100
# instead of a downstream build error that looks unrelated.
103101
- name: Rebase check — merge PR base branch into PR head
104102
if: steps.skip.outputs.skip != 'true' && github.event_name == 'pull_request'
105-
shell: bash
106-
run: |
107-
set -euo pipefail
108-
git config user.email "ci@gsd-redux"
109-
git config user.name "CI Rebase Check"
110-
BASE_BRANCH="${GITHUB_BASE_REF:-main}"
111-
git fetch origin "$BASE_BRANCH"
112-
if ! git merge --no-edit --no-ff "origin/$BASE_BRANCH"; then
113-
echo "::error::This PR cannot cleanly merge origin/$BASE_BRANCH. Rebase your branch onto current $BASE_BRANCH and push again."
114-
echo "::error::Conflicting files:"
115-
git diff --name-only --diff-filter=U
116-
git merge --abort
117-
exit 1
118-
fi
103+
shell: ${{ matrix.shell }}
104+
run: node scripts/ci-rebase-check.cjs
119105

120106
- name: Set up Node.js ${{ matrix.node-version }}
121107
if: steps.skip.outputs.skip != 'true'
@@ -126,12 +112,13 @@ jobs:
126112

127113
- name: Install root deps
128114
if: steps.skip.outputs.skip != 'true'
115+
shell: ${{ matrix.shell }}
129116
run: npm ci
130117

131118
- name: Pack root tarball
132119
if: steps.skip.outputs.skip != 'true'
133120
id: pack
134-
shell: bash
121+
shell: ${{ matrix.shell }}
135122
run: |
136123
set -euo pipefail
137124
TARBALL=$(npm pack --silent)
@@ -141,18 +128,18 @@ jobs:
141128
142129
- name: Ensure npm global bin is on PATH (CI runner default may differ)
143130
if: steps.skip.outputs.skip != 'true'
144-
shell: bash
131+
shell: ${{ matrix.shell }}
145132
run: |
146133
NPM_BIN="$(npm config get prefix)/bin"
147134
echo "$NPM_BIN" >> "$GITHUB_PATH"
148135
echo "npm global bin: $NPM_BIN"
149136
150137
- name: Install tarball globally
151138
if: steps.skip.outputs.skip != 'true'
152-
shell: bash
153139
env:
154140
TARBALL: ${{ steps.pack.outputs.tarball }}
155141
WORKSPACE: ${{ github.workspace }}
142+
shell: ${{ matrix.shell }}
156143
run: |
157144
set -euo pipefail
158145
TMPDIR_ROOT=$(mktemp -d)
@@ -170,7 +157,7 @@ jobs:
170157
171158
- name: Assert gsd-tools resolves on PATH
172159
if: steps.skip.outputs.skip != 'true'
173-
shell: bash
160+
shell: ${{ matrix.shell }}
174161
run: |
175162
set -euo pipefail
176163
if ! command -v gsd-tools >/dev/null 2>&1; then
@@ -184,7 +171,7 @@ jobs:
184171
185172
- name: Assert gsd-tools is executable
186173
if: steps.skip.outputs.skip != 'true'
187-
shell: bash
174+
shell: ${{ matrix.shell }}
188175
run: |
189176
set -euo pipefail
190177
gsd-tools --help
@@ -193,7 +180,7 @@ jobs:
193180
- name: Lifecycle smoke
194181
if: steps.skip.outputs.skip != 'true'
195182
id: lifecycle-smoke
196-
shell: bash
183+
shell: ${{ matrix.shell }}
197184
run: |
198185
set -euo pipefail
199186
node scripts/release-tarball-smoke.cjs --json | tee /tmp/release-smoke.json
@@ -226,20 +213,7 @@ jobs:
226213
# latest target.
227214
- name: Rebase check — merge PR base branch into PR head
228215
if: github.event_name == 'pull_request'
229-
shell: bash
230-
run: |
231-
set -euo pipefail
232-
git config user.email "ci@gsd-redux"
233-
git config user.name "CI Rebase Check"
234-
BASE_BRANCH="${GITHUB_BASE_REF:-main}"
235-
git fetch origin "$BASE_BRANCH"
236-
if ! git merge --no-edit --no-ff "origin/$BASE_BRANCH"; then
237-
echo "::error::This PR cannot cleanly merge origin/$BASE_BRANCH. Rebase your branch onto current $BASE_BRANCH and push again."
238-
echo "::error::Conflicting files:"
239-
git diff --name-only --diff-filter=U
240-
git merge --abort
241-
exit 1
242-
fi
216+
run: node scripts/ci-rebase-check.cjs
243217

244218
- name: Set up Node.js 22
245219
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
@@ -251,14 +225,12 @@ jobs:
251225
run: npm ci
252226

253227
- name: Ensure npm global bin is on PATH
254-
shell: bash
255228
run: |
256229
NPM_BIN="$(npm config get prefix)/bin"
257230
echo "$NPM_BIN" >> "$GITHUB_PATH"
258231
echo "npm global bin: $NPM_BIN"
259232
260233
- name: Install from unpacked directory (no npm pack)
261-
shell: bash
262234
run: |
263235
set -euo pipefail
264236
TMPDIR_ROOT=$(mktemp -d)
@@ -268,7 +240,6 @@ jobs:
268240
get-shit-done-redux --claude --local || true
269241
270242
- name: Assert gsd-tools resolves on PATH after unpacked install
271-
shell: bash
272243
run: |
273244
set -euo pipefail
274245
if ! command -v gsd-tools >/dev/null 2>&1; then
@@ -280,7 +251,6 @@ jobs:
280251
echo "✓ gsd-tools resolves at: $(command -v gsd-tools)"
281252
282253
- name: Assert gsd-tools is executable after unpacked install
283-
shell: bash
284254
run: |
285255
set -euo pipefail
286256
gsd-tools --help

.github/workflows/release.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ jobs:
189189
- name: Install and test
190190
run: |
191191
npm ci
192-
chmod +x scripts/check-npm-integrity.sh
193-
scripts/check-npm-integrity.sh
192+
node scripts/check-npm-integrity.cjs
194193
npm run test:coverage:unit
195194
196195
- name: Commit pre-release version bump
@@ -321,8 +320,7 @@ jobs:
321320
NODE_OPTIONS: --max-old-space-size=6144
322321
run: |
323322
npm ci
324-
chmod +x scripts/check-npm-integrity.sh
325-
scripts/check-npm-integrity.sh
323+
node scripts/check-npm-integrity.cjs
326324
npm run test:coverage:unit
327325
328326
# npm bundled with Node 24 (pinned via setup-node) already supports trusted publishing (#318)

.github/workflows/security-scan.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ jobs:
4343
run: npm ci
4444

4545
- name: Dependency integrity gate
46-
run: |
47-
chmod +x scripts/check-npm-integrity.sh
48-
scripts/check-npm-integrity.sh
46+
run: node scripts/check-npm-integrity.cjs
4947

5048
- name: Prompt injection scan
5149
env:

0 commit comments

Comments
 (0)