@decohere/ci-tools 0.0.1-dev.20261123.379 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decohere/ci-tools",
3
- "version": "0.0.1-dev.20261123.379",
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",
@@ -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 no `v*` tag (a version only gets one once it
7
- * passed CI and fully shipped), or is under a day old, unless `allowYoung` is set: current pnpm
8
- * skips versions that new and would install an older one. Safe to re-run: packages already there
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,8 +35,11 @@ export function promoteLatest(options) {
35
35
  const log = options.log ?? console.log;
36
36
  const npm = (...args) => run("npm", args);
37
37
 
38
- const version =
39
- options.version?.trim() || npm("view", LAUNCH_PACKAGE, "dist-tags.dev").stdout.trim();
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;
@@ -44,14 +47,20 @@ export function promoteLatest(options) {
44
47
  log(`Promoting ${version} to latest on ${packages.length} packages`);
45
48
 
46
49
  // Once a stable version is out, latest belongs to releases: see "Stable release" in docs/contributing/ci.
47
- const current = /^latest: (.+)$/m.exec(npm("dist-tag", "ls", LAUNCH_PACKAGE).stdout)?.[1];
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
- const tag = run("git", ["tag", "--list", `v${version}`]).stdout.trim();
54
- if (tag !== `v${version}`) {
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
- /** `npm dist-tag ls` reads fresh; `npm view` can lag for a minute or so after a move. */
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
+ });