@decohere/ci-tools 0.0.1-dev.20261123.374 → 0.0.1-dev.20261123.401
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/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @decohere/ci-tools
|
|
2
|
+
|
|
3
|
+
Node scripts the repo's GitHub workflows and root `package.json` scripts run. Plain `.mjs`, run from source with `node`. One folder per job, under `src/`:
|
|
4
|
+
|
|
5
|
+
- `audit/`: summarize `npm audit`, fail on findings (`enforce`), and open or close the audit issue (`upsert-issue`). Run by CI (`ci.yml`) and the nightly `npm-audit.yml`.
|
|
6
|
+
- `badges/`: the CI status badge (`ci-status`). Run by `pages.yml`, `bench.yml` and `clear-benchmark-history.yml`.
|
|
7
|
+
- `bench/`: build benchmarks (`pnpm bench`, `pnpm bench:save`, `pnpm perf:trace`), and the nightly run and its regression issues. Run by `bench.yml`.
|
|
8
|
+
- `changeset/`: changeset status and changelog scripts behind `pnpm changeset:check` and `pnpm version:aggregate`. No workflow runs them.
|
|
9
|
+
- `coverage/`: the coverage report (`pnpm test:coverage:report`) and its badge, run by `pages.yml`.
|
|
10
|
+
- `github/`: GitHub and npm checks (`ensure-metadata` is used by `publish-verify`): `first-publish-check` (CI), `publish-verify` (`publish.yml`), `failure-report` (the `failure-report` action, used by `ci.yml` and `clear-benchmark-history.yml`), and `npm-bootstrap` (`pnpm npm:bootstrap`, run by hand).
|
|
11
|
+
- `lib/`: what the scripts share: SVG badges, LCOV parsing, GitHub issues, the workspace's packages. Nothing runs it directly.
|
|
12
|
+
- `pages/`: the GitHub Pages site (badges, bench history, the artifact). Run by `pages.yml`, `bench.yml` and `clear-benchmark-history.yml`.
|
|
13
|
+
- `release/`: publishing: `check-patch-release`, `find-publish-base` and `restamp-build` (`publish.yml`), `promote-latest` (`promote-latest.yml`, the "Promote to latest" workflow), and `publish-to-temporary-registry` (the `verify-release` action).
|
|
14
|
+
|
|
15
|
+
## Working on this package
|
|
16
|
+
|
|
17
|
+
Tests are in `tests/`, in folders named like the `src/` folders they test: `*.test.mjs` and, under `release/`, `*.spec.ts`. `pnpm test` runs both. `tests/github/ci-workflow.test.mjs` and `publish-workflow.test.mjs` check the workflow files themselves. There is no canonical suite for ci-tools in the [testing table](../../docs/contributing/testing/README.md#canonical-suite-ownership).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decohere/ci-tools",
|
|
3
|
-
"version": "0.0.1-dev.20261123.
|
|
3
|
+
"version": "0.0.1-dev.20261123.401",
|
|
4
4
|
"description": "CI utility scripts for badge generation, coverage reporting, pages artifact assembly, and GitHub API tooling",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -57,7 +57,9 @@ export function runDesignCheck(options = {}) {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
log(
|
|
60
|
+
log(
|
|
61
|
+
`design: ${total(counts)} breaks of ADR 0027 (docs/contributing/adr/0027-code-design.md).`,
|
|
62
|
+
);
|
|
61
63
|
if (rose.length > 0) {
|
|
62
64
|
log(rose.join("\n"));
|
|
63
65
|
log(
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Points npm's `latest` tag at a version on every public @decohere package. Run by
|
|
4
4
|
* `promote-latest.yml`, which authenticates over OIDC.
|
|
5
5
|
*
|
|
6
|
-
* Refuses a version that isn't on every package, has
|
|
7
|
-
* passed CI and fully shipped), or is under
|
|
8
|
-
* skips versions that new and would install an
|
|
9
|
-
* are skipped.
|
|
6
|
+
* With no version, takes what `dev` points at. Refuses a version that isn't on every package, has
|
|
7
|
+
* no `v*` tag on origin (a version only gets one once it passed CI and fully shipped), or is under
|
|
8
|
+
* a day old, unless `allowYoung` is set: current pnpm skips versions that new and would install an
|
|
9
|
+
* older one. Safe to re-run: packages already there are skipped.
|
|
10
10
|
*/
|
|
11
11
|
import { spawnSync } from "node:child_process";
|
|
12
12
|
import { resolve } from "node:path";
|
|
@@ -35,23 +35,32 @@ export function promoteLatest(options) {
|
|
|
35
35
|
const log = options.log ?? console.log;
|
|
36
36
|
const npm = (...args) => run("npm", args);
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
/** `npm dist-tag ls` reads fresh; `npm view` can lag for a minute or more after a move. */
|
|
39
|
+
const distTag = (name, tag) =>
|
|
40
|
+
new RegExp(`^${tag}: (.+)$`, "m").exec(npm("dist-tag", "ls", name).stdout)?.[1]?.trim();
|
|
41
|
+
|
|
42
|
+
const version = options.version?.trim() || distTag(LAUNCH_PACKAGE, "dev");
|
|
40
43
|
if (!version) {
|
|
41
44
|
log(`Could not read the dev tag of ${LAUNCH_PACKAGE}. Nothing moved.`);
|
|
42
45
|
return 1;
|
|
43
46
|
}
|
|
44
47
|
log(`Promoting ${version} to latest on ${packages.length} packages`);
|
|
45
48
|
|
|
46
|
-
// Once a stable version is out, latest belongs to releases: see "Stable release" in docs/ci.
|
|
47
|
-
const current =
|
|
49
|
+
// Once a stable version is out, latest belongs to releases: see "Stable release" in docs/contributing/ci.
|
|
50
|
+
const current = distTag(LAUNCH_PACKAGE, "latest");
|
|
48
51
|
if (current != null && !current.includes("-") && version.includes("-")) {
|
|
49
52
|
log(`latest is the stable ${current}, and ${version} is a dev version. Nothing moved.`);
|
|
50
53
|
return 1;
|
|
51
54
|
}
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
// Asks origin: the workflow's checkout is shallow and holds only the tip commit's tags.
|
|
57
|
+
const ref = `refs/tags/v${version}`;
|
|
58
|
+
const remote = run("git", ["ls-remote", "--tags", "origin", ref]);
|
|
59
|
+
if (remote.status !== 0) {
|
|
60
|
+
log("Could not read the tags on origin. Nothing moved.");
|
|
61
|
+
return 1;
|
|
62
|
+
}
|
|
63
|
+
if (!remote.stdout.split("\n").some((line) => line.split("\t")[1] === ref)) {
|
|
55
64
|
log(`${version} has no v${version} tag, so it didn't fully ship. Nothing moved.`);
|
|
56
65
|
return 1;
|
|
57
66
|
}
|
|
@@ -84,13 +93,7 @@ export function promoteLatest(options) {
|
|
|
84
93
|
}
|
|
85
94
|
}
|
|
86
95
|
|
|
87
|
-
|
|
88
|
-
const onLatest = (name) => {
|
|
89
|
-
const line = npm("dist-tag", "ls", name)
|
|
90
|
-
.stdout.split("\n")
|
|
91
|
-
.find((entry) => entry.startsWith("latest:"));
|
|
92
|
-
return line?.slice("latest:".length).trim() === version;
|
|
93
|
-
};
|
|
96
|
+
const onLatest = (name) => distTag(name, "latest") === version;
|
|
94
97
|
|
|
95
98
|
const failed = [];
|
|
96
99
|
for (const name of packages) {
|
|
@@ -39,3 +39,28 @@ describe("ci.yml and the merge queue", () => {
|
|
|
39
39
|
);
|
|
40
40
|
});
|
|
41
41
|
});
|
|
42
|
+
|
|
43
|
+
describe("the release build passed between jobs", () => {
|
|
44
|
+
const workflows = ["ci.yml", "publish.yml"].map((name) => ({
|
|
45
|
+
name,
|
|
46
|
+
yml: fs.readFileSync(
|
|
47
|
+
fileURLToPath(new URL(`../../../../.github/workflows/${name}`, import.meta.url)),
|
|
48
|
+
"utf8",
|
|
49
|
+
),
|
|
50
|
+
}));
|
|
51
|
+
|
|
52
|
+
// upload-artifact leaves hidden files out by default. The scaffolder's templates are mostly
|
|
53
|
+
// dot-files (.devcontainer, .github, .vscode), so without them every new app would lack them,
|
|
54
|
+
// and Publish ships what verify-release tested: the uploaded build.
|
|
55
|
+
it("keeps its hidden files, such as the scaffolder's .devcontainer templates", () => {
|
|
56
|
+
const uploads = workflows.flatMap(({ name, yml }) =>
|
|
57
|
+
[...yml.matchAll(/uses: actions\/upload-artifact@\S+\n {8}with:\n((?: {10}.*\n)+)/g)]
|
|
58
|
+
.map((match) => ({ name, step: match[1] }))
|
|
59
|
+
.filter(({ step }) => /path: dist\/release\//.test(step)),
|
|
60
|
+
);
|
|
61
|
+
expect(uploads.map(({ name }) => name).toSorted()).toEqual(["ci.yml", "publish.yml"]);
|
|
62
|
+
for (const { name, step } of uploads) {
|
|
63
|
+
expect(step, name).toMatch(/include-hidden-files: true/);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|