Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,34 @@ permissions:
contents: read

jobs:
gate:
if: '!cancelled()'
runs-on: arc-moddrop
timeout-minutes: 5
permissions:
actions: read
contents: read
outputs:
reuse: ${{ steps.proof.outputs.reuse }}
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version-file: .node-version
- name: Find successful verification of this tree
id: proof
env:
GH_TOKEN: ${{ github.token }}
run: node scripts/verify-proof.ts

verify:
needs: gate
if: "!cancelled() && (needs.gate.result != 'success' || needs.gate.outputs.reuse != 'true')"
uses: ./.github/workflows/verify.yml

build:
needs: verify
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main'
needs: [gate, verify]
if: "!cancelled() && ((needs.gate.result == 'success' && needs.gate.outputs.reuse == 'true' && needs.verify.result == 'skipped') || needs.verify.result == 'success') && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')"
runs-on: arc-moddrop
permissions:
contents: read
Expand Down Expand Up @@ -69,3 +91,16 @@ jobs:
NEXT_PUBLIC_TLDRAW_LICENSE_KEY=${{ secrets.NEXT_PUBLIC_TLDRAW_LICENSE_KEY }}
secrets: |
glitchtip_auth_token=${{ secrets.GLITCHTIP_AUTH_TOKEN }}

smoke:
needs: build
if: "!cancelled() && needs.build.result == 'success' && startsWith(github.ref, 'refs/tags/v')"
runs-on: arc-moddrop
timeout-minutes: 35
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version-file: .node-version
- name: Wait for Flux rollout and check production
run: node scripts/rollout-smoke.ts https://moddrop.live "${GITHUB_REF_NAME#v}"
24 changes: 24 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,27 @@ jobs:
- run: pnpm install --frozen-lockfile --ignore-scripts
- run: pnpm exec playwright install --with-deps chromium
- run: bash scripts/verify.sh
proof:
needs: verify
continue-on-error: true
runs-on: arc-moddrop
Comment thread
beastyrabbit marked this conversation as resolved.
Resolved
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Record verified checkout
id: proof
run: |
commit=$(git rev-parse HEAD)
tree=$(git rev-parse 'HEAD^{tree}')
[[ "$commit" =~ ^[0-9a-fA-F]{40}$ ]]
[[ "$tree" =~ ^[0-9a-fA-F]{40}$ ]]
printf '{"commit":"%s","tree":"%s"}\n' "$commit" "$tree" > verify-proof.json
printf 'tree=%s\n' "$tree" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v7
with:
name: verify-proof-${{ steps.proof.outputs.tree }}
path: verify-proof.json
overwrite: true
if-no-files-found: error
retention-days: 14
4 changes: 4 additions & 0 deletions backend/stream-canvas/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ app.onError((error, c) => {
});
app.use("*", cors({ origin: config.corsOrigins }));
app.get("/health", (c) => c.json({ status: "ok" }));
app.get("/version", (c) => {
c.header("Cache-Control", "no-store");
return c.json({ release: config.appRelease });
});
app.get("/ready", async (c) => {
if (!leaderState.isLeader) {
return c.json({ status: "standby", role: "standby" }, 503);
Expand Down
1 change: 1 addition & 0 deletions backend/stream-canvas/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const uploadsDir = process.env.UPLOADS_DIR ?? "data/uploads";

export const config = {
nodeEnv,
appRelease: process.env.APP_RELEASE || null,
port: numberEnv("PORT", 8003, { min: 1, max: 65535 }),
databaseUrl:
process.env.DATABASE_URL ??
Expand Down
25 changes: 25 additions & 0 deletions backend/stream-canvas/src/version.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import assert from "node:assert/strict";
import test from "node:test";

// Match the app integration tests: tldraw disables its browser channel in test mode.
process.env.NODE_ENV = "test";
const { app } = await import("./app.ts");
const { config } = await import("./config.ts");
const { closeDatabase } = await import("./db.ts");
const { leaderState } = await import("./leader.ts");

test("version is public and uncached on standbys, with null when unset", async (t) => {
t.after(closeDatabase);
assert.equal(leaderState.isLeader, false);
const original = config.appRelease;
t.after(() => {
Object.defineProperty(config, "appRelease", { value: original });
});
for (const release of ["moddrop@0.9.0", null]) {
Object.defineProperty(config, "appRelease", { value: release });
const response = await app.request("/version");
assert.equal(response.status, 200);
assert.equal(response.headers.get("Cache-Control"), "no-store");
assert.deepEqual(await response.json(), { release });
}
});
29 changes: 24 additions & 5 deletions docs/releasing.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
# Release and deployment notes

Pushing a `vX.Y.Z` tag runs the GitHub container-image workflow. The workflow
verifies the repository and builds the frontend
and stream-canvas images on the `arc-moddrop` runner. The current workflow
publishes both images to GHCR; check the downstream deployment configuration
before assuming a tag has reached production.
Pushing a `vX.Y.Z` tag runs the GitHub container-image workflow. After the full
suite passes, a separate job that runs no repository code records the checked-out
commit and tree in a JSON proof artifact retained for 14 days. Recording is
best-effort; failure only means the next release runs full Verify.
The release gate reuses proof only for the exact release
tree from a completed, successful Verify run in this repository. Proof is reused
only when GitHub's record of the Verify run's head commit has the release tree.
The artifact is only an index. PR runs whose merge tree differs from their head
tree fall back to full verification. Fork PR runs cannot supply proof.
Missing, expired, invalid or unavailable proof falls back
to the full Verify workflow. The gate logs the fallback reason as a notice,
or a warning for API, download and unzip errors. Both production images still
build on `arc-moddrop` and publish to GHCR after verification succeeds.

For tags, a rollout smoke job waits up to 30 minutes for Flux to deploy both
components. It polls `/telemetry-config` and `/canvas-api/version` at
`https://moddrop.live` every 20 seconds until both report `moddrop@<tag version>`,
then retries `/` until successful and checks `/canvas-api/ready` for HTTP 200.
Both checks share a one-minute retry window. The overall
deadline includes readiness retries. A newer semver on either component marks
the release as superseded and skips remaining checks. Timeouts fail with each
endpoint's last observation. For manual use, run
`node scripts/rollout-smoke.ts <base-url> <version> [timeout-ms]`; the timeout
also accepts `ROLLOUT_TIMEOUT_MS`.

The frontend image receives its public configuration at build time. The GitHub
repository variable `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` must exist and contain the
Expand Down
109 changes: 98 additions & 11 deletions scripts/delivery-changes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,104 @@ test("GitHub releases use the PR verification gate before production actions", (
expect(verification.on).toHaveProperty("workflow_call");
expect(verification.jobs.verify["runs-on"]).toBe("arc-moddrop");
const job = workflow.jobs.build;
expect(job.needs).toBe("verify");
const allowed = (ref: string) =>
Function(
"github",
"startsWith",
`return (${job.if})`,
)({ ref }, (value: string, prefix: string) => value.startsWith(prefix));
expect(allowed("refs/heads/feature")).toBe(false);
expect(allowed("refs/heads/main")).toBe(true);
expect(allowed("refs/tags/v0.6.2")).toBe(true);
expect(job.if).not.toContain("always()");
expect(job.needs).toEqual(["gate", "verify"]);
expect(workflow.jobs.verify.needs).toBe("gate");
expect(workflow.jobs.smoke.needs).toBe("build");
expect(workflow.jobs.gate.permissions).toEqual({
actions: "read",
contents: "read",
});
expect(verification.jobs.verify.services.postgres).toBeDefined();
const steps = verification.jobs.verify.steps;
const verifyIndex = steps.findIndex(
(step: { run?: string }) => step.run === "bash scripts/verify.sh",
);
expect(verifyIndex).toBeGreaterThan(-1);
expect(steps.at(-1)).toEqual({ run: "bash scripts/verify.sh" });
for (const step of steps) {
expect(step.uses ?? "").not.toMatch(/^actions\/upload-artifact@/);
expect(step.id).not.toBe("proof");
expect(step.run ?? "").not.toContain("verify-proof");
}
expect(verification.permissions).toEqual({ contents: "read" });
expect(verification.jobs.proof).toEqual({
needs: "verify", // Default success() requires the full suite to pass.
"continue-on-error": true,
"runs-on": "arc-moddrop",
steps: [
{
uses: "actions/checkout@v7",
with: { "persist-credentials": false },
},
{
name: "Record verified checkout",
id: "proof",
run: expect.stringContaining("git rev-parse 'HEAD^{tree}'"),
},
{
uses: "actions/upload-artifact@v7",
with: {
// biome-ignore lint/suspicious/noTemplateCurlyInString: GitHub Actions expression.
name: "verify-proof-${{ steps.proof.outputs.tree }}",
path: "verify-proof.json",
overwrite: true,
"if-no-files-found": "error",
"retention-days": 14,
},
},
],
});

const results = ["success", "failure", "cancelled", "skipped"];
function checkVerification(gate: string, reuse: string, verify: string) {
for (const cancelled of [true, false])
for (const ref of [
"refs/heads/feature",
"refs/heads/main",
"refs/tags/v0.6.2",
"refs/tags/other",
"refs/pull/1/merge",
]) {
const needs = {
gate: { result: gate, outputs: { reuse } },
verify: { result: verify },
};
const evaluate = (condition: string, dependencies: object = needs) =>
Function(
"needs",
"github",
"cancelled",
"always",
"startsWith",
`return (${condition});`,
)(
dependencies,
{ ref },
() => cancelled,
() => true,
(value: string, prefix: string) => value.startsWith(prefix),
);
expect(evaluate(workflow.jobs.gate.if)).toBe(!cancelled);
expect(evaluate(workflow.jobs.verify.if)).toBe(
!cancelled && (gate !== "success" || reuse !== "true"),
);
const safe =
!cancelled &&
(ref === "refs/heads/main" || ref.startsWith("refs/tags/v")) &&
(verify === "success" ||
(gate === "success" && reuse === "true" && verify === "skipped"));
expect(evaluate(job.if)).toBe(safe);
for (const build of results)
expect(
evaluate(workflow.jobs.smoke.if, { build: { result: build } }),
).toBe(
!cancelled && build === "success" && ref.startsWith("refs/tags/v"),
);
}
}
for (const gate of results)
for (const reuse of ["true", "false", ""])
for (const verify of results) checkVerification(gate, reuse, verify);
});

test.each(["pnpm-lock.yaml", "pnpm-workspace.yaml", "package.json", ".npmrc"])(
Expand Down
Loading