Merge pull request 'CI: Node 22 tests, registry signatures, licence review' (#86) from ci-node22-supplychain into main
CI / UI screenshots (before/after) (push) Skipped
CI / Lint (eslint) (push) Successful in 32s
CI / Test (Node 22) (push) Successful in 32s
CI / Test (jest) (push) Successful in 37s
CI / Security (npm audit) (push) Successful in 44s
CI / Scan (secrets, workflows, shell) (push) Successful in 1m47s
CI / Integration (api) (push) Successful in 2m51s
CI / UI (playwright) (push) Successful in 2m29s
CI / Deploy (push) Successful in 14s
CI / Deploy worker (push) Successful in 8s
CI / Notify (push) Successful in 2s
CI / UI screenshots (before/after) (push) Skipped
CI / Lint (eslint) (push) Successful in 32s
CI / Test (Node 22) (push) Successful in 32s
CI / Test (jest) (push) Successful in 37s
CI / Security (npm audit) (push) Successful in 44s
CI / Scan (secrets, workflows, shell) (push) Successful in 1m47s
CI / Integration (api) (push) Successful in 2m51s
CI / UI (playwright) (push) Successful in 2m29s
CI / Deploy (push) Successful in 14s
CI / Deploy worker (push) Successful in 8s
CI / Notify (push) Successful in 2s
This commit was merged in pull request #86.
This commit is contained in:
commit
e6dfb011c7
2 files changed
+73
No files matched your search
@@ -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
|
||||
|
||||
Executable
+51
@@ -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.`);
|
||||
Reference in new issue
Block a user