CI: Node 22 tests, registry signatures, licence review (#45)
CI / Lint (eslint) (pull_request) Successful in 20s
CI / Test (jest) (pull_request) Successful in 25s
CI / Security (npm audit) (pull_request) Successful in 52s
CI / Test (Node 22) (pull_request) Successful in 1m37s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 2m21s
CI / Integration (api) (pull_request) Successful in 3m17s
CI / UI screenshots (before/after) (pull_request) Successful in 12s
CI / UI (playwright) (pull_request) Successful in 2m41s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped

- Test (Node 22): the unit tests on node:22-bookworm (pinned by digest),
  as a separate job so the required "Test (jest)" context is unchanged.
  Not required and not a deploy prerequisite: a heads-up before
  production moves to Node 22.
- Security job: npm ci --ignore-scripts, then `npm audit signatures`
  (every installed package's registry signature and attestations) and
  scripts/ci/licenses.js, which fails when a production dependency's
  licence is not on the allowlist (MIT, ISC, BSD-2/3, Apache-2.0, 0BSD,
  BlueOak-1.0.0, CC0-1.0, Unlicense, Python-2.0). Licences missing from
  the lockfile are read from the installed package.json.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-23 19:21:44 -05:00
1 parent 777ab728c0
commit 51f4593b55
2 files changed
+73

No files matched your search

+22
View File
@@ -63,6 +63,22 @@ jobs:
- name: Run jest with coverage
run: npm test -- --ci
# The unit tests on the next Node LTS, ahead of moving production to it (#45). Not a
# required check: a failure here is a heads-up, not a blocker.
test-node22:
name: Test (Node 22)
runs-on: ubuntu-latest
timeout-minutes: 20
container: node:22-bookworm@sha256:e13726ca604184d7a91fcacab1fc09eefd642dc28e79ac34e85540dd93b78cfb
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
persist-credentials: false # no job pushes; keep the token out of .git/config
- name: Install dependencies (lockfile only)
run: npm ci
- name: Run jest
run: npx jest --ci
audit:
name: Security (npm audit)
runs-on: ubuntu-latest
@@ -84,6 +100,12 @@ jobs:
sleep 20
done
exit 1
- name: Install dependencies (lockfile only)
run: npm ci --ignore-scripts
- name: Registry signatures and provenance of every installed package
run: npm audit signatures
- name: Licences of production dependencies
run: node scripts/ci/licenses.js
- name: Software bill of materials (production dependencies)
run: npm sbom --sbom-format cyclonedx --omit dev --package-lock-only > sbom.cdx.json
- name: Keep the SBOM for each main build
+51
View File
@@ -0,0 +1,51 @@
#!/usr/bin/env node
'use strict';
// Licence review for production dependencies (#45): every package that ships with Pulse
// must use a licence on the allowlist. Run after `npm ci`. The lockfile records most
// licences; for the rest, the installed package's own package.json is read.
// An SPDX "A OR B" passes when either side is allowed; "A AND B" needs both.
const fs = require('fs');
const path = require('path');
const ALLOWED = new Set([
'MIT', 'ISC', 'BSD-2-Clause', 'BSD-3-Clause', 'Apache-2.0', '0BSD',
'BlueOak-1.0.0', 'CC0-1.0', 'Unlicense', 'Python-2.0',
]);
const root = path.join(__dirname, '..', '..');
const lock = JSON.parse(fs.readFileSync(path.join(root, 'package-lock.json'), 'utf8'));
function licenceOf(key, entry) {
if (entry.license) return entry.license;
try {
const pkg = JSON.parse(fs.readFileSync(path.join(root, key, 'package.json'), 'utf8'));
if (typeof pkg.license === 'string') return pkg.license;
if (pkg.license && pkg.license.type) return pkg.license.type;
if (Array.isArray(pkg.licenses)) return pkg.licenses.map(l => l.type || l).join(' OR ');
} catch (e) { /* not installed or unreadable: reported below */ }
return null;
}
function allowed(expr) {
const clean = expr.replace(/[()]/g, ' ').trim();
return clean.split(/\s+OR\s+/).some(alt => alt.split(/\s+AND\s+/).every(id => ALLOWED.has(id.trim())));
}
const problems = [];
let checked = 0;
for (const [key, entry] of Object.entries(lock.packages || {})) {
if (!key || entry.dev || entry.link) continue; // the root, dev-only and workspace links
checked++;
const lic = licenceOf(key, entry);
if (!lic) problems.push(`${key}: no licence found`);
else if (!allowed(lic)) problems.push(`${key}: ${lic}`);
}
if (problems.length) {
console.error(`Licences not on the allowlist (${[...ALLOWED].join(', ')}):`);
for (const p of problems) console.error(' ' + p);
process.exit(1);
}
console.log(`${checked} production packages, all with allowed licences.`);