Skip to content

Commit eafd1f0

Browse files
robgilbreathclaude
andcommitted
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]>
1 parent 921d2a4 commit eafd1f0

8 files changed

Lines changed: 441 additions & 83 deletions

File tree

‎.github/actions/README.md‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
| local action | upstream |
30+
|---|---|
31+
| `validate-codebase/action.yml` | `pncit/shared-actions/.github/actions/validate-codebase` |
32+
| `verify-node-toolchain/action.yml` | `pncit/shared-actions/.github/actions/verify-node-toolchain` |
33+
| `verify-version-bump/action.yml` | `pncit/shared-actions/.github/actions/verify-version-bump` |
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
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; re-copy
24+
# when upstream changes (see .github/actions/README.md).
25+
26+
inputs:
27+
npm-token:
28+
description: 'npm token used for `npm ci` (NODE_AUTH_TOKEN in the install step).'
29+
required: true
30+
npm-scope:
31+
description: 'npm scope (for private packages).'
32+
required: false
33+
default: '@pncit'
34+
registry-url:
35+
description: 'npm registry URL.'
36+
required: false
37+
default: 'https://registry.npmjs.org'
38+
39+
npm-version:
40+
description: >-
41+
Exact npm version to pin after setup-node, e.g. "12.0.2". `.nvmrc`
42+
pins a Node *major*, so setup-node resolves to whatever 24.x is
43+
newest on the day — which is how npm crossed the 11 -> 12 boundary
44+
(and started blocking unapproved install scripts) with nothing
45+
committed on either side. Pinning here makes that upgrade a
46+
deliberate, reviewed edit to one default instead of a surprise.
47+
Set to the empty string to opt out and take the bundled npm.
48+
required: false
49+
default: '12.0.2'
50+
node-major-version:
51+
description: >-
52+
Optional. Required Node major, e.g. "24" — typically
53+
vars.NODE_MAJOR_VERSION. When this and npm-major-version are both
54+
set, verify-node-toolchain runs *after* setup-node, so it measures
55+
the toolchain that actually runs `npm ci`. Callers that invoke
56+
verify-node-toolchain as a top-level step are measuring the
57+
runner's system Node/npm, which is not what this action uses.
58+
required: false
59+
default: ''
60+
npm-major-version:
61+
description: 'Optional. Required npm major, e.g. "12". See node-major-version.'
62+
required: false
63+
default: ''
64+
65+
runs:
66+
using: composite
67+
steps:
68+
- name: Checkout
69+
uses: actions/checkout@v7
70+
71+
- name: Setup Node
72+
uses: actions/setup-node@v7
73+
with:
74+
node-version-file: .nvmrc
75+
cache: npm
76+
registry-url: ${{ inputs.registry-url }}
77+
scope: ${{ inputs.npm-scope }}
78+
# actions/setup-node@v6 dropped `always-auth: true` — it was a
79+
# v4-era flag and is no longer needed. Specifying it produced an
80+
# "Unexpected input" warning during the first real deploy run.
81+
82+
# Pin npm before anything reads it. setup-node gives us whatever npm
83+
# its Node bundles; this makes the version an explicit, reviewable
84+
# input instead of a moving target.
85+
- name: Pin npm
86+
if: inputs.npm-version != ''
87+
shell: bash
88+
run: |
89+
npm i -g "npm@${NPM_VERSION}"
90+
echo "npm pinned to $(npm --version) ($(command -v npm))"
91+
env:
92+
NPM_VERSION: ${{ inputs.npm-version }}
93+
94+
# Runs here, after Setup Node and the pin, so it asserts against the
95+
# toolchain `npm ci` will actually use.
96+
- name: Verify Node toolchain
97+
if: inputs.node-major-version != '' && inputs.npm-major-version != ''
98+
uses: pncit/shared-actions/.github/actions/verify-node-toolchain@main
99+
with:
100+
node-major-version: ${{ inputs.node-major-version }}
101+
npm-major-version: ${{ inputs.npm-major-version }}
102+
103+
- name: Install dependencies
104+
shell: bash
105+
env:
106+
NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
107+
run: npm ci 2>&1 | tee "${RUNNER_TEMP}/npm-ci.log"
108+
109+
# npm 11.16.0 added per-package install-script allowlists (the
110+
# `allowScripts` field in package.json). npm 11 warns and still runs
111+
# them; npm 12 blocks them -- and `npm ci` exits 0 either way, so a
112+
# native module can silently never build. That is what took
113+
# documentation-server's whole suite down with 262 "Could not locate
114+
# the bindings file" errors against a green `npm ci`.
115+
#
116+
# Both the warn-phase and block-phase messages contain the literal
117+
# string `allowScripts`, so matching that catches the block and also
118+
# gives early warning on a runner still effectively on npm 11.
119+
#
120+
# Warning, not error, on purpose: most pncit repos have no
121+
# `allowScripts` field yet, and failing here would red them all at
122+
# once. Flip to ::error:: once the org-wide rollout lands.
123+
- name: Audit skipped install scripts
124+
shell: bash
125+
run: |
126+
if grep -q 'allowScripts' "${RUNNER_TEMP}/npm-ci.log"; then
127+
grep 'allowScripts' "${RUNNER_TEMP}/npm-ci.log" >&2
128+
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."
129+
fi
130+
env:
131+
NPM_VERSION: ${{ inputs.npm-version }}
132+
133+
- name: Lint
134+
shell: bash
135+
run: npm run lint
136+
137+
- name: Typecheck
138+
shell: bash
139+
run: npm run typecheck
140+
141+
- name: Test
142+
shell: bash
143+
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; re-copy
35+
# 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
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: 'Verify version bump'
2+
description: >-
3+
One observation: does package.json's `version` differ from the one at a
4+
reference commit? On a pull_request the reference is the base branch, so
5+
the check answers "will publish-on-version-bump have something to publish
6+
after this merges?" before review instead of as a red run on main. On a
7+
push it is the previous commit, which is how the publish workflow itself
8+
decides whether to publish or skip.
9+
10+
# PR gate (fails unless the version was bumped; Dependabot exempt):
11+
#
12+
# - uses: pncit/shared-actions/.github/actions/verify-version-bump@v2
13+
#
14+
# Publish-side detection (never fails; gate the publish job on the output):
15+
#
16+
# check-version:
17+
# outputs:
18+
# changed: ${{ steps.bump.outputs.changed }}
19+
# steps:
20+
# - id: bump
21+
# uses: pncit/shared-actions/.github/actions/verify-version-bump@v2
22+
# with:
23+
# fail-if-unchanged: false
24+
# publish:
25+
# needs: check-version
26+
# if: needs.check-version.outputs.changed == 'true'
27+
#
28+
# Does its own checkout (fetch-depth 2 plus a fetch of the reference), so it
29+
# can run first in a job; a later validate-codebase will check out again.
30+
31+
# Vendored from pncit/shared-actions@v2 (59e838b) because this repo is PUBLIC
32+
# and shared-actions is PRIVATE — a public repo can't `uses:` a private
33+
# action. Byte-for-byte identical to upstream apart from this comment; re-copy
34+
# when upstream changes (see .github/actions/README.md).
35+
36+
inputs:
37+
compare-to:
38+
description: >-
39+
Git ref holding the previous package.json. Default: the PR base branch
40+
on pull_request events, otherwise HEAD^.
41+
required: false
42+
default: ''
43+
package-path:
44+
description: 'Path to the package.json to inspect, relative to the repo root.'
45+
required: false
46+
default: 'package.json'
47+
fail-if-unchanged:
48+
description: >-
49+
"true" fails the step when the version is unchanged (PR gate);
50+
"false" only reports it via the `changed` output (publish-side skip).
51+
required: false
52+
default: 'true'
53+
exempt-actors:
54+
description: >-
55+
Comma-separated GitHub actors for whom an unchanged version is not a
56+
failure. Dependabot only ever moves dependency versions, never the
57+
package's own; its merges land unpublished until the next human bump.
58+
required: false
59+
default: 'dependabot[bot]'
60+
61+
outputs:
62+
changed:
63+
description: '"true" if the version differs from the reference (or the reference has no package.json).'
64+
value: ${{ steps.bump.outputs.changed }}
65+
name:
66+
description: 'package.json name.'
67+
value: ${{ steps.bump.outputs.name }}
68+
current:
69+
description: 'package.json version at HEAD.'
70+
value: ${{ steps.bump.outputs.current }}
71+
previous:
72+
description: 'package.json version at the reference, or empty if none.'
73+
value: ${{ steps.bump.outputs.previous }}
74+
75+
runs:
76+
using: composite
77+
steps:
78+
- name: Checkout
79+
uses: actions/checkout@v7
80+
with:
81+
fetch-depth: 2
82+
83+
- name: Compare package.json version with the reference
84+
id: bump
85+
shell: bash
86+
env:
87+
COMPARE_TO: ${{ inputs.compare-to }}
88+
PACKAGE_PATH: ${{ inputs.package-path }}
89+
FAIL_IF_UNCHANGED: ${{ inputs.fail-if-unchanged }}
90+
EXEMPT_ACTORS: ${{ inputs.exempt-actors }}
91+
EVENT_NAME: ${{ github.event_name }}
92+
BASE_REF: ${{ github.base_ref }}
93+
ACTOR: ${{ github.actor }}
94+
run: |
95+
set -euo pipefail
96+
97+
if [ -z "$COMPARE_TO" ]; then
98+
if [ "$EVENT_NAME" = "pull_request" ] || [ "$EVENT_NAME" = "pull_request_target" ]; then
99+
git fetch --no-tags --depth=1 origin "$BASE_REF"
100+
COMPARE_TO="origin/$BASE_REF"
101+
else
102+
COMPARE_TO="HEAD^"
103+
fi
104+
fi
105+
106+
read_version() {
107+
node -p "(() => { const s = require('fs').readFileSync(0, 'utf8'); try { return JSON.parse(s).version || '' } catch { return '' } })()"
108+
}
109+
110+
NAME=$(node -p "require('./$PACKAGE_PATH').name || ''")
111+
CUR=$(node -p "require('./$PACKAGE_PATH').version || ''")
112+
if [ -z "$CUR" ]; then
113+
echo "::error::$PACKAGE_PATH has no version"
114+
exit 1
115+
fi
116+
117+
PREV=""
118+
if git rev-parse --verify --quiet "$COMPARE_TO" >/dev/null; then
119+
PREV=$(git show "$COMPARE_TO:$PACKAGE_PATH" 2>/dev/null | read_version || true)
120+
fi
121+
122+
{
123+
echo "name=$NAME"
124+
echo "current=$CUR"
125+
echo "previous=$PREV"
126+
} >> "$GITHUB_OUTPUT"
127+
128+
if [ -n "$PREV" ] && [ "$CUR" = "$PREV" ]; then
129+
echo "changed=false" >> "$GITHUB_OUTPUT"
130+
case ",$EXEMPT_ACTORS," in
131+
*",$ACTOR,"*)
132+
echo "::notice::$NAME version unchanged ($CUR); $ACTOR is exempt from the bump gate."
133+
exit 0 ;;
134+
esac
135+
if [ "$FAIL_IF_UNCHANGED" = "true" ]; then
136+
echo "::error::$NAME version unchanged ($PREV -> $CUR) against $COMPARE_TO. Bump $PACKAGE_PATH so the merge has something to publish."
137+
exit 1
138+
fi
139+
echo "::notice::$NAME version unchanged ($CUR) — nothing to publish."
140+
exit 0
141+
fi
142+
143+
echo "changed=true" >> "$GITHUB_OUTPUT"
144+
if [ -z "$PREV" ]; then
145+
echo "No $PACKAGE_PATH at $COMPARE_TO; treating $CUR as new."
146+
else
147+
echo "Version changed: $PREV -> $CUR"
148+
fi

0 commit comments

Comments
 (0)