[repo] Licences: the check covers every crate in Cargo.lock, SPDX rule tests; Fabrica test pipeline

This commit is contained in:
2026-11-17 00:47:02 +01:00
parent fcc9840fdc
commit f1f0234ffb
4 changed files with 224 additions and 149 deletions
+4 -3
View File
@@ -32,11 +32,12 @@ export function allowed(expr) {
}
function main() {
const meta = JSON.parse(execFileSync('cargo', ['metadata', '--format-version', '1', '--locked', '--filter-platform', 'x86_64-pc-windows-msvc'], {
// Every package in Cargo.lock (all platforms): a crate that is locked must be listed, whatever it is built for.
const meta = JSON.parse(execFileSync('cargo', ['metadata', '--format-version', '1', '--locked'], {
cwd: root, maxBuffer: 1 << 28, encoding: 'utf8',
}));
// Only crates reachable on Windows x64 (the one target of V1), not every lockfile entry of every platform:
// with --filter-platform, resolve.nodes lists what the workspace really depends on there.
// resolve.nodes lists every package the lockfile resolves (all targets).
const used = new Set(meta.resolve.nodes.map((n) => n.id));
const workspace = new Set(meta.workspace_members);
const rows = meta.packages
+20
View File
@@ -0,0 +1,20 @@
// The licence rule's SPDX evaluator (scripts/deps.mjs). Run: node --test scripts/deps.test.mjs
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { allowed } from './deps.mjs';
test('the allowed licences pass', () => {
for (const l of ['MIT', 'Apache-2.0', 'BSD-3-Clause', 'Zlib', 'MPL-2.0', 'ISC', 'Unicode-3.0', 'MIT OR Apache-2.0', 'MIT/Apache-2.0', '(MIT OR Apache-2.0) AND Unicode-3.0', 'Apache-2.0 WITH LLVM-exception'])
assert.ok(allowed(l), l);
});
test('copyleft, non-commercial and missing licences fail', () => {
for (const l of ['GPL-3.0', 'AGPL-3.0-only', 'LGPL-2.1', 'CC-BY-NC-4.0', 'MIT AND GPL-2.0', '', undefined, 'SSPL-1.0', 'OpenSSL'])
assert.equal(allowed(l), false, String(l));
});
test('OR needs one allowed branch, AND needs all', () => {
assert.ok(allowed('GPL-2.0 OR MIT'));
assert.equal(allowed('GPL-2.0 AND MIT'), false);
assert.ok(allowed('(GPL-2.0 OR MIT) AND Apache-2.0'));
});