@intellectual-frontiers/libraries 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +8 -2
- package/dist/affected.d.ts +28 -0
- package/dist/affected.js +250 -0
- package/dist/changes.d.ts +27 -0
- package/dist/changes.js +470 -0
- package/dist/check.d.ts +15 -0
- package/dist/check.js +198 -0
- package/dist/generate-ontology.d.ts +37 -0
- package/dist/generate-ontology.js +293 -0
- package/dist/generate-workflows.d.ts +12 -0
- package/dist/generate-workflows.js +102 -0
- package/dist/imports/nist-sp-800-53.import.d.ts +33 -0
- package/dist/imports/nist-sp-800-53.import.js +34 -0
- package/dist/imports/schema-org.import.d.ts +33 -0
- package/dist/imports/schema-org.import.js +31 -0
- package/dist/install-bun.d.ts +1 -0
- package/dist/install-bun.js +58 -0
- package/dist/libraries.d.ts +79 -0
- package/dist/libraries.js +386 -0
- package/dist/mod.d.ts +16 -0
- package/dist/mod.js +16 -0
- package/dist/newer.d.ts +27 -0
- package/dist/newer.js +147 -0
- package/dist/oscal-register.d.ts +65 -0
- package/dist/oscal-register.js +344 -0
- package/dist/pack-library.d.ts +47 -0
- package/dist/pack-library.js +498 -0
- package/dist/pins.d.ts +15 -0
- package/dist/pins.js +29 -0
- package/dist/publish-ontology.d.ts +160 -0
- package/dist/publish-ontology.js +227 -0
- package/dist/versions.d.ts +26 -0
- package/dist/versions.js +556 -0
- package/dist/workflows/definitions.d.ts +65 -0
- package/dist/workflows/definitions.js +614 -0
- package/dist/workflows/mod.d.ts +10 -0
- package/dist/workflows/mod.js +10 -0
- package/dist/workflows/model.d.ts +143 -0
- package/dist/workflows/model.js +81 -0
- package/dist/workflows/render.d.ts +9 -0
- package/dist/workflows/render.js +179 -0
- package/package.json +129 -4
- package/src/affected.ts +265 -0
- package/src/changes.ts +546 -0
- package/src/check.ts +223 -0
- package/src/generate-ontology.ts +350 -0
- package/src/generate-workflows.ts +103 -0
- package/src/imports/nist-sp-800-53.import.ts +36 -0
- package/src/imports/schema-org.import.ts +31 -0
- package/src/install-bun.ts +53 -0
- package/src/libraries.ts +385 -0
- package/src/mod.ts +16 -0
- package/src/newer.ts +154 -0
- package/src/oscal-register.ts +443 -0
- package/src/pack-library.ts +522 -0
- package/src/pins.ts +30 -0
- package/src/publish-ontology.ts +354 -0
- package/src/versions.ts +594 -0
- package/src/workflows/definitions.ts +847 -0
- package/src/workflows/mod.ts +30 -0
- package/src/workflows/model.ts +187 -0
- package/src/workflows/render.ts +176 -0
|
@@ -0,0 +1,614 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workflows of this repository, as the typed values the files under `.github/workflows/` are made from (commons 0030-generated-workflows FR-001, FR-005, FR-006): the pins and the steps they share
|
|
3
|
+
* are written once, the workflow of each library of commons is made from its manifest, and the rest are written here as values. Nothing is read from a file but the manifests, and nothing is written.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* `workflows(libraries)` gives every workflow, in the order of their files' names; the library workflows come from `libraryWorkflow`, which reads the folder, the name and the `verify` command of a manifest
|
|
7
|
+
* (0027-commons-libraries FR-012) and what else the library's job needs from `LIBRARY_CI`, the facts of CI that a manifest does not hold (a library without a record has the job `verify` and nothing else).
|
|
8
|
+
* The workflows run on the same triggers, with the same jobs and steps and the same names as the hand-written ones they replaced, so that the names of their checks do not change.
|
|
9
|
+
*
|
|
10
|
+
* @limits
|
|
11
|
+
* It does not run a workflow or read one; a library that registers needs no entry of `LIBRARY_CI` unless its CI is more than `verify`.
|
|
12
|
+
*
|
|
13
|
+
* Spec: 0001-libraries FR-004
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
import { expr, job, run, use } from "./model.js";
|
|
18
|
+
/** The versions the workflows pin (FR-005): each once. */
|
|
19
|
+
export const PIN = {
|
|
20
|
+
checkout: "actions/checkout@v4",
|
|
21
|
+
setupNode: "actions/setup-node@v4",
|
|
22
|
+
cache: "actions/cache@v4",
|
|
23
|
+
uploadArtifact: "actions/upload-artifact@v4",
|
|
24
|
+
downloadArtifact: "actions/download-artifact@v4",
|
|
25
|
+
uploadPages: "actions/upload-pages-artifact@v3",
|
|
26
|
+
deployPages: "actions/deploy-pages@v4",
|
|
27
|
+
bun: "./.github/actions/bun",
|
|
28
|
+
};
|
|
29
|
+
/** The Node that is the backup runtime (commons 0005-typescript-runtime). */
|
|
30
|
+
export const NODE_VERSION = "26.13.1";
|
|
31
|
+
/** The canary of Bun that runs the linter until a release does (FR-028 of 0005-typescript-runtime). */
|
|
32
|
+
export const BUN_LINT_VERSION = "1.4.4-canary.20261115.1";
|
|
33
|
+
const checkout = (o = {}) => use(PIN.checkout, {
|
|
34
|
+
...(o.fetchDepth === undefined ? {} : { with: { "fetch-depth": o.fetchDepth } }),
|
|
35
|
+
...(o.comment === undefined ? {} : { comment: o.comment }),
|
|
36
|
+
});
|
|
37
|
+
const bun = (o = {}) => use(PIN.bun, o.nodeVersion === undefined ? {} : { with: { "node-version": o.nodeVersion } });
|
|
38
|
+
const setupNode = (when) => use(PIN.setupNode, { ...(when === undefined ? {} : { when }), with: { "node-version": expr("env.NODE_VERSION") } });
|
|
39
|
+
const tools = (workingDirectory, name = "The development tools, from bun.lock") => run("bun install --frozen-lockfile", { name, workingDirectory });
|
|
40
|
+
/**
|
|
41
|
+
* A run that a newer push to the same branch replaces is stopped, except on main, where each commit keeps its own result.
|
|
42
|
+
*/
|
|
43
|
+
const supersedable = {
|
|
44
|
+
group: `${expr("github.workflow")}-${expr("github.ref")}`,
|
|
45
|
+
cancelInProgress: expr("github.ref != 'refs/heads/main'"),
|
|
46
|
+
};
|
|
47
|
+
/** A script from its lines, ending with a newline as a literal block does. */
|
|
48
|
+
const lines = (...l) => `${l.join("\n")}\n`;
|
|
49
|
+
/** The files a workflow of this repository runs on a change of (a push and a pull request alike). */
|
|
50
|
+
const BUN_ACTION = ".github/actions/bun/**";
|
|
51
|
+
const own = (file) => `.github/workflows/${file}.auto.yml`;
|
|
52
|
+
/** The facts of CI of the libraries that have more than `verify`, by the library's name. */
|
|
53
|
+
export const LIBRARY_CI = {
|
|
54
|
+
data: {
|
|
55
|
+
comment: lines("IFC data, an independent library of commons (commons 0027-commons-libraries FR-010): its own `verify` (the compiler, the specification checker and the rules on its own", "spec kit, and its tests) on Bun, and its tests on Node 26, the backup runtime (commons 0005-typescript-runtime). It runs when its folder changes or what it imports does:", "the kernel and the runtime, the specification tools, and the Bun action.").trimEnd(),
|
|
56
|
+
afterVerify: [
|
|
57
|
+
run("bun tools/generate-dpv.ts --check", {
|
|
58
|
+
name: "The terms of DPV, as the vocabulary's CSV makes them (a fetch, so not in verify)",
|
|
59
|
+
workingDirectory: "commons/data",
|
|
60
|
+
}),
|
|
61
|
+
],
|
|
62
|
+
nodeTests: 'node --test "suite/**/*.test.ts"',
|
|
63
|
+
},
|
|
64
|
+
core: {
|
|
65
|
+
comment: lines("Core, the foundation of commons, the first library lifted out of `commons/ts` (commons 0032-lifting-libraries): its own `verify` (the compiler, the specification checker, the trace, its tests and the packing of its", "package with the inspection of its declarations) on Bun and its tests on Node 26, on Windows, macOS and Linux, because the package runs on all three.").trimEnd(),
|
|
66
|
+
nodeTests: 'node --test "suite/**/*.test.ts"',
|
|
67
|
+
systems: ["windows-latest", "macos-latest", "ubuntu-latest"],
|
|
68
|
+
},
|
|
69
|
+
rdf: {
|
|
70
|
+
comment: lines("RDF, typed RDF and its writers, a library lifted out of `commons/ts` (commons 0032-lifting-libraries): its own `verify` (the compiler, the specification checker, the trace, its tests and the", "package with the inspection of its declarations) on Bun and its tests on Node 26, on Windows, macOS and Linux, because the package runs on all three.").trimEnd(),
|
|
71
|
+
nodeTests: 'node --test "suite/**/*.test.ts"',
|
|
72
|
+
systems: ["windows-latest", "macos-latest", "ubuntu-latest"],
|
|
73
|
+
},
|
|
74
|
+
terminal: {
|
|
75
|
+
comment: lines("Terminal, the command line and the console as pure code, a library lifted out of `commons/ts` (commons 0032-lifting-libraries): its own `verify` (the compiler, the specification checker, the trace, its tests and the", "package with the inspection of its declarations) on Bun and its tests on Node 26, on Windows, macOS and Linux, because the package runs on all three.").trimEnd(),
|
|
76
|
+
nodeTests: 'node --test "suite/**/*.test.ts"',
|
|
77
|
+
systems: ["windows-latest", "macos-latest", "ubuntu-latest"],
|
|
78
|
+
},
|
|
79
|
+
net: {
|
|
80
|
+
comment: lines("Net, the network as one typed library (downloads, an HTTP server and clients, TCP and TLS, DNS and ACME), a library lifted out of `commons/ts` (commons 0032-lifting-libraries): its own `verify` (the compiler, the specification checker, the trace, its tests and the", "packing of its package with the inspection of its declarations) on Bun and its tests on Node 26, on Windows, macOS and Linux, because the package runs on all three.").trimEnd(),
|
|
81
|
+
nodeTests: 'node --test "suite/**/*.test.ts"',
|
|
82
|
+
systems: ["windows-latest", "macos-latest", "ubuntu-latest"],
|
|
83
|
+
},
|
|
84
|
+
grc: {
|
|
85
|
+
comment: lines("GRC, governance, risk and compliance as code as one typed library, a library lifted out of `commons/ts` (commons 0032-lifting-libraries): its own `verify` (the compiler, the specification checker, the trace, its tests and the", "packing of its package with the inspection of its declarations) on Bun and its tests on Node 26, on Windows, macOS and Linux, because the package runs on all three.").trimEnd(),
|
|
86
|
+
nodeTests: 'node --test "suite/**/*.test.ts"',
|
|
87
|
+
systems: ["windows-latest", "macos-latest", "ubuntu-latest"],
|
|
88
|
+
},
|
|
89
|
+
test: {
|
|
90
|
+
comment: lines("Test, tests that run unchanged under `bun test` and `node --test` and are recorded as evidence by their own code, a library lifted out of `commons/ts` (commons 0032-lifting-libraries): its own `verify` (the compiler, the specification checker, the trace, its tests and the", "packing of its package with the inspection of its declarations) on Bun and its tests on Node 26, on Windows, macOS and Linux, because the package runs on all three.").trimEnd(),
|
|
91
|
+
nodeTests: 'node --test "suite/**/*.test.ts"',
|
|
92
|
+
systems: ["windows-latest", "macos-latest", "ubuntu-latest"],
|
|
93
|
+
},
|
|
94
|
+
lint: {
|
|
95
|
+
comment: lines("Lint, the lint plugin of Intellectual Frontiers, a library lifted out of `commons/ts` (commons 0032-lifting-libraries): its own `verify` (the pinned linter's canary, the compiler, the specification checker, the trace, its tests, which run", "the real `bun lint`, and the packing of its package with the inspection of its declarations) on Bun and its tests on Node 26, on Windows, macOS and Linux, because the package runs on all three.").trimEnd(),
|
|
96
|
+
nodeTests: `bun x bun@${BUN_LINT_VERSION} --version && node --test "suite/**/*.test.ts"`,
|
|
97
|
+
systems: ["windows-latest", "macos-latest", "ubuntu-latest"],
|
|
98
|
+
},
|
|
99
|
+
githost: {
|
|
100
|
+
comment: lines("Githost, the Git hosts behind one typed interface (GitHub, GitLab and plain Git) and the reading of a remote, a library lifted out of `commons/ts` (commons 0032-lifting-libraries): its own `verify` (the compiler, the specification checker, the trace, its tests and the", "packing of its package with the inspection of its declarations) on Bun and its tests on Node 26, on Windows, macOS and Linux, because the package runs on all three.").trimEnd(),
|
|
101
|
+
nodeTests: 'node --test "suite/**/*.test.ts"',
|
|
102
|
+
systems: ["windows-latest", "macos-latest", "ubuntu-latest"],
|
|
103
|
+
},
|
|
104
|
+
ontology: {
|
|
105
|
+
comment: lines("Ontology, the ontologies of commons as typed values (Mizan, IFCCM, IFQS, IFR, the audit of packaging and the software supply chain), a library lifted out of `commons/ts` (commons 0032-lifting-libraries): its own `verify` (the compiler, the spec checker, the trace, its tests and the packing of its package with the inspection of its declarations) on Bun and its tests on", "Node 26, on Windows, macOS and Linux, because the package runs on all three.").trimEnd(),
|
|
106
|
+
nodeTests: 'node --test "suite/**/*.test.ts"',
|
|
107
|
+
systems: ["windows-latest", "macos-latest", "ubuntu-latest"],
|
|
108
|
+
},
|
|
109
|
+
mizan: {
|
|
110
|
+
comment: lines("Mizan, the harness and the rules of the IF Spec Profile as plugins, with the change-control and release rules, the levels, the integrations and the trace, a library lifted out of `commons/ts` (commons 0032-lifting-libraries): its own `verify` (the compiler, the spec checker, the trace, its tests and the packing of its package with the inspection of its declarations) on Bun and its tests on", "Node 26, on Windows, macOS and Linux, because the package runs on all three.").trimEnd(),
|
|
111
|
+
nodeTests: 'node --test "suite/**/*.test.ts"',
|
|
112
|
+
systems: ["windows-latest", "macos-latest", "ubuntu-latest"],
|
|
113
|
+
},
|
|
114
|
+
libraries: {
|
|
115
|
+
comment: lines("Libraries, the tools that manage the libraries of a repository of commons and hold it to Mizan (the manifest, the affected libraries, the typed workflows and their generator, the pinned Bun, the packer and the", "commands of the repository), a library lifted out of `commons/ts` (commons 0032-lifting-libraries): its own `verify` (the compiler, the specification checker, the trace, its tests and the packing of its package with", "the inspection of its declarations) on Bun and its tests on Node 26, on Windows, macOS and Linux, because the package runs on all three.").trimEnd(),
|
|
116
|
+
nodeTests: 'node --test "suite/**/*.test.ts"',
|
|
117
|
+
systems: ["windows-latest", "macos-latest", "ubuntu-latest"],
|
|
118
|
+
},
|
|
119
|
+
telemetry: {
|
|
120
|
+
comment: lines("Telemetry, OpenTelemetry-native signals as one typed library, a library lifted out of `commons/ts` (commons 0032-lifting-libraries): its own `verify` (the compiler, the specification checker, the trace, its tests and the", "packing of its package with the inspection of its declarations) on Bun and its tests on Node 26, on Windows, macOS and Linux, because the package runs on all three.").trimEnd(),
|
|
121
|
+
nodeTests: 'node --test "suite/**/*.test.ts"',
|
|
122
|
+
systems: ["windows-latest", "macos-latest", "ubuntu-latest"],
|
|
123
|
+
},
|
|
124
|
+
system: {
|
|
125
|
+
comment: lines("System, the host as one typed library (files, paths, processes, Git, scheduled jobs and the terminal's streams), a library lifted out of `commons/ts` (commons 0032-lifting-libraries): its own `verify` (the compiler, the specification checker, the trace, its tests and the", "package with the inspection of its declarations) on Bun and its tests on Node 26, on Windows, macOS and Linux, because the package runs on all three.").trimEnd(),
|
|
126
|
+
nodeTests: 'node --test "suite/**/*.test.ts"',
|
|
127
|
+
systems: ["windows-latest", "macos-latest", "ubuntu-latest"],
|
|
128
|
+
},
|
|
129
|
+
formats: {
|
|
130
|
+
comment: lines("Formats, a library lifted out of `commons/ts` (commons 0032-lifting-libraries): its own `verify` (the compiler, the specification checker, the trace, its tests and the packing of its", "package with the inspection of its declarations) on Bun and its tests on Node 26, on Windows, macOS and Linux, because the package runs on all three.").trimEnd(),
|
|
131
|
+
nodeTests: 'node --test "suite/**/*.test.ts"',
|
|
132
|
+
systems: ["windows-latest", "macos-latest", "ubuntu-latest"],
|
|
133
|
+
},
|
|
134
|
+
crypto: {
|
|
135
|
+
comment: lines("Crypto, a library lifted out of `commons/ts` (commons 0032-lifting-libraries): its own `verify` (the compiler, the specification checker, the trace, its tests and the packing of its", "package with the inspection of its declarations) on Bun and its tests on Node 26, on Windows, macOS and Linux, because the package runs on all three.").trimEnd(),
|
|
136
|
+
nodeTests: 'node --test "suite/**/*.test.ts"',
|
|
137
|
+
systems: ["windows-latest", "macos-latest", "ubuntu-latest"],
|
|
138
|
+
},
|
|
139
|
+
quality: {
|
|
140
|
+
comment: lines("Quality, the quality system of commons (the record of a run as evidence, the quality branch, the ladder, the ledger, the Trust page and the assessor pack), a library lifted out of `commons/ts`", "(commons 0032-lifting-libraries): its own `verify` on Bun and its tests, which run a real Git, on Node 26, on Linux.").trimEnd(),
|
|
141
|
+
nodeTests: 'node --test "suite/**/*.test.ts"',
|
|
142
|
+
},
|
|
143
|
+
ergonex: {
|
|
144
|
+
comment: lines("Ergonex, the workspaces management of Intellectual Frontiers, a library of commons (commons 0027-commons-libraries FR-010): its own `verify` on Bun and its tests on Node 26, the backup runtime,", "on Windows first, then macOS and Linux (ergonex 0004-onboarding): a person on any of them installs the command from npm and runs it.").trimEnd(),
|
|
145
|
+
nodeTests: 'node --test "suite/**/*.test.ts"',
|
|
146
|
+
systems: ["windows-latest", "macos-latest", "ubuntu-latest"],
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
/** The workflow of a library of commons, made from its manifest (FR-006): its `verify` on Bun when its folder or what it imports changes, and its tests on Node where its record says so. */
|
|
150
|
+
export function libraryWorkflow(l) {
|
|
151
|
+
const folder = `commons/${l.name}`;
|
|
152
|
+
const ci = LIBRARY_CI[l.name];
|
|
153
|
+
const paths = l.paths;
|
|
154
|
+
const systems = ci?.systems;
|
|
155
|
+
const onSystems = systems === undefined
|
|
156
|
+
? { runsOn: "ubuntu-latest" }
|
|
157
|
+
: { runsOn: expr("matrix.os"), strategy: { failFast: false, matrix: { os: systems } } };
|
|
158
|
+
const verify = job({
|
|
159
|
+
...onSystems,
|
|
160
|
+
timeoutMinutes: 15,
|
|
161
|
+
steps: [
|
|
162
|
+
checkout(),
|
|
163
|
+
bun(),
|
|
164
|
+
tools(folder, "The development tools, from bun.lock (the kernel is linked from commons/ts)"),
|
|
165
|
+
run(l.verify, { name: "verify", workingDirectory: folder }),
|
|
166
|
+
...(ci?.afterVerify ?? []),
|
|
167
|
+
],
|
|
168
|
+
});
|
|
169
|
+
const node = ci?.nodeTests === undefined
|
|
170
|
+
? {}
|
|
171
|
+
: {
|
|
172
|
+
node: job({
|
|
173
|
+
...onSystems,
|
|
174
|
+
timeoutMinutes: 15,
|
|
175
|
+
steps: [
|
|
176
|
+
checkout(),
|
|
177
|
+
bun(),
|
|
178
|
+
setupNode(),
|
|
179
|
+
tools(folder),
|
|
180
|
+
run(ci.nodeTests, { name: "The tests on Node 26", workingDirectory: folder }),
|
|
181
|
+
],
|
|
182
|
+
}),
|
|
183
|
+
};
|
|
184
|
+
return {
|
|
185
|
+
file: l.name,
|
|
186
|
+
name: l.name,
|
|
187
|
+
...(ci === undefined ? {} : { comment: ci.comment }),
|
|
188
|
+
on: { push: { paths }, pullRequest: { paths } },
|
|
189
|
+
permissions: { contents: "read" },
|
|
190
|
+
env: { NODE_VERSION },
|
|
191
|
+
concurrency: supersedable,
|
|
192
|
+
jobs: { verify, ...node },
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
const ifcTypescriptPaths = [
|
|
196
|
+
"commons/ts/**",
|
|
197
|
+
"commons/docs/**",
|
|
198
|
+
"commons/generated/pins.auto.env",
|
|
199
|
+
"package.json",
|
|
200
|
+
"bun.lock",
|
|
201
|
+
BUN_ACTION,
|
|
202
|
+
own("ifc-typescript"),
|
|
203
|
+
];
|
|
204
|
+
const ifcTypescript = {
|
|
205
|
+
file: "ifc-typescript",
|
|
206
|
+
name: "ifc-typescript",
|
|
207
|
+
comment: lines("IFC TypeScript (commons 0005-typescript-runtime FR-017, FR-018, FR-026 to FR-030, FR-070). TypeScript 7 checks; Bun, pinned in commons' pins, installs, formats", "and lints; the same tests run unchanged on Bun, the default runtime, and Node 26, the backup, on Linux, macOS and Windows; and the commit is installed as a Git dependency of an empty project,", "as a consumer installs it, and used there on Bun and Node 26 (through the hook), IFC Docs too (0011-documentation FR-021, FR-022). Nothing is released.").trimEnd(),
|
|
208
|
+
on: { push: { paths: ifcTypescriptPaths }, pullRequest: { paths: ifcTypescriptPaths } },
|
|
209
|
+
permissions: { contents: "read" },
|
|
210
|
+
env: { NODE_VERSION, BUN_LINT_VERSION },
|
|
211
|
+
concurrency: supersedable,
|
|
212
|
+
jobs: {
|
|
213
|
+
check: job({
|
|
214
|
+
runsOn: "ubuntu-latest",
|
|
215
|
+
timeoutMinutes: 10,
|
|
216
|
+
steps: [
|
|
217
|
+
checkout(),
|
|
218
|
+
bun(),
|
|
219
|
+
tools("commons/ts"),
|
|
220
|
+
run("bun x tsc --version && bun run check", {
|
|
221
|
+
name: "TypeScript 7 on everything, then the kernel with no host types",
|
|
222
|
+
workingDirectory: "commons/ts",
|
|
223
|
+
}),
|
|
224
|
+
run("bun fmt --check", { name: "The formatter", workingDirectory: "commons/ts" }),
|
|
225
|
+
run('bun x "bun@$BUN_LINT_VERSION" lint --type-aware --max-warnings 0 kernel runtime tests tools', {
|
|
226
|
+
name: "The linter, type-aware, no warning allowed",
|
|
227
|
+
workingDirectory: "commons/ts",
|
|
228
|
+
}),
|
|
229
|
+
],
|
|
230
|
+
}),
|
|
231
|
+
test: job({
|
|
232
|
+
runsOn: expr("matrix.os"),
|
|
233
|
+
timeoutMinutes: 15,
|
|
234
|
+
strategy: { failFast: false, matrix: { os: ["ubuntu-latest", "macos-latest", "windows-latest"], runtime: ["bun", "node"] } },
|
|
235
|
+
steps: [
|
|
236
|
+
checkout(),
|
|
237
|
+
bun(),
|
|
238
|
+
tools("commons/ts"),
|
|
239
|
+
setupNode("matrix.runtime == 'node'"),
|
|
240
|
+
run('bun x "bun@$BUN_LINT_VERSION" --version', {
|
|
241
|
+
name: "The linter's canary, so the lint plugin's tests run rather than skip",
|
|
242
|
+
shell: "bash",
|
|
243
|
+
}),
|
|
244
|
+
run(lines(`grep -E '^000[5-8]-' ../spec-kit/enforcement.tsv >"$RUNNER_TEMP/requirements.tsv"`, "bun ../quality/src/test-cli.ts run --runtime ${{ matrix.runtime }} --out test-results \\", " --report tap,junit,ctrf,sarif,md,html,oscal \\", ' --requirements "$RUNNER_TEMP/requirements.tsv" --reviewed ci-reviewed.tsv \\', " --ledger test-results/ledger.jsonl tests"), {
|
|
245
|
+
name: "The suite on ${{ matrix.runtime }}, recorded as evidence (commons 0008-test-evidence FR-014)",
|
|
246
|
+
comment: "A hang ends here, so the record of what ran is still kept below.",
|
|
247
|
+
timeoutMinutes: 10,
|
|
248
|
+
workingDirectory: "commons/ts",
|
|
249
|
+
shell: "bash",
|
|
250
|
+
}),
|
|
251
|
+
use(PIN.uploadArtifact, {
|
|
252
|
+
name: "The record, its reports and the ledger, kept with the run",
|
|
253
|
+
when: "always()",
|
|
254
|
+
with: {
|
|
255
|
+
name: "test-evidence-${{ matrix.os }}-${{ matrix.runtime }}",
|
|
256
|
+
path: "commons/ts/test-results/",
|
|
257
|
+
"if-no-files-found": "error",
|
|
258
|
+
},
|
|
259
|
+
}),
|
|
260
|
+
],
|
|
261
|
+
}),
|
|
262
|
+
"otel-conformance": job({
|
|
263
|
+
comment: "commons 0006-signals FR-020: the suite's OTLP sent to the pinned OpenTelemetry Collector, read back from its file exporter.",
|
|
264
|
+
runsOn: "ubuntu-latest",
|
|
265
|
+
timeoutMinutes: 10,
|
|
266
|
+
steps: [
|
|
267
|
+
checkout(),
|
|
268
|
+
bun(),
|
|
269
|
+
tools("commons/telemetry"),
|
|
270
|
+
run(lines("v=$(sed -n 's/^OTELCOL_CONTRIB_VERSION=//p' commons/generated/pins.auto.env)", "sum=$(sed -n 's/^OTELCOL_CONTRIB_SHA256_X86_64=//p' commons/generated/pins.auto.env)", 'dir="$RUNNER_TEMP/otelcol"', 'mkdir -p "$dir"', 'curl -fsSL -o "$dir/otelcol.tar.gz" "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v$v/otelcol-contrib_${v}_linux_amd64.tar.gz"', 'echo "$sum $dir/otelcol.tar.gz" | sha256sum -c -', 'tar -xzf "$dir/otelcol.tar.gz" -C "$dir" otelcol-contrib', 'echo "IFC_OTELCOL=$dir/otelcol-contrib" >>"$GITHUB_ENV"'), { name: "The OpenTelemetry Collector, verified against commons' pins", shell: "bash" }),
|
|
271
|
+
run(lines("bun test suite/otel-conformance.test.ts", "node --test suite/otel-conformance.test.ts"), {
|
|
272
|
+
name: "The conformance test, on Bun and on Node",
|
|
273
|
+
workingDirectory: "commons/telemetry",
|
|
274
|
+
}),
|
|
275
|
+
],
|
|
276
|
+
}),
|
|
277
|
+
compile: job({
|
|
278
|
+
comment: "commons 0005-typescript-runtime FR-062: a program built into one binary by the pinned Bun on each system, then run; and Windows built from Linux.",
|
|
279
|
+
runsOn: expr("matrix.os"),
|
|
280
|
+
timeoutMinutes: 10,
|
|
281
|
+
strategy: { failFast: false, matrix: { os: ["ubuntu-latest", "macos-latest", "windows-latest"] } },
|
|
282
|
+
steps: [
|
|
283
|
+
checkout(),
|
|
284
|
+
bun(),
|
|
285
|
+
tools("commons/system"),
|
|
286
|
+
run("bun test suite/compile.test.ts", {
|
|
287
|
+
name: "Built for this computer, with an embedded file, and run",
|
|
288
|
+
workingDirectory: "commons/system",
|
|
289
|
+
shell: "bash",
|
|
290
|
+
}),
|
|
291
|
+
run(lines("v=$(sed -n 's/^BUN_VERSION=//p' ../generated/pins.auto.env)", 'mkdir -p "$RUNNER_TEMP/cross"', `printf 'console.log("ok");\\n' >"$RUNNER_TEMP/cross/hello.ts"`, "bun -e '", ' import { compile, describeCompileError } from "./src/compile.ts";', ' const r = await compile({ entry: process.argv[1], outfile: process.argv[2], target: "windows-x64", bunVersion: process.argv[3] });', ' if (r.kind === "err") { console.error(describeCompileError(r.error)); process.exit(1); }', " console.log(r.value.path, r.value.sha256);", `' "$RUNNER_TEMP/cross/hello.ts" "$RUNNER_TEMP/cross/hello" "$v"`, 'test -f "$RUNNER_TEMP/cross/hello.exe"'), {
|
|
292
|
+
name: "Built for Windows from Linux, by the pinned Bun alone",
|
|
293
|
+
when: "runner.os == 'Linux'",
|
|
294
|
+
workingDirectory: "commons/system",
|
|
295
|
+
shell: "bash",
|
|
296
|
+
}),
|
|
297
|
+
],
|
|
298
|
+
}),
|
|
299
|
+
"git-dependency": job({
|
|
300
|
+
comment: lines("commons 0005-typescript-runtime FR-030 and 0011-documentation FR-022: the commit checked, installed into an empty project by a", "git+file: URL of this checkout, as a consumer installs it by github:intellectual-frontiers/.github#<commit>, and used there.").trimEnd(),
|
|
301
|
+
runsOn: expr("matrix.os"),
|
|
302
|
+
timeoutMinutes: 15,
|
|
303
|
+
strategy: { failFast: false, matrix: { os: ["ubuntu-latest", "macos-latest", "windows-latest"] } },
|
|
304
|
+
steps: [
|
|
305
|
+
checkout({
|
|
306
|
+
fetchDepth: 0,
|
|
307
|
+
comment: "Bun clones the checkout as a Git repository; a whole one, so that nothing depends on how a shallow clone is cloned.",
|
|
308
|
+
}),
|
|
309
|
+
bun({ nodeVersion: expr("env.NODE_VERSION") }),
|
|
310
|
+
run("bun install --frozen-lockfile", {
|
|
311
|
+
name: "The root package's lockfile, which the consumer does not read but this repository keeps",
|
|
312
|
+
}),
|
|
313
|
+
run(lines("bun install --frozen-lockfile", "node --version", 'bun tools/smoke.ts --repo "$GITHUB_WORKSPACE" --commit "$GITHUB_SHA"'), {
|
|
314
|
+
name: "IFC TypeScript as a Git dependency, on Bun and Node 26, with ifc test and tsc 7",
|
|
315
|
+
workingDirectory: "commons/ts",
|
|
316
|
+
shell: "bash",
|
|
317
|
+
}),
|
|
318
|
+
run(lines("bun install --frozen-lockfile", 'bun tools/smoke.ts --repo "$GITHUB_WORKSPACE" --commit "$GITHUB_SHA"'), {
|
|
319
|
+
name: "IFC Docs as a Git dependency, ifc-docs check and build on a fixture repository on Bun and Node 26",
|
|
320
|
+
workingDirectory: "commons/docs",
|
|
321
|
+
shell: "bash",
|
|
322
|
+
}),
|
|
323
|
+
],
|
|
324
|
+
}),
|
|
325
|
+
},
|
|
326
|
+
};
|
|
327
|
+
const docsPaths = ["commons/**", "package.json", own("docs"), BUN_ACTION];
|
|
328
|
+
const onMainPush = "github.event_name != 'pull_request' && github.ref == 'refs/heads/main'";
|
|
329
|
+
const docs = {
|
|
330
|
+
file: "docs",
|
|
331
|
+
name: "docs",
|
|
332
|
+
comment: lines("The documentation site of commons (commons 0011-documentation FR-020): made by commons/docs, from commons' TypeScript and spec kit alone,", "as commons' configuration (commons/docs.config.ts) says. Every pull request and push that touches commons tests the generator and checks", "the site (no finding, every link and anchor resolves); a push to main builds the site and publishes it to GitHub Pages with GitHub's own", "actions. The site is never committed.").trimEnd(),
|
|
333
|
+
on: { push: { paths: docsPaths }, pullRequest: { paths: docsPaths }, workflowDispatch: true },
|
|
334
|
+
permissions: { contents: "read" },
|
|
335
|
+
concurrency: { group: "docs-${{ github.ref }}", cancelInProgress: true },
|
|
336
|
+
jobs: {
|
|
337
|
+
check: job({
|
|
338
|
+
runsOn: "ubuntu-24.04",
|
|
339
|
+
timeoutMinutes: 15,
|
|
340
|
+
steps: [
|
|
341
|
+
checkout(),
|
|
342
|
+
bun(),
|
|
343
|
+
tools("commons/docs", "TypeScript 7.1 (beta), Mermaid and @types/node, exactly as bun.lock pins them (IFC TypeScript is ../ts, by relative path)"),
|
|
344
|
+
run("bun run verify", { name: "The compiler, the generator's tests, then check on commons", workingDirectory: "commons/docs" }),
|
|
345
|
+
run('bun main.ts build --out "$GITHUB_WORKSPACE/_site"', {
|
|
346
|
+
name: "The site, built",
|
|
347
|
+
when: onMainPush,
|
|
348
|
+
workingDirectory: "commons/docs",
|
|
349
|
+
}),
|
|
350
|
+
use(PIN.uploadPages, { name: "The site, kept for Pages", when: onMainPush, with: { path: "_site" } }),
|
|
351
|
+
],
|
|
352
|
+
}),
|
|
353
|
+
publish: job({
|
|
354
|
+
needs: ["check"],
|
|
355
|
+
when: onMainPush,
|
|
356
|
+
runsOn: "ubuntu-24.04",
|
|
357
|
+
timeoutMinutes: 10,
|
|
358
|
+
permissions: { pages: "write", "id-token": "write" },
|
|
359
|
+
environment: { name: "github-pages", url: "${{ steps.deployment.outputs.page_url }}" },
|
|
360
|
+
steps: [use(PIN.deployPages, { name: "Published to GitHub Pages", id: "deployment" })],
|
|
361
|
+
}),
|
|
362
|
+
},
|
|
363
|
+
};
|
|
364
|
+
const checkScripts = (shellOnly) => {
|
|
365
|
+
const common = [
|
|
366
|
+
"commons/tools/generate-packaging.ts --check",
|
|
367
|
+
"commons/tools/mizan-check.ts",
|
|
368
|
+
"commons/libraries/src/generate-ontology.ts --check",
|
|
369
|
+
"commons/libraries/src/check.ts",
|
|
370
|
+
];
|
|
371
|
+
const more = [
|
|
372
|
+
"commons/libraries/src/libraries.ts --check",
|
|
373
|
+
"commons/libraries/src/generate-workflows.ts --check",
|
|
374
|
+
"commons/libraries/src/versions.ts check",
|
|
375
|
+
"commons/libraries/src/versions.ts ledger",
|
|
376
|
+
"commons/mizan/src/integrations/host/import.ts commons/libraries/src/imports/schema-org.import.ts --check --fetch",
|
|
377
|
+
"commons/mizan/src/integrations/host/import.ts commons/libraries/src/imports/nist-sp-800-53.import.ts --check --fetch",
|
|
378
|
+
];
|
|
379
|
+
const all = shellOnly ? common : [...common, ...more];
|
|
380
|
+
return [...all.map((c) => `bun ${c}`), ...all.map((c) => `node ${c}`)];
|
|
381
|
+
};
|
|
382
|
+
const tests = {
|
|
383
|
+
file: "tests",
|
|
384
|
+
name: "tests",
|
|
385
|
+
comment: lines("The tests of the repository's own files (`tests/`: the one-command installers of agora, commons' packaging tools and specification checker, the layout of the repository),", "on IFC TypeScript: Bun, the default runtime, and Node 26, the backup. Bun comes at the version commons pins (the `.github/actions/bun` action), Node 26 from", "`actions/setup-node`. The tests run the real programs (real `sh`, real `git`, the real tools), never stand-ins; GitHub CLI's sign-in needs an account and a browser,", "and is not run.").trimEnd(),
|
|
386
|
+
on: { push: { branches: ["main"] }, pullRequest: {} },
|
|
387
|
+
permissions: { contents: "read" },
|
|
388
|
+
env: { NODE_VERSION, BUN_LINT_VERSION },
|
|
389
|
+
concurrency: supersedable,
|
|
390
|
+
jobs: {
|
|
391
|
+
check: job({
|
|
392
|
+
runsOn: "ubuntu-latest",
|
|
393
|
+
timeoutMinutes: 15,
|
|
394
|
+
steps: [
|
|
395
|
+
checkout({
|
|
396
|
+
fetchDepth: 0,
|
|
397
|
+
comment: "the whole history and its tags: `versions check` compares each work with the merge base, and its ledger reads the tags (commons 0026-works-versioning FR-022, FR-035)",
|
|
398
|
+
}),
|
|
399
|
+
bun(),
|
|
400
|
+
tools("commons/ts"),
|
|
401
|
+
run("bun run check", { name: "TypeScript 7 on commons' tools and on these tests", workingDirectory: "commons/ts" }),
|
|
402
|
+
run("bun fmt --check . ../tools ../../tests", { name: "The formatter", workingDirectory: "commons/ts" }),
|
|
403
|
+
run('bun x "bun@$BUN_LINT_VERSION" lint --type-aware --max-warnings 0 ../tools ../../tests', {
|
|
404
|
+
name: "The linter, type-aware, no warning allowed",
|
|
405
|
+
workingDirectory: "commons/ts",
|
|
406
|
+
}),
|
|
407
|
+
run(lines(...checkScripts(false)), {
|
|
408
|
+
name: "Commons' generated files and specifications, as a person checks them, on Bun and on Node 26",
|
|
409
|
+
}),
|
|
410
|
+
],
|
|
411
|
+
}),
|
|
412
|
+
tests: job({
|
|
413
|
+
runsOn: expr("matrix.os"),
|
|
414
|
+
timeoutMinutes: 15,
|
|
415
|
+
strategy: { failFast: false, matrix: { os: ["ubuntu-latest", "macos-latest"], runtime: ["bun", "node"] } },
|
|
416
|
+
steps: [
|
|
417
|
+
checkout(),
|
|
418
|
+
bun(),
|
|
419
|
+
tools("commons/ts"),
|
|
420
|
+
run("sudo apt-get update -qq && sudo apt-get install -y -qq shellcheck", {
|
|
421
|
+
name: "ShellCheck, which the packaging test uses where it is installed",
|
|
422
|
+
when: "runner.os == 'Linux'",
|
|
423
|
+
}),
|
|
424
|
+
run(lines('python3 -m venv "$RUNNER_TEMP/venv"', '"$RUNNER_TEMP/venv/bin/pip" install -q rdflib==7.6.0 pyshacl==0.40.2 jsonschema==4.26.0 pyyaml==6.0.3', 'echo "$RUNNER_TEMP/venv/bin" >> "$GITHUB_PATH"'), {
|
|
425
|
+
name: "Independent validators of the exports (rdflib, pySHACL, jsonschema), which the Mizan test uses where they are installed",
|
|
426
|
+
}),
|
|
427
|
+
run("bun test ./tests/", { name: "The tests on Bun", when: "matrix.runtime == 'bun'" }),
|
|
428
|
+
run('node --test "tests/*.test.ts"', { name: "The tests on Node 26", when: "matrix.runtime == 'node'" }),
|
|
429
|
+
],
|
|
430
|
+
}),
|
|
431
|
+
windows: job({
|
|
432
|
+
comment: lines("Windows: what has no shell in it. The generator and the specification checker run on both runtimes; the installers' tests need a POSIX `sh` and a Unix PATH, and", "`agora-install.ps1` is read by its test on the other systems and is not run by any test (it needs a sign-in to GitHub).").trimEnd(),
|
|
433
|
+
runsOn: "windows-latest",
|
|
434
|
+
timeoutMinutes: 15,
|
|
435
|
+
steps: [
|
|
436
|
+
checkout(),
|
|
437
|
+
bun(),
|
|
438
|
+
run(lines(...checkScripts(true)), { name: "Commons' generated files and specifications, on Bun and on Node 26", shell: "bash" }),
|
|
439
|
+
],
|
|
440
|
+
}),
|
|
441
|
+
robot: job({
|
|
442
|
+
comment: lines("ROBOT (the OBO Foundry's ontology tool) reads the generated OWL as a second, independent OWL reader and reports its quality; it must read it, convert it and find it", "consistent, and its report must have no error. The jar is pinned by version and SHA-256.").trimEnd(),
|
|
443
|
+
runsOn: "ubuntu-latest",
|
|
444
|
+
timeoutMinutes: 10,
|
|
445
|
+
env: { ROBOT_VERSION: "1.9.11", ROBOT_SHA256: "53cd275c8e4c0dad1fc2c1c34174876795cd7d6b6926e1444adcbb0cb3c7ab26" },
|
|
446
|
+
steps: [
|
|
447
|
+
checkout(),
|
|
448
|
+
run(lines('curl -fsSL -o "$RUNNER_TEMP/robot.jar" "https://github.com/ontodev/robot/releases/download/v${ROBOT_VERSION}/robot.jar"', 'echo "${ROBOT_SHA256} $RUNNER_TEMP/robot.jar" | sha256sum -c -'), { name: "ROBOT, pinned" }),
|
|
449
|
+
run(lines("for n in mizan ifccm ifqs ifr; do", ' java -jar "$RUNNER_TEMP/robot.jar" convert --input "commons/generated/$n.auto.ofn" --format owl --output "$RUNNER_TEMP/$n.owl"', ' java -jar "$RUNNER_TEMP/robot.jar" convert --input "commons/generated/$n.auto.ttl" --format ofn --output "$RUNNER_TEMP/$n-from-ttl.ofn"', ' java -jar "$RUNNER_TEMP/robot.jar" reason --reasoner ELK --input "commons/generated/$n.auto.ofn"', ' java -jar "$RUNNER_TEMP/robot.jar" report --input "commons/generated/$n.auto.ofn" --fail-on ERROR --output "$RUNNER_TEMP/$n-report.tsv"', "done"), { name: "Convert, reason and report, for each ontology" }),
|
|
450
|
+
],
|
|
451
|
+
}),
|
|
452
|
+
},
|
|
453
|
+
};
|
|
454
|
+
/** Reads the name and version of the tarball in the working folder and says on the step's output whether that version is already on the registry (a re-run, or a first publish made by hand, never fails on a duplicate). */
|
|
455
|
+
const HAVE = (registry) => lines(`pkg=$(tar -xzOf ./*.tgz package/package.json)`, `name=$(printf '%s' "$pkg" | node -p "JSON.parse(require('fs').readFileSync(0,'utf8')).name")`, `version=$(printf '%s' "$pkg" | node -p "JSON.parse(require('fs').readFileSync(0,'utf8')).version")`, `if npm view "$name@$version" version${registry} >/dev/null 2>&1; then`, ' echo "$name@$version is already there"', ' echo "have=true" >> "$GITHUB_OUTPUT"', "else", ' echo "have=false" >> "$GITHUB_OUTPUT"', "fi");
|
|
456
|
+
const HAVE_NPM = HAVE("");
|
|
457
|
+
const HAVE_GITHUB = HAVE(" --registry https://npm.pkg.github.com");
|
|
458
|
+
/**
|
|
459
|
+
* The workflow that publishes a library to the registries its manifest names (0030-generated-workflows FR-009): on a tag `<name>-v<version>` it checks the tag is the version, proves the library, packs it
|
|
460
|
+
* with its `tools/pack.ts` and sends the tarball to npm, with provenance and no token (npm's trusted publishing), and to the GitHub package registry with the workflow's own token.
|
|
461
|
+
*/
|
|
462
|
+
export function publishWorkflow(l) {
|
|
463
|
+
const folder = `commons/${l.name}`;
|
|
464
|
+
const tarball = 'npm publish "$(ls ./*.tgz)"';
|
|
465
|
+
const sendNpm = l.distribution.includes("npm");
|
|
466
|
+
return {
|
|
467
|
+
file: `${l.name}-publish`,
|
|
468
|
+
name: `${l.name}-publish`,
|
|
469
|
+
comment: lines(`Publishes ${l.name} (commons 0027-commons-libraries FR-015, FR-016): a tag \`${l.name}-v<version>\` (made by \`versions tag\`, commons 0026-works-versioning), or a run by hand from main, is checked against the package's version, the library is proved and packed by its own`, "tools/pack.ts, and the tarball goes to the registries its manifest names: npm with provenance and no token (trusted publishing, which the owner of the npm scope sets up once for this workflow's file), and", "the GitHub package registry with this workflow's own token.").trimEnd(),
|
|
470
|
+
on: { push: { tags: [`${l.name}-v*`] }, workflowDispatch: true },
|
|
471
|
+
permissions: { contents: "read" },
|
|
472
|
+
jobs: {
|
|
473
|
+
build: job({
|
|
474
|
+
runsOn: "ubuntu-latest",
|
|
475
|
+
timeoutMinutes: 15,
|
|
476
|
+
steps: [
|
|
477
|
+
checkout(),
|
|
478
|
+
bun(),
|
|
479
|
+
setupNode(),
|
|
480
|
+
tools(folder),
|
|
481
|
+
run(lines(`version=$(node -p "require('./package.json').version")`, `if [ "$GITHUB_REF_TYPE" = tag ]; then`, ` test "$GITHUB_REF_NAME" = "${l.name}-v$version" || { echo "the tag $GITHUB_REF_NAME is not ${l.name}-v$version"; exit 1; }`, `else`, ` test "$GITHUB_REF" = refs/heads/main || { echo "a run by hand publishes only from main, not $GITHUB_REF"; exit 1; }`, `fi`), {
|
|
482
|
+
name: "The tag, or main for a run by hand, is the version of the package",
|
|
483
|
+
workingDirectory: folder,
|
|
484
|
+
shell: "bash",
|
|
485
|
+
}),
|
|
486
|
+
run("bun run verify", { name: "verify", workingDirectory: folder }),
|
|
487
|
+
run("bun tools/pack.ts", { name: "The package that is published", workingDirectory: folder }),
|
|
488
|
+
use(PIN.uploadArtifact, {
|
|
489
|
+
name: "The tarball, kept for the jobs that publish it",
|
|
490
|
+
with: { name: `${l.name}-package`, path: `${folder}/dist/*.tgz`, "if-no-files-found": "error" },
|
|
491
|
+
}),
|
|
492
|
+
],
|
|
493
|
+
}),
|
|
494
|
+
...(sendNpm
|
|
495
|
+
? {
|
|
496
|
+
"publish-npm": job({
|
|
497
|
+
needs: ["build"],
|
|
498
|
+
runsOn: "ubuntu-latest",
|
|
499
|
+
timeoutMinutes: 10,
|
|
500
|
+
permissions: { contents: "read", "id-token": "write" },
|
|
501
|
+
environment: { name: "npm" },
|
|
502
|
+
steps: [
|
|
503
|
+
use(PIN.downloadArtifact, { name: "The tarball", with: { name: `${l.name}-package`, path: "package" } }),
|
|
504
|
+
use(PIN.setupNode, { with: { "node-version": expr("env.NODE_VERSION"), "registry-url": "https://registry.npmjs.org" } }),
|
|
505
|
+
run(HAVE_NPM, {
|
|
506
|
+
name: "Is the version already on npm (published by hand, or by an earlier run)?",
|
|
507
|
+
id: "have",
|
|
508
|
+
shell: "bash",
|
|
509
|
+
workingDirectory: "package",
|
|
510
|
+
}),
|
|
511
|
+
run(tarball + " --access public --provenance", {
|
|
512
|
+
name: "Published to npm, with provenance and no token",
|
|
513
|
+
when: "steps.have.outputs.have != 'true'",
|
|
514
|
+
workingDirectory: "package",
|
|
515
|
+
shell: "bash",
|
|
516
|
+
}),
|
|
517
|
+
],
|
|
518
|
+
}),
|
|
519
|
+
}
|
|
520
|
+
: {}),
|
|
521
|
+
"publish-github": job({
|
|
522
|
+
needs: ["build"],
|
|
523
|
+
runsOn: "ubuntu-latest",
|
|
524
|
+
timeoutMinutes: 10,
|
|
525
|
+
permissions: { contents: "read", packages: "write" },
|
|
526
|
+
steps: [
|
|
527
|
+
use(PIN.downloadArtifact, { name: "The tarball", with: { name: `${l.name}-package`, path: "package" } }),
|
|
528
|
+
use(PIN.setupNode, {
|
|
529
|
+
with: {
|
|
530
|
+
"node-version": expr("env.NODE_VERSION"),
|
|
531
|
+
"registry-url": "https://npm.pkg.github.com",
|
|
532
|
+
scope: "@intellectual-frontiers",
|
|
533
|
+
},
|
|
534
|
+
}),
|
|
535
|
+
run(HAVE_GITHUB, {
|
|
536
|
+
name: "Is the version already on the GitHub package registry?",
|
|
537
|
+
id: "have",
|
|
538
|
+
shell: "bash",
|
|
539
|
+
workingDirectory: "package",
|
|
540
|
+
env: { NODE_AUTH_TOKEN: expr("secrets.GITHUB_TOKEN") },
|
|
541
|
+
}),
|
|
542
|
+
run(tarball, {
|
|
543
|
+
name: "Published to the GitHub package registry",
|
|
544
|
+
when: "steps.have.outputs.have != 'true'",
|
|
545
|
+
workingDirectory: "package",
|
|
546
|
+
shell: "bash",
|
|
547
|
+
env: { NODE_AUTH_TOKEN: expr("secrets.GITHUB_TOKEN") },
|
|
548
|
+
}),
|
|
549
|
+
],
|
|
550
|
+
}),
|
|
551
|
+
// a run by hand from main makes the tag that a push of one would have, where the runner's token may and a person's sandbox may not; it tags a version that is on its registry,
|
|
552
|
+
// however it got there (this workflow's jobs, or a person's first publish of a package that has no trusted publisher yet), and never fails on a tag that is there
|
|
553
|
+
tag: job({
|
|
554
|
+
needs: ["build", ...(sendNpm ? ["publish-npm"] : []), "publish-github"],
|
|
555
|
+
when: "always() && needs.build.result == 'success' && github.ref_type == 'branch'",
|
|
556
|
+
runsOn: "ubuntu-latest",
|
|
557
|
+
timeoutMinutes: 5,
|
|
558
|
+
permissions: { contents: "write" },
|
|
559
|
+
steps: [
|
|
560
|
+
checkout(),
|
|
561
|
+
use(PIN.setupNode, {
|
|
562
|
+
with: {
|
|
563
|
+
"node-version": expr("env.NODE_VERSION"),
|
|
564
|
+
...(sendNpm ? {} : { "registry-url": "https://npm.pkg.github.com", scope: "@intellectual-frontiers" }),
|
|
565
|
+
},
|
|
566
|
+
}),
|
|
567
|
+
run(lines(`version=$(node -p "require('./package.json').version")`, `tag="${l.name}-v$version"`, sendNpm
|
|
568
|
+
? `npm view "@intellectual-frontiers/${l.name}@$version" version >/dev/null 2>&1 || { echo "$version is not on npm: no tag"; exit 1; }`
|
|
569
|
+
: `npm view "@intellectual-frontiers/${l.name}@$version" version >/dev/null 2>&1 || { echo "$version is not on the GitHub package registry: no tag"; exit 1; }`, 'if gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$tag" >/dev/null 2>&1; then', ' echo "$tag is already there"', "else", ' gh api "repos/$GITHUB_REPOSITORY/git/refs" -f "ref=refs/tags/$tag" -f "sha=$GITHUB_SHA"', "fi"), {
|
|
570
|
+
name: "The tag of the version that is published, made once",
|
|
571
|
+
shell: "bash",
|
|
572
|
+
workingDirectory: folder,
|
|
573
|
+
env: { GH_TOKEN: expr("secrets.GITHUB_TOKEN"), ...(sendNpm ? {} : { NODE_AUTH_TOKEN: expr("secrets.GITHUB_TOKEN") }) },
|
|
574
|
+
}),
|
|
575
|
+
],
|
|
576
|
+
}),
|
|
577
|
+
},
|
|
578
|
+
env: { NODE_VERSION },
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
/** Every workflow, the libraries'' made from their manifests, in the order of their files' names. */
|
|
582
|
+
export function workflows(libraries) {
|
|
583
|
+
return [
|
|
584
|
+
...libraries.map(libraryWorkflow),
|
|
585
|
+
...libraries.filter((l) => l.distribution.includes("npm")).map(publishWorkflow),
|
|
586
|
+
docs,
|
|
587
|
+
ifcTypescript,
|
|
588
|
+
tests,
|
|
589
|
+
].sort((a, b) => (a.file < b.file ? -1 : a.file > b.file ? 1 : 0));
|
|
590
|
+
}
|
|
591
|
+
/** The composite actions of `.github/actions/`: the pinned Bun, which every workflow uses. */
|
|
592
|
+
export const ACTIONS = [
|
|
593
|
+
{
|
|
594
|
+
folder: "bun",
|
|
595
|
+
name: "Pinned Bun",
|
|
596
|
+
description: "Bun at the version commons pins (commons/generated/pins.auto.env, commons 0005-typescript-runtime FR-026), fetched with retries, kept only where its SHA-256 is the pinned one, unpacked by IFC TypeScript's own zip reader (commons/libraries/src/install-bun.ts, run by Node) and put on the PATH. Linux, macOS and Windows; no shell script, no Python, no unzip.",
|
|
597
|
+
inputs: { "node-version": { description: "The Node that runs the installer.", default: NODE_VERSION } },
|
|
598
|
+
steps: [
|
|
599
|
+
use(PIN.setupNode, { with: { "node-version": expr("inputs.node-version") } }),
|
|
600
|
+
use(PIN.cache, {
|
|
601
|
+
name: "The pinned Bun's download, kept between runs (the installer checks its SHA-256 whatever the cache holds)",
|
|
602
|
+
with: {
|
|
603
|
+
path: `${expr("runner.temp")}/bun/cache`,
|
|
604
|
+
key: `${expr("runner.os")}-${expr("runner.arch")}-bun-${expr("hashFiles('commons/generated/pins.auto.env')")}`,
|
|
605
|
+
},
|
|
606
|
+
}),
|
|
607
|
+
run("node -e \"const fs=require('fs'),p=require('path'),d='commons/node_modules/@intellectual-frontiers';fs.mkdirSync(d,{recursive:true});for(const n of fs.readdirSync('commons')){const f=p.join('commons',n,'package.json');if(fs.existsSync(f)&&JSON.parse(fs.readFileSync(f,'utf8')).name==='@intellectual-frontiers/'+n)fs.symlinkSync(p.resolve('commons',n),p.join(d,n),'junction')}\"", {
|
|
608
|
+
name: "The libraries of commons, linked in one place that every file of commons finds them (the installer runs before any package is installed; Bun links them again later)",
|
|
609
|
+
shell: "bash",
|
|
610
|
+
}),
|
|
611
|
+
run('node commons/libraries/src/install-bun.ts "$RUNNER_TEMP/bun"', { name: "Bun, pinned and checked", shell: "bash" }),
|
|
612
|
+
],
|
|
613
|
+
},
|
|
614
|
+
];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The typed model of GitHub Actions workflows and the writer of their files (commons 0030-generated-workflows): the values a repository writes its workflows as, and the YAML they are made into. A repository
|
|
3
|
+
* that imports this writes its own workflows as TypeScript and makes `.github/workflows/<name>.auto.yml` from them, as this repository does with `commons/libraries/src/generate-workflows.ts`.
|
|
4
|
+
*
|
|
5
|
+
* Spec: 0001-libraries FR-004
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
export { type CompositeAction, expr, type Expr, type Filter, job, type Job, type Permissions, type Runner, run, type RunStep, type Scalar, type Step, type Strategy, type Triggers, use, type UseStep, validateAction, validateWorkflow, type Workflow, } from "./model.js";
|
|
10
|
+
export { GENERATOR, renderAction, renderWorkflow } from "./render.js";
|