Skip to content

Commit 10f2e64

Browse files
robgilbreathclaude
andauthored
ci: pin actions to v7, Dependabot for actions, vendor shared-actions v2 composites, [email protected] in publish; release 1.1.1 (#51)
* chore: pin actions/checkout and actions/setup-node to v7 One major per action across the org. Closes #49. Part of pncit/.github#15. * chore: watch workflow action refs with Dependabot, grouped Dependabot only tracks major tags for actions, so this is a few PRs a year; grouped so a repo gets one PR per round. Keeps the v7 pin from drifting and is the only thing in the org that would report a pncit/shared-actions major bump. Part of pncit/.github#15. * fix: quote the dependabot group glob * chore: render the org-standard dependabot.yml Generated by pncit/.github rollout/render-dependabot.py from what this repo contains (datto-rmm-api-client: written (npm actions)). Values are the org standard, not tuned here: weekly, limit 5 (3 for actions), @pncit/* in their own PR, other minor/patch collapsed, majors individual, security advisories batched. Drift is caught by rollout/audit-dependabot.sh. Part of pncit/.github#15. * ci: vendor shared-actions v2 composites, pin [email protected] in publish; release 1.1.1 - .github/actions/{validate-codebase,verify-node-toolchain,verify-version-bump} copied byte-for-byte from pncit/shared-actions v2 (59e838b); README documents the mirror. Public repo, so it can't uses: the private repo directly. - validate.yml: library shape (verify-node-toolchain -> verify-version-bump -> validate-codebase -> test:repro) replacing the inline bash gate and inline npm steps. Dependabot stays exempt from the bump gate (action default). - npm-publish.yml: validate job uses the vendored validate-codebase; npm pinned to 12.0.2 (folds in #50 — npm/cli#9722 was fixed in 12.0.1). - 1.1.0 -> 1.1.1 so this PR passes the gate; merge publishes via OIDC. Co-Authored-By: Claude Code <[email protected]> * ci: redirect validate-codebase's nested verify-node-toolchain ref to the local copy Actions resolves nested `uses:` at prepare time even when the step's `if:` is false, so the upstream pncit/shared-actions@main ref fails in a public repo ("Unable to resolve action"). This is the one documented deviation from the byte-for-byte mirror. Co-Authored-By: Claude Code <[email protected]> --------- Co-authored-by: Claude Code <[email protected]>
1 parent ee59ab4 commit 10f2e64

9 files changed

Lines changed: 490 additions & 111 deletions

File tree

‎.github/actions/README.md‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Local composite actions
2+
3+
These are **local mirrors** (vendored copies) of composite actions from the
4+
private [`pncit/shared-actions`](https://github.com/pncit/shared-actions) repo,
5+
currently at `v2` (`59e838b`).
6+
7+
## Why they're copied here
8+
9+
`datto-rmm-api-client` is a **public** repository. GitHub does not allow a public
10+
repo to reference actions that live in a **private** repo, so it cannot `uses:`
11+
`pncit/shared-actions/...` directly (the workflow fails with
12+
`Unable to resolve action pncit/shared-actions, not found`). Copying the
13+
actions into this repo under `.github/actions/` sidesteps that — a repo-local
14+
action (`uses: ./.github/actions/<name>`) has no visibility restriction.
15+
16+
This is the org standard for public repos; the sibling public repos
17+
[`pncit/timezest`](https://github.com/pncit/timezest) and
18+
[`pncit/node-quickbooks`](https://github.com/pncit/node-quickbooks)
19+
carry the same copies — keep them in step.
20+
21+
## Keeping them in sync (manual)
22+
23+
When an action changes in `pncit/shared-actions`, re-copy it here verbatim and
24+
update the tag/sha above. The copies are intentionally byte-for-byte identical
25+
to upstream (apart from the header comment) so a sync is a trivial file diff —
26+
do **not** locally "optimize" inputs or steps; consistency with upstream is the
27+
point.
28+
29+
**One deliberate deviation:** `validate-codebase` upstream contains a nested
30+
`uses: pncit/shared-actions/.github/actions/verify-node-toolchain@main`. Actions
31+
resolves every nested `uses:` when the step is prepared, even when its `if:` is
32+
false, so the private ref fails here with `Unable to resolve action`. The
33+
vendored copy points that line at `./.github/actions/verify-node-toolchain`
34+
instead. Keep that redirect when re-copying.
35+
36+
| local action | upstream |
37+
|---|---|
38+
| `validate-codebase/action.yml` | `pncit/shared-actions/.github/actions/validate-codebase` |
39+
| `verify-node-toolchain/action.yml` | `pncit/shared-actions/.github/actions/verify-node-toolchain` |
40+
| `verify-version-bump/action.yml` | `pncit/shared-actions/.github/actions/verify-version-bump` |
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
name: 'Validate codebase'
2+
description: >-
3+
Run the standard npm CI gates against the calling repo: `npm ci`,
4+
then `npm run lint`, `npm run typecheck`, `npm test`. Each is
5+
expected to be defined as a script in the repo's package.json (or to
6+
fan out via npm workspaces to per-workspace scripts).
7+
8+
# This composite is the "does the codebase pass the org-standard
9+
# checks?" assertion. It's one of three validate-* actions:
10+
#
11+
# validate-containers-spec static check of the deploy `containers` JSON
12+
# validate-codebase (this) lint + typecheck + test against the repo
13+
# validate-build docker build of every container that declares build:
14+
#
15+
# Each is invocable independently; callers pick the subset that
16+
# matches what their workflow needs to check.
17+
#
18+
# Does its own checkout + setup-node so it's self-contained — invoke
19+
# directly from a job's `steps:` with just `uses:` and the npm-token.
20+
21+
# Vendored from pncit/shared-actions@v2 (59e838b) because this repo is PUBLIC
22+
# and shared-actions is PRIVATE — a public repo can't `uses:` a private
23+
# action. Byte-for-byte identical to upstream apart from this comment and the
24+
# nested verify-node-toolchain `uses:` (redirected to the local copy);
25+
# re-copy when upstream changes (see .github/actions/README.md).
26+
27+
inputs:
28+
npm-token:
29+
description: 'npm token used for `npm ci` (NODE_AUTH_TOKEN in the install step).'
30+
required: true
31+
npm-scope:
32+
description: 'npm scope (for private packages).'
33+
required: false
34+
default: '@pncit'
35+
registry-url:
36+
description: 'npm registry URL.'
37+
required: false
38+
default: 'https://registry.npmjs.org'
39+
40+
npm-version:
41+
description: >-
42+
Exact npm version to pin after setup-node, e.g. "12.0.2". `.nvmrc`
43+
pins a Node *major*, so setup-node resolves to whatever 24.x is
44+
newest on the day — which is how npm crossed the 11 -> 12 boundary
45+
(and started blocking unapproved install scripts) with nothing
46+
committed on either side. Pinning here makes that upgrade a
47+
deliberate, reviewed edit to one default instead of a surprise.
48+
Set to the empty string to opt out and take the bundled npm.
49+
required: false
50+
default: '12.0.2'
51+
node-major-version:
52+
description: >-
53+
Optional. Required Node major, e.g. "24" — typically
54+
vars.NODE_MAJOR_VERSION. When this and npm-major-version are both
55+
set, verify-node-toolchain runs *after* setup-node, so it measures
56+
the toolchain that actually runs `npm ci`. Callers that invoke
57+
verify-node-toolchain as a top-level step are measuring the
58+
runner's system Node/npm, which is not what this action uses.
59+
required: false
60+
default: ''
61+
npm-major-version:
62+
description: 'Optional. Required npm major, e.g. "12". See node-major-version.'
63+
required: false
64+
default: ''
65+
66+
runs:
67+
using: composite
68+
steps:
69+
- name: Checkout
70+
uses: actions/checkout@v7
71+
72+
- name: Setup Node
73+
uses: actions/setup-node@v7
74+
with:
75+
node-version-file: .nvmrc
76+
cache: npm
77+
registry-url: ${{ inputs.registry-url }}
78+
scope: ${{ inputs.npm-scope }}
79+
# actions/setup-node@v6 dropped `always-auth: true` — it was a
80+
# v4-era flag and is no longer needed. Specifying it produced an
81+
# "Unexpected input" warning during the first real deploy run.
82+
83+
# Pin npm before anything reads it. setup-node gives us whatever npm
84+
# its Node bundles; this makes the version an explicit, reviewable
85+
# input instead of a moving target.
86+
- name: Pin npm
87+
if: inputs.npm-version != ''
88+
shell: bash
89+
run: |
90+
npm i -g "npm@${NPM_VERSION}"
91+
echo "npm pinned to $(npm --version) ($(command -v npm))"
92+
env:
93+
NPM_VERSION: ${{ inputs.npm-version }}
94+
95+
# Runs here, after Setup Node and the pin, so it asserts against the
96+
# toolchain `npm ci` will actually use.
97+
- name: Verify Node toolchain
98+
if: inputs.node-major-version != '' && inputs.npm-major-version != ''
99+
uses: ./.github/actions/verify-node-toolchain
100+
with:
101+
node-major-version: ${{ inputs.node-major-version }}
102+
npm-major-version: ${{ inputs.npm-major-version }}
103+
104+
- name: Install dependencies
105+
shell: bash
106+
env:
107+
NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
108+
run: npm ci 2>&1 | tee "${RUNNER_TEMP}/npm-ci.log"
109+
110+
# npm 11.16.0 added per-package install-script allowlists (the
111+
# `allowScripts` field in package.json). npm 11 warns and still runs
112+
# them; npm 12 blocks them -- and `npm ci` exits 0 either way, so a
113+
# native module can silently never build. That is what took
114+
# documentation-server's whole suite down with 262 "Could not locate
115+
# the bindings file" errors against a green `npm ci`.
116+
#
117+
# Both the warn-phase and block-phase messages contain the literal
118+
# string `allowScripts`, so matching that catches the block and also
119+
# gives early warning on a runner still effectively on npm 11.
120+
#
121+
# Warning, not error, on purpose: most pncit repos have no
122+
# `allowScripts` field yet, and failing here would red them all at
123+
# once. Flip to ::error:: once the org-wide rollout lands.
124+
- name: Audit skipped install scripts
125+
shell: bash
126+
run: |
127+
if grep -q 'allowScripts' "${RUNNER_TEMP}/npm-ci.log"; then
128+
grep 'allowScripts' "${RUNNER_TEMP}/npm-ci.log" >&2
129+
echo "::warning::npm flagged or skipped one or more install scripts. If any is a native module, it did not build and the install still reported success. Approve with: npx npm@${NPM_VERSION:-12} install-scripts approve <pkg>, then commit the package.json allowScripts change."
130+
fi
131+
env:
132+
NPM_VERSION: ${{ inputs.npm-version }}
133+
134+
- name: Lint
135+
shell: bash
136+
run: npm run lint
137+
138+
- name: Typecheck
139+
shell: bash
140+
run: npm run typecheck
141+
142+
- name: Test
143+
shell: bash
144+
run: npm test
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: 'Verify Node toolchain'
2+
description: >-
3+
Fail-fast check that `node` and `npm` on the runner match the major
4+
versions the repo expects. Catches the case where actions/setup-node
5+
silently falls back to whatever's installed on a self-hosted runner
6+
(e.g. the tool cache miss path), which would otherwise let a stale
7+
Node version reach `npm ci` and resolve nested optional deps
8+
differently from the committed lockfile.
9+
10+
# Standalone use: add to any workflow that calls actions/setup-node:
11+
#
12+
# - uses: actions/setup-node@v7
13+
# with:
14+
# node-version-file: .nvmrc
15+
# - uses: pncit/shared-actions/.github/actions/verify-node-toolchain@v1
16+
# with:
17+
# node-major-version: ${{ vars.NODE_MAJOR_VERSION }}
18+
# npm-major-version: ${{ vars.NPM_MAJOR_VERSION }}
19+
#
20+
# `validate-codebase` calls this internally, but only when it is given
21+
# both node-major-version and npm-major-version; it runs there *after*
22+
# that action's own setup-node, so it measures the toolchain that will
23+
# actually run `npm ci`.
24+
#
25+
# Invoking it as a top-level workflow step instead measures the runner's
26+
# *system* node/npm, which is not what a composite doing its own
27+
# setup-node will use. That gap is why an npm 11 -> 12 upgrade slipped
28+
# past this gate: it reported npm 11.11.0 from /usr/bin/npm while
29+
# `npm ci` ran under npm 12 from the tool cache. Prefer passing the
30+
# versions through to `validate-codebase`.
31+
32+
# Vendored from pncit/shared-actions@v2 (59e838b) because this repo is PUBLIC
33+
# and shared-actions is PRIVATE — a public repo can't `uses:` a private
34+
# action. Byte-for-byte identical to upstream apart from this comment;
35+
# re-copy when upstream changes (see .github/actions/README.md).
36+
37+
inputs:
38+
node-major-version:
39+
description: 'Required Node major version, e.g. "24". Typically sourced from vars.NODE_MAJOR_VERSION.'
40+
required: true
41+
npm-major-version:
42+
description: 'Required npm major version, e.g. "11". Typically sourced from vars.NPM_MAJOR_VERSION.'
43+
required: true
44+
45+
runs:
46+
using: composite
47+
steps:
48+
- name: Verify Node and npm match expected major versions
49+
shell: bash
50+
env:
51+
NODE_MAJOR_VERSION: ${{ inputs.node-major-version }}
52+
NPM_MAJOR_VERSION: ${{ inputs.npm-major-version }}
53+
run: |
54+
if [[ -z "$NODE_MAJOR_VERSION" || -z "$NPM_MAJOR_VERSION" ]]; then
55+
echo "::error::node-major-version and npm-major-version inputs must both be set."
56+
exit 1
57+
fi
58+
NODE_VERSION=$(node --version)
59+
NPM_VERSION=$(npm --version)
60+
echo "node: $NODE_VERSION ($(which node))"
61+
echo "npm: $NPM_VERSION ($(which npm))"
62+
if [[ ! "$NODE_VERSION" =~ ^v${NODE_MAJOR_VERSION}\. ]]; then
63+
echo "::error::Expected Node ${NODE_MAJOR_VERSION}.x, got $NODE_VERSION."
64+
echo "::error::The runner is falling back to system Node — install Node ${NODE_MAJOR_VERSION} on the runner or fix actions/setup-node."
65+
exit 1
66+
fi
67+
if [[ ! "$NPM_VERSION" =~ ^${NPM_MAJOR_VERSION}\. ]]; then
68+
echo "::error::Expected npm ${NPM_MAJOR_VERSION}.x, got $NPM_VERSION."
69+
echo "::error::npm version mismatch resolves nested optional deps differently and breaks npm ci against the committed lockfile."
70+
exit 1
71+
fi

0 commit comments

Comments
 (0)