diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 5700bddf..6373dfd6 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -258,7 +258,9 @@ jobs: persist-credentials: false ref: ${{ needs.release-context.outputs.orchestration_ref }} path: .release-orchestration - sparse-checkout: cli/scripts/publish-release.ts + sparse-checkout: | + cli/scripts/publish-release.ts + cli/src/lib/object.ts sparse-checkout-cone-mode: false - name: Install Bun diff --git a/cli/scripts/publish-release.ts b/cli/scripts/publish-release.ts index 187a1d75..4a4c8d62 100644 --- a/cli/scripts/publish-release.ts +++ b/cli/scripts/publish-release.ts @@ -1,5 +1,5 @@ import { basename, join, resolve } from "node:path"; -import { isRecord } from "@/lib/object.ts"; +import { isRecord } from "../src/lib/object.ts"; export type NpmVersionLookup = { status: "published"; version: string } | { status: "missing" }; diff --git a/cli/scripts/release.test.ts b/cli/scripts/release.test.ts index 751e3cda..65b60186 100644 --- a/cli/scripts/release.test.ts +++ b/cli/scripts/release.test.ts @@ -1,7 +1,7 @@ import { afterEach, describe, expect, test } from "bun:test"; -import { mkdtemp, readFile, rm } from "node:fs/promises"; +import { copyFile, mkdir, mkdtemp, readFile, rm } from "node:fs/promises"; import { tmpdir } from "node:os"; -import { join } from "node:path"; +import { dirname, join } from "node:path"; import { assertReleaseTag, assertToolchain, @@ -575,7 +575,9 @@ describe("release infrastructure wiring", () => { expect(releaseCheckout?.with?.ref).toContain("release_ref"); expect(orchestrationCheckout?.with?.ref).toContain("orchestration_ref"); expect(orchestrationCheckout?.with?.path).toBe(".release-orchestration"); - expect(orchestrationCheckout?.with?.["sparse-checkout"]).toBe("cli/scripts/publish-release.ts"); + expect(orchestrationCheckout?.with?.["sparse-checkout"]).toBe( + "cli/scripts/publish-release.ts\ncli/src/lib/object.ts\n", + ); const orderedSteps = [ "Download tested release binaries", @@ -608,6 +610,37 @@ describe("release infrastructure wiring", () => { } }); + test("builds release publication from only the orchestration checkout", async () => { + const workflow = await readWorkflow("release-please.yml"); + const checkout = workflow.jobs["release-artifacts"]?.steps?.find( + ({ name }) => name === "Check out current release orchestration", + ); + const sparseCheckout = checkout?.with?.["sparse-checkout"]; + if (typeof sparseCheckout !== "string") { + throw new Error("Release orchestration sparse checkout is missing"); + } + const paths = sparseCheckout + .trim() + .split("\n") + .map((path) => path.trim()); + const directory = await mkdtemp(join(tmpdir(), "altertable-release-orchestration-test-")); + try { + for (const path of paths) { + const destination = join(directory, path); + await mkdir(dirname(destination), { recursive: true }); + await copyFile(join(repositoryRoot, path), destination); + } + const result = await Bun.build({ + entrypoints: [join(directory, "cli/scripts/publish-release.ts")], + outdir: join(directory, "dist"), + target: "bun", + }); + expect(result.success).toBe(true); + } finally { + await rm(directory, { recursive: true, force: true }); + } + }); + test("retains recoverable release binaries longer than diagnostic artifacts", async () => { const releaseWorkflow = await readWorkflow("release-please.yml"); const verificationWorkflow = await readWorkflow("verify.yml");