From 55d3c294be3a936c6711c8c436ffdfb8fd78180f Mon Sep 17 00:00:00 2001 From: lvbt-bot Date: Fri, 27 Nov 2026 22:46:29 +0000 Subject: [PATCH] chore: update LVBT repository standard to v0.8.0 Apply the reviewed v0.8.0 release with its own updater. --- .claude/settings.json | 2 +- .lvbt/web-platform.json | 6 +- .../examples/with-astro/.claude/settings.json | 2 +- .../with-astro/.github/workflows/ci.yml | 4 +- .../with-astro/apps/deploy/package.json | 4 +- .../with-astro/apps/site/package.json | 8 +- .../examples/with-astro/package.json | 6 +- .../with-vite-react/.claude/settings.json | 2 +- .../with-vite-react/.github/workflows/ci.yml | 4 +- .../with-vite-react/apps/app/package.json | 8 +- .../with-vite-react/apps/deploy/package.json | 4 +- .../examples/with-vite-react/package.json | 6 +- .lvbt/web-platform/packages/cli/package.json | 2 +- .../.claude-plugin/plugin.json | 2 +- .../.codex-plugin/plugin.json | 2 +- .../packages/eslint-config/package.json | 2 +- .../packages/playwright-config/package.json | 2 +- .../packages/prettier-config/package.json | 2 +- .../packages/typescript-config/package.json | 2 +- .../packages/vitest-config/package.json | 2 +- .../packages/web-platform/package.json | 2 +- .../web-platform/src/doctor-github.ts | 58 ++++++++----- .../web-platform/src/github-governance.ts | 14 ++- .../web-platform/src/provision-ruleset.ts | 8 +- .../web-platform/src/release-candidate.ts | 38 ++++++-- .../packages/web-platform/src/ruleset.ts | 17 ++++ .../web-platform/tests/doctor-github.test.ts | 22 ++++- .../tests/provision-ruleset.test.ts | 30 +++++++ .../tests/release-candidate.test.ts | 86 +++++++++++++++++++ .../tests/release-publish-workflow.test.ts | 19 ++++ .lvbt/web-platform/standards/ruleset.json | 12 +++ 31 files changed, 304 insertions(+), 74 deletions(-) diff --git a/.claude/settings.json b/.claude/settings.json index 362329c..106001b 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -4,7 +4,7 @@ "source": { "source": "github", "repo": "LasVegasForTransit/repository-tooling", - "ref": "v0.7.9" + "ref": "v0.8.0" } } }, diff --git a/.lvbt/web-platform.json b/.lvbt/web-platform.json index fbde7c8..c073ba7 100644 --- a/.lvbt/web-platform.json +++ b/.lvbt/web-platform.json @@ -1,9 +1,9 @@ { "formatVersion": 1, "preset": "lvbt-web", - "release": "v0.7.9", - "commit": "5ebebb6dd19040acae98054e39ff794ae3fc8660", - "contentHash": "d2fa90baa7effc16137c1dada07bdd788ad53bfe489c1d44e0a865269466356d", + "release": "v0.8.0", + "commit": "5db2f70bc9926a5a854e1fced7b3830c5081e008", + "contentHash": "90f2cda55c623b381b464cdca76806e6b72b5a79209a47b9b692417e9f999356", "executables": [ "examples/with-astro/.githooks/commit-msg", "examples/with-astro/.githooks/pre-commit", diff --git a/.lvbt/web-platform/examples/with-astro/.claude/settings.json b/.lvbt/web-platform/examples/with-astro/.claude/settings.json index 362329c..106001b 100644 --- a/.lvbt/web-platform/examples/with-astro/.claude/settings.json +++ b/.lvbt/web-platform/examples/with-astro/.claude/settings.json @@ -4,7 +4,7 @@ "source": { "source": "github", "repo": "LasVegasForTransit/repository-tooling", - "ref": "v0.7.9" + "ref": "v0.8.0" } } }, diff --git a/.lvbt/web-platform/examples/with-astro/.github/workflows/ci.yml b/.lvbt/web-platform/examples/with-astro/.github/workflows/ci.yml index 5e52570..d3d570c 100644 --- a/.lvbt/web-platform/examples/with-astro/.github/workflows/ci.yml +++ b/.lvbt/web-platform/examples/with-astro/.github/workflows/ci.yml @@ -5,6 +5,7 @@ name: CI on: pull_request: branches: [main] + merge_group: workflow_call: workflow_dispatch: @@ -13,7 +14,8 @@ permissions: concurrency: group: ci-${{ github.ref }} - cancel-in-progress: true + # Cancelling a running merge-group check drops the queued pull request. + cancel-in-progress: ${{ github.event_name != 'merge_group' }} jobs: validate: diff --git a/.lvbt/web-platform/examples/with-astro/apps/deploy/package.json b/.lvbt/web-platform/examples/with-astro/apps/deploy/package.json index 5825430..0f6b54f 100644 --- a/.lvbt/web-platform/examples/with-astro/apps/deploy/package.json +++ b/.lvbt/web-platform/examples/with-astro/apps/deploy/package.json @@ -10,9 +10,9 @@ "validate": "cf deploy --dry-run" }, "devDependencies": { - "@lasvegasfortransit/eslint-config": "0.7.9", + "@lasvegasfortransit/eslint-config": "0.8.0", "@lasvegasfortransit/site": "workspace:*", - "@lasvegasfortransit/typescript-config": "0.7.9", + "@lasvegasfortransit/typescript-config": "0.8.0", "cf": "catalog:", "eslint": "catalog:", "typescript": "catalog:", diff --git a/.lvbt/web-platform/examples/with-astro/apps/site/package.json b/.lvbt/web-platform/examples/with-astro/apps/site/package.json index 98d6c91..4e16387 100644 --- a/.lvbt/web-platform/examples/with-astro/apps/site/package.json +++ b/.lvbt/web-platform/examples/with-astro/apps/site/package.json @@ -23,10 +23,10 @@ }, "devDependencies": { "@astrojs/check": "catalog:", - "@lasvegasfortransit/eslint-config": "0.7.9", - "@lasvegasfortransit/playwright-config": "0.7.9", - "@lasvegasfortransit/typescript-config": "0.7.9", - "@lasvegasfortransit/vitest-config": "0.7.9", + "@lasvegasfortransit/eslint-config": "0.8.0", + "@lasvegasfortransit/playwright-config": "0.8.0", + "@lasvegasfortransit/typescript-config": "0.8.0", + "@lasvegasfortransit/vitest-config": "0.8.0", "@playwright/test": "catalog:", "@types/node": "catalog:", "eslint": "catalog:", diff --git a/.lvbt/web-platform/examples/with-astro/package.json b/.lvbt/web-platform/examples/with-astro/package.json index 4792a77..6862f9a 100644 --- a/.lvbt/web-platform/examples/with-astro/package.json +++ b/.lvbt/web-platform/examples/with-astro/package.json @@ -28,8 +28,8 @@ "*": "prettier --write --ignore-unknown" }, "devDependencies": { - "@lasvegasfortransit/cli": "0.7.9", - "@lasvegasfortransit/prettier-config": "0.7.9", + "@lasvegasfortransit/cli": "0.8.0", + "@lasvegasfortransit/prettier-config": "0.8.0", "lint-staged": "catalog:", "markdownlint-cli2": "catalog:", "markdownlint-rule-relative-links": "catalog:", @@ -39,7 +39,7 @@ "typescript": "catalog:", "wrangler": "catalog:", "tsx": "catalog:", - "@lasvegasfortransit/web-platform": "0.7.9" + "@lasvegasfortransit/web-platform": "0.8.0" }, "packageManager": "pnpm@11.25.0", "engines": { diff --git a/.lvbt/web-platform/examples/with-vite-react/.claude/settings.json b/.lvbt/web-platform/examples/with-vite-react/.claude/settings.json index 362329c..106001b 100644 --- a/.lvbt/web-platform/examples/with-vite-react/.claude/settings.json +++ b/.lvbt/web-platform/examples/with-vite-react/.claude/settings.json @@ -4,7 +4,7 @@ "source": { "source": "github", "repo": "LasVegasForTransit/repository-tooling", - "ref": "v0.7.9" + "ref": "v0.8.0" } } }, diff --git a/.lvbt/web-platform/examples/with-vite-react/.github/workflows/ci.yml b/.lvbt/web-platform/examples/with-vite-react/.github/workflows/ci.yml index 5e52570..d3d570c 100644 --- a/.lvbt/web-platform/examples/with-vite-react/.github/workflows/ci.yml +++ b/.lvbt/web-platform/examples/with-vite-react/.github/workflows/ci.yml @@ -5,6 +5,7 @@ name: CI on: pull_request: branches: [main] + merge_group: workflow_call: workflow_dispatch: @@ -13,7 +14,8 @@ permissions: concurrency: group: ci-${{ github.ref }} - cancel-in-progress: true + # Cancelling a running merge-group check drops the queued pull request. + cancel-in-progress: ${{ github.event_name != 'merge_group' }} jobs: validate: diff --git a/.lvbt/web-platform/examples/with-vite-react/apps/app/package.json b/.lvbt/web-platform/examples/with-vite-react/apps/app/package.json index 9877bd3..a38e41a 100644 --- a/.lvbt/web-platform/examples/with-vite-react/apps/app/package.json +++ b/.lvbt/web-platform/examples/with-vite-react/apps/app/package.json @@ -19,10 +19,10 @@ "react-dom": "catalog:" }, "devDependencies": { - "@lasvegasfortransit/eslint-config": "0.7.9", - "@lasvegasfortransit/playwright-config": "0.7.9", - "@lasvegasfortransit/typescript-config": "0.7.9", - "@lasvegasfortransit/vitest-config": "0.7.9", + "@lasvegasfortransit/eslint-config": "0.8.0", + "@lasvegasfortransit/playwright-config": "0.8.0", + "@lasvegasfortransit/typescript-config": "0.8.0", + "@lasvegasfortransit/vitest-config": "0.8.0", "@playwright/test": "catalog:", "@tailwindcss/vite": "catalog:", "@types/node": "catalog:", diff --git a/.lvbt/web-platform/examples/with-vite-react/apps/deploy/package.json b/.lvbt/web-platform/examples/with-vite-react/apps/deploy/package.json index 06e4eca..3023b5d 100644 --- a/.lvbt/web-platform/examples/with-vite-react/apps/deploy/package.json +++ b/.lvbt/web-platform/examples/with-vite-react/apps/deploy/package.json @@ -10,9 +10,9 @@ "validate": "cf deploy --dry-run" }, "devDependencies": { - "@lasvegasfortransit/eslint-config": "0.7.9", + "@lasvegasfortransit/eslint-config": "0.8.0", "@lasvegasfortransit/app": "workspace:*", - "@lasvegasfortransit/typescript-config": "0.7.9", + "@lasvegasfortransit/typescript-config": "0.8.0", "cf": "catalog:", "eslint": "catalog:", "typescript": "catalog:", diff --git a/.lvbt/web-platform/examples/with-vite-react/package.json b/.lvbt/web-platform/examples/with-vite-react/package.json index 0f499a9..bc0ef39 100644 --- a/.lvbt/web-platform/examples/with-vite-react/package.json +++ b/.lvbt/web-platform/examples/with-vite-react/package.json @@ -28,8 +28,8 @@ "*": "prettier --write --ignore-unknown" }, "devDependencies": { - "@lasvegasfortransit/cli": "0.7.9", - "@lasvegasfortransit/prettier-config": "0.7.9", + "@lasvegasfortransit/cli": "0.8.0", + "@lasvegasfortransit/prettier-config": "0.8.0", "lint-staged": "catalog:", "markdownlint-cli2": "catalog:", "markdownlint-rule-relative-links": "catalog:", @@ -38,7 +38,7 @@ "typescript": "catalog:", "wrangler": "catalog:", "tsx": "catalog:", - "@lasvegasfortransit/web-platform": "0.7.9" + "@lasvegasfortransit/web-platform": "0.8.0" }, "packageManager": "pnpm@11.25.0", "engines": { diff --git a/.lvbt/web-platform/packages/cli/package.json b/.lvbt/web-platform/packages/cli/package.json index b34f643..3ec492d 100644 --- a/.lvbt/web-platform/packages/cli/package.json +++ b/.lvbt/web-platform/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@lasvegasfortransit/cli", - "version": "0.7.9", + "version": "0.8.0", "description": "The lvbt command every LVBT repository runs for bootstrap, preflight, and deploy, plus the production platform setup, the shared git hooks, and the lvbt-contributions agent plugin.", "license": "MIT", "type": "module", diff --git a/.lvbt/web-platform/packages/cli/plugins/lvbt-contributions/.claude-plugin/plugin.json b/.lvbt/web-platform/packages/cli/plugins/lvbt-contributions/.claude-plugin/plugin.json index c2e7e93..e34a1e0 100644 --- a/.lvbt/web-platform/packages/cli/plugins/lvbt-contributions/.claude-plugin/plugin.json +++ b/.lvbt/web-platform/packages/cli/plugins/lvbt-contributions/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "lvbt-contributions", - "version": "0.7.9", + "version": "0.8.0", "description": "Create readable LVBT contributions and reconcile trusted audit and recurring issues through the organization workflow.", "author": { "name": "Las Vegans for Better Transit", diff --git a/.lvbt/web-platform/packages/cli/plugins/lvbt-contributions/.codex-plugin/plugin.json b/.lvbt/web-platform/packages/cli/plugins/lvbt-contributions/.codex-plugin/plugin.json index 25f52f2..7a74d75 100644 --- a/.lvbt/web-platform/packages/cli/plugins/lvbt-contributions/.codex-plugin/plugin.json +++ b/.lvbt/web-platform/packages/cli/plugins/lvbt-contributions/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "lvbt-contributions", - "version": "0.7.9", + "version": "0.8.0", "description": "Create readable LVBT contributions and reconcile trusted audit and recurring issues through the organization workflow.", "author": { "name": "Las Vegans for Better Transit", diff --git a/.lvbt/web-platform/packages/eslint-config/package.json b/.lvbt/web-platform/packages/eslint-config/package.json index c7c9668..36d4822 100644 --- a/.lvbt/web-platform/packages/eslint-config/package.json +++ b/.lvbt/web-platform/packages/eslint-config/package.json @@ -1,6 +1,6 @@ { "name": "@lasvegasfortransit/eslint-config", - "version": "0.7.9", + "version": "0.8.0", "description": "The ESLint configurations every LVBT repository uses.", "license": "MIT", "type": "module", diff --git a/.lvbt/web-platform/packages/playwright-config/package.json b/.lvbt/web-platform/packages/playwright-config/package.json index 7e097aa..c0ea5d7 100644 --- a/.lvbt/web-platform/packages/playwright-config/package.json +++ b/.lvbt/web-platform/packages/playwright-config/package.json @@ -1,6 +1,6 @@ { "name": "@lasvegasfortransit/playwright-config", - "version": "0.7.9", + "version": "0.8.0", "description": "The Playwright configuration every LVBT repository spreads into its own: end-to-end tests under tests/e2e, desktop and mobile projects, traces on failure.", "license": "MIT", "type": "module", diff --git a/.lvbt/web-platform/packages/prettier-config/package.json b/.lvbt/web-platform/packages/prettier-config/package.json index 44aa1bd..4da7af7 100644 --- a/.lvbt/web-platform/packages/prettier-config/package.json +++ b/.lvbt/web-platform/packages/prettier-config/package.json @@ -1,6 +1,6 @@ { "name": "@lasvegasfortransit/prettier-config", - "version": "0.7.9", + "version": "0.8.0", "description": "The Prettier configuration every LVBT repository uses.", "license": "MIT", "type": "module", diff --git a/.lvbt/web-platform/packages/typescript-config/package.json b/.lvbt/web-platform/packages/typescript-config/package.json index 96a6392..2adb50d 100644 --- a/.lvbt/web-platform/packages/typescript-config/package.json +++ b/.lvbt/web-platform/packages/typescript-config/package.json @@ -1,6 +1,6 @@ { "name": "@lasvegasfortransit/typescript-config", - "version": "0.7.9", + "version": "0.8.0", "description": "TypeScript configurations every LVBT repository extends.", "license": "MIT", "repository": { diff --git a/.lvbt/web-platform/packages/vitest-config/package.json b/.lvbt/web-platform/packages/vitest-config/package.json index 9004471..dab348a 100644 --- a/.lvbt/web-platform/packages/vitest-config/package.json +++ b/.lvbt/web-platform/packages/vitest-config/package.json @@ -1,6 +1,6 @@ { "name": "@lasvegasfortransit/vitest-config", - "version": "0.7.9", + "version": "0.8.0", "description": "The Vitest configuration every LVBT repository spreads into its own.", "license": "MIT", "type": "module", diff --git a/.lvbt/web-platform/packages/web-platform/package.json b/.lvbt/web-platform/packages/web-platform/package.json index a512af0..9930414 100644 --- a/.lvbt/web-platform/packages/web-platform/package.json +++ b/.lvbt/web-platform/packages/web-platform/package.json @@ -1,6 +1,6 @@ { "name": "@lasvegasfortransit/web-platform", - "version": "0.7.9", + "version": "0.8.0", "description": "Provider-neutral deployment, provisioning, and validation primitives for LVBT web repositories.", "license": "MIT", "type": "module", diff --git a/.lvbt/web-platform/packages/web-platform/src/doctor-github.ts b/.lvbt/web-platform/packages/web-platform/src/doctor-github.ts index e3faf76..0eb111f 100644 --- a/.lvbt/web-platform/packages/web-platform/src/doctor-github.ts +++ b/.lvbt/web-platform/packages/web-platform/src/doctor-github.ts @@ -1,6 +1,6 @@ import { z } from 'zod'; import { doctorCheck, type DoctorCheck } from './doctor-check.js'; -import { matchesPinnedRules } from './ruleset.js'; +import { matchesPinnedRules, rulesetForOwner } from './ruleset.js'; interface GitHubTarget { repository: string; @@ -80,39 +80,53 @@ async function productionPolicy( return branches.length === 1 && branches[0]?.name === branch && branches[0].type === 'branch'; } +async function repositoryCheck(target: GitHubTarget, base: string, read: Read, check: Check) { + let organizationOwned = true; + const result = await check( + 'repository', + 'Public, unarchived repository with the expected default branch.', + async () => { + const repo = z + .object({ + full_name: z.string(), + private: z.boolean(), + archived: z.boolean(), + default_branch: z.string(), + owner: z.object({ type: z.string() }).optional(), + }) + .parse(await read(base)); + organizationOwned = repo.owner?.type !== 'User'; + return ( + repo.full_name === target.repository && + !repo.private && + !repo.archived && + repo.default_branch === target.branch + ); + }, + ); + return { result, organizationOwned }; +} + export async function githubDoctor(target: GitHubTarget, read: Read) { const base = `repos/${target.repository}`; const environment = `${base}/environments/${encodeURIComponent(target.environment)}`; const check = (id: string, requirement: string, inspect: () => Promise) => doctorCheck(`github.${id}`, requirement, inspect); + const { result: repository, organizationOwned } = await repositoryCheck( + target, + base, + read, + check, + ); const checks = [ - await check( - 'repository', - 'Public, unarchived repository with the expected default branch.', - async () => { - const repo = z - .object({ - full_name: z.string(), - private: z.boolean(), - archived: z.boolean(), - default_branch: z.string(), - }) - .parse(await read(base)); - return ( - repo.full_name === target.repository && - !repo.private && - !repo.archived && - repo.default_branch === target.branch - ); - }, - ), + repository, await check( 'rules', 'Effective production-branch rules match the pinned organization ruleset.', async () => matchesPinnedRules( await read(`${base}/rules/branches/${encodeURIComponent(target.branch)}`), - target.ruleset, + rulesetForOwner(target.ruleset, organizationOwned), ), ), await check('production', 'The production environment accepts only the main branch.', () => diff --git a/.lvbt/web-platform/packages/web-platform/src/github-governance.ts b/.lvbt/web-platform/packages/web-platform/src/github-governance.ts index cdf692c..34c1bb7 100644 --- a/.lvbt/web-platform/packages/web-platform/src/github-governance.ts +++ b/.lvbt/web-platform/packages/web-platform/src/github-governance.ts @@ -1,6 +1,6 @@ import { z } from 'zod'; import { doctorCheck } from './doctor-check.js'; -import { matchesPinnedRules, matchesPinnedRuleset } from './ruleset.js'; +import { matchesPinnedRules, matchesPinnedRuleset, rulesetForOwner } from './ruleset.js'; const repositorySettings = z.object({ allow_merge_commit: z.literal(false), @@ -56,9 +56,17 @@ export async function githubGovernanceDoctor( ), check( 'ruleset', - 'Settings → Rules: apply the reviewed organization ruleset; preserve additional merge-queue protections.', + 'Settings → Rules: apply the reviewed organization ruleset, including the rebase merge queue on organization repositories.', async () => { - return await rulesMatch(target.ruleset, read, base); + const repo = z + .object({ owner: z.object({ type: z.string() }).optional() }) + .loose() + .parse(await read(base)); + return await rulesMatch( + rulesetForOwner(target.ruleset, repo.owner?.type !== 'User'), + read, + base, + ); }, ), check( diff --git a/.lvbt/web-platform/packages/web-platform/src/provision-ruleset.ts b/.lvbt/web-platform/packages/web-platform/src/provision-ruleset.ts index bc2a878..bb07986 100644 --- a/.lvbt/web-platform/packages/web-platform/src/provision-ruleset.ts +++ b/.lvbt/web-platform/packages/web-platform/src/provision-ruleset.ts @@ -1,9 +1,10 @@ import { z } from 'zod'; import type { ProvisionResource } from './provision-reconcile.js'; -import { matchesPinnedRuleset } from './ruleset.js'; +import { matchesPinnedRuleset, rulesetForOwner } from './ruleset.js'; const targetSchema = z.object({ repository: z.string().regex(/^[A-Za-z0-9-]+\/[A-Za-z0-9._-]+$/), + organizationOwned: z.boolean().default(true), ruleset: z.object({ name: z.string().min(1), target: z.literal('branch'), @@ -31,6 +32,7 @@ export function provisionRepositoryRuleset( write: Write, ): ProvisionResource { const target = targetSchema.parse(input); + const desiredRuleset = rulesetForOwner(target.ruleset, target.organizationOwned); const endpoint = `repos/${target.repository}/rulesets`; const selected = async () => { const input = await read(endpoint); @@ -53,7 +55,7 @@ export function provisionRepositoryRuleset( const summary = await selected(); return ( summary !== null && - matchesPinnedRuleset(await read(`${endpoint}/${summary.id}`), target.ruleset) + matchesPinnedRuleset(await read(`${endpoint}/${summary.id}`), desiredRuleset) ); }, desired: () => true, @@ -62,7 +64,7 @@ export function provisionRepositoryRuleset( await write( summary === null ? 'POST' : 'PUT', summary === null ? endpoint : `${endpoint}/${summary.id}`, - target.ruleset, + desiredRuleset, ); }, }; diff --git a/.lvbt/web-platform/packages/web-platform/src/release-candidate.ts b/.lvbt/web-platform/packages/web-platform/src/release-candidate.ts index 357b546..31c8161 100644 --- a/.lvbt/web-platform/packages/web-platform/src/release-candidate.ts +++ b/.lvbt/web-platform/packages/web-platform/src/release-candidate.ts @@ -148,7 +148,9 @@ function operations(repository: string): CandidateOperations { function assertRun(value: unknown, config: ReleaseConfiguration, context: CandidateContext): void { z.object({ id: z.number().refine((id) => String(id) === context.runId), - run_attempt: z.number().refine((attempt) => String(attempt) === context.attempt), + run_attempt: z.number().refine((attempt) => String(attempt) === context.attempt, { + message: 'Run attempt does not match this run.', + }), head_sha: z.literal(context.toolsCommit), head_branch: z.literal('main'), event: z.literal('workflow_dispatch'), @@ -161,17 +163,29 @@ function assertRun(value: unknown, config: ReleaseConfiguration, context: Candid head_repository: z.object({ full_name: z.literal(config.repository) }), }).parse(value); } -function assertCompletedCandidate(value: unknown): void { +function assertCompletedCandidate(value: unknown, currentAttempt: string): string { const jobs = z .object({ jobs: z.array( - z.object({ name: z.string(), status: z.string(), conclusion: z.string().nullable() }), + z.object({ + name: z.string(), + status: z.string(), + conclusion: z.string().nullable(), + run_attempt: z.number().int().positive(), + }), ), }) .parse(value) .jobs.filter((job) => /(^| \/ )Verify named release candidate$/.test(job.name)); - if (jobs.length !== 1 || jobs[0]?.status !== 'completed' || jobs[0].conclusion !== 'success') + const candidateJob = jobs[0]; + if ( + jobs.length !== 1 || + candidateJob?.status !== 'completed' || + candidateJob.conclusion !== 'success' || + candidateJob.run_attempt > Number(currentAttempt) + ) throw new Error('Current promotion run has no uniquely completed successful candidate job.'); + return String(candidateJob.run_attempt); } function selectedArtifact(value: unknown, name: string, context: CandidateContext): number { const artifacts = z @@ -213,8 +227,16 @@ export async function verifyCandidateReceipt( throw new Error('Candidate proof must be a regular receipt smaller than1MiB.'); const text = await readFile(file, 'utf8'); const receipt = candidateReceiptSchema.parse(JSON.parse(text)); + assertRun(await tools.getRun(context.runId), config, context); + const candidateAttempt = assertCompletedCandidate( + await tools.getJobs(context.runId), + context.attempt, + ); + // Activation retries re-use the verified candidate artifact from the earlier attempt that ran + // `Verify named release candidate`, rather than requiring a new candidate upload on the retry. + const expectedIssuer: CandidateContext = { ...context, attempt: candidateAttempt }; if ( - !isDeepStrictEqual(receipt.issuer, context) || + !isDeepStrictEqual(receipt.issuer, expectedIssuer) || !isDeepStrictEqual(receipt.release, selectedRelease(release)) || receipt.preview.worker !== config.previewWorker || receipt.preview.origin !== config.previewUrl @@ -222,12 +244,10 @@ export async function verifyCandidateReceipt( throw new Error( 'Candidate proof does not match this run, tools, selected artifact, app, and preview namespace.', ); - assertRun(await tools.getRun(context.runId), config, context); - assertCompletedCandidate(await tools.getJobs(context.runId)); const id = selectedArtifact( await tools.getArtifacts(context.runId), - candidateArtifactName(context, config.profile), - context, + candidateArtifactName(expectedIssuer, config.profile), + expectedIssuer, ); const retained = await tools.downloadArtifact(id); if ( diff --git a/.lvbt/web-platform/packages/web-platform/src/ruleset.ts b/.lvbt/web-platform/packages/web-platform/src/ruleset.ts index 0072035..93c58dc 100644 --- a/.lvbt/web-platform/packages/web-platform/src/ruleset.ts +++ b/.lvbt/web-platform/packages/web-platform/src/ruleset.ts @@ -19,6 +19,23 @@ function managedFieldsMatch(expected: unknown, actual: unknown): boolean { ); } +export function rulesetForOwner( + standard: T, + organizationOwned: boolean, +): T; +export function rulesetForOwner(standard: unknown, organizationOwned: boolean): unknown; +export function rulesetForOwner(standard: unknown, organizationOwned: boolean): unknown { + if (organizationOwned) return standard; + const parsed = z + .object({ rules: z.array(z.object({ type: z.string() }).loose()) }) + .loose() + .parse(standard); + return { + ...parsed, + rules: parsed.rules.filter((rule) => rule.type !== 'merge_queue'), + }; +} + export function matchesPinnedRuleset(input: unknown, standard: unknown) { return managedFieldsMatch(standard, input); } diff --git a/.lvbt/web-platform/packages/web-platform/tests/doctor-github.test.ts b/.lvbt/web-platform/packages/web-platform/tests/doctor-github.test.ts index 8ac95d6..35dd6fb 100644 --- a/.lvbt/web-platform/packages/web-platform/tests/doctor-github.test.ts +++ b/.lvbt/web-platform/packages/web-platform/tests/doctor-github.test.ts @@ -96,9 +96,9 @@ test('rejects unrestricted production branches and a nonrequired Validate check' expect(result.find((check) => check.id === 'github.rules')?.status).toBe('fail'); }); -test('requires the pinned pull-request and linear-history rules', async () => { +test('requires the pinned pull-request, linear-history, and merge-queue rules on organization repositories', async () => { const rules = fixture['/rules/branches/main'] as { type: string; parameters?: unknown }[]; - for (const type of ['pull_request', 'required_linear_history']) { + for (const type of ['pull_request', 'required_linear_history', 'merge_queue']) { const result = await githubDoctor(target, (endpoint) => Promise.resolve( endpoint.includes('/rules/branches/') @@ -109,3 +109,21 @@ test('requires the pinned pull-request and linear-history rules', async () => { expect(result.find((check) => check.id === 'github.rules')?.status).toBe('fail'); } }); + +test('skips merge_queue requirement for personal-account repositories', async () => { + const rules = ( + fixture['/rules/branches/main'] as { type: string; parameters?: unknown }[] + ).filter((rule) => rule.type !== 'merge_queue'); + const result = await githubDoctor(target, (endpoint) => { + const suffix = endpoint.replace(`repos/${target.repository}`, ''); + if (suffix === '') { + return Promise.resolve({ + ...(fixture[''] as Record), + owner: { type: 'User' }, + }); + } + if (endpoint.includes('/rules/branches/')) return Promise.resolve(rules); + return Promise.resolve(fixture[suffix]); + }); + expect(result.find((check) => check.id === 'github.rules')?.status).toBe('pass'); +}); diff --git a/.lvbt/web-platform/packages/web-platform/tests/provision-ruleset.test.ts b/.lvbt/web-platform/packages/web-platform/tests/provision-ruleset.test.ts index d8d5afd..7171757 100644 --- a/.lvbt/web-platform/packages/web-platform/tests/provision-ruleset.test.ts +++ b/.lvbt/web-platform/packages/web-platform/tests/provision-ruleset.test.ts @@ -81,3 +81,33 @@ test('accepts provider fields added inside managed rule parameters', async () => expect((await reconcileResources([resource], true)).changed).toBe(false); }); + +test('omits merge_queue when provisioning a personal-account repository', async () => { + let details: unknown = null; + const writes: { body: { rules: { type: string }[] } }[] = []; + const expectedWithoutQueue = { + ...standard, + rules: standard.rules.filter((rule) => rule.type !== 'merge_queue'), + }; + const resource = provisionRepositoryRuleset( + { repository: 'williecubed/example', organizationOwned: false, ruleset: standard }, + (endpoint) => + Promise.resolve( + endpoint.endsWith('/rulesets') + ? details + ? [{ id: 42, name: standard.name, target: 'branch', source_type: 'Repository' }] + : [] + : details, + ), + (_method, _endpoint, body) => { + writes.push({ body: body as { rules: { type: string }[] } }); + details = body; + return Promise.resolve(); + }, + ); + + expect((await reconcileResources([resource], true)).ok).toBe(true); + expect(writes[0]?.body).toEqual(expectedWithoutQueue); + expect(writes[0]?.body.rules.some((rule) => rule.type === 'merge_queue')).toBe(false); + expect((await reconcileResources([resource], true)).changed).toBe(false); +}); diff --git a/.lvbt/web-platform/packages/web-platform/tests/release-candidate.test.ts b/.lvbt/web-platform/packages/web-platform/tests/release-candidate.test.ts index a2f3c3a..3b2e697 100644 --- a/.lvbt/web-platform/packages/web-platform/tests/release-candidate.test.ts +++ b/.lvbt/web-platform/packages/web-platform/tests/release-candidate.test.ts @@ -58,6 +58,7 @@ const jobs = { name: 'publish / Verify named release candidate', status: 'completed', conclusion: 'success', + run_attempt: 2, }, ], }; @@ -127,3 +128,88 @@ test('candidate proof binds the same manual run, tools, successful job, artifact await rm(directory, { recursive: true, force: true }); } }); + +test('activation-only retry reuses the verified candidate receipt from an earlier attempt and rejects mismatches', async () => { + const directory = await mkdtemp(path.join(os.tmpdir(), 'candidate-retry-')); + const attempt1Receipt = { + ...receipt, + issuer: { ...context, attempt: '1' }, + }; + const attempt1Artifacts = { + artifacts: [ + { + id: 54, + name: 'candidate-900-1', + expired: false, + workflow_run: { id: 900, head_sha: context.toolsCommit, head_branch: 'main' }, + }, + ], + }; + try { + await writeFile(path.join(directory, 'candidate.json'), JSON.stringify(attempt1Receipt) + '\n'); + const retryOps = operations({ + getRun: () => Promise.resolve({ ...run, run_attempt: 2 }), + getJobs: () => + Promise.resolve({ + jobs: [{ ...jobs.jobs[0], run_attempt: 1 }], + }), + getArtifacts: () => Promise.resolve(attempt1Artifacts), + downloadArtifact: () => Promise.resolve(JSON.stringify(attempt1Receipt) + '\n'), + }); + expect( + await verifyCandidateReceipt(config, release, directory, { + context: { ...context, attempt: '2' }, + operations: retryOps, + }), + ).toEqual(attempt1Receipt); + + // Reject if the candidate job ran on attempt 2 while the receipt claims attempt 1. + await expect( + verifyCandidateReceipt(config, release, directory, { + context: { ...context, attempt: '2' }, + operations: operations({ + getRun: () => Promise.resolve({ ...run, run_attempt: 2 }), + getJobs: () => + Promise.resolve({ + jobs: [{ ...jobs.jobs[0], run_attempt: 2 }], + }), + getArtifacts: () => Promise.resolve(attempt1Artifacts), + downloadArtifact: () => Promise.resolve(JSON.stringify(attempt1Receipt) + '\n'), + }), + }), + ).rejects.toThrow('this run'); + + // Reject if the candidate job reports an attempt newer than the current run attempt. + await expect( + verifyCandidateReceipt(config, release, directory, { + context: { ...context, attempt: '2' }, + operations: operations({ + getRun: () => Promise.resolve({ ...run, run_attempt: 2 }), + getJobs: () => + Promise.resolve({ + jobs: [{ ...jobs.jobs[0], run_attempt: 3 }], + }), + getArtifacts: () => Promise.resolve(attempt1Artifacts), + downloadArtifact: () => Promise.resolve(JSON.stringify(attempt1Receipt) + '\n'), + }), + }), + ).rejects.toThrow('candidate job'); + + // Reject if the attempt-1 artifact is missing on retry. + await expect( + verifyCandidateReceipt(config, release, directory, { + context: { ...context, attempt: '2' }, + operations: operations({ + getRun: () => Promise.resolve({ ...run, run_attempt: 2 }), + getJobs: () => + Promise.resolve({ + jobs: [{ ...jobs.jobs[0], run_attempt: 1 }], + }), + getArtifacts: () => Promise.resolve({ artifacts: [] }), + }), + }), + ).rejects.toThrow('retained artifact'); + } finally { + await rm(directory, { recursive: true, force: true }); + } +}); diff --git a/.lvbt/web-platform/packages/web-platform/tests/release-publish-workflow.test.ts b/.lvbt/web-platform/packages/web-platform/tests/release-publish-workflow.test.ts index 9ea3cb0..d9a6dbd 100644 --- a/.lvbt/web-platform/packages/web-platform/tests/release-publish-workflow.test.ts +++ b/.lvbt/web-platform/packages/web-platform/tests/release-publish-workflow.test.ts @@ -35,6 +35,25 @@ test('named production installs Chromium before its browser-backed public smoke' ); }); +test('named production resumes using the succeeded candidate job attempt on activation-only retries', async () => { + const workflow = await readFile( + new URL('../../../.github/workflows/release-publish.yml', import.meta.url), + 'utf8', + ); + const namedCandidate = workflow.slice( + workflow.indexOf(' named-candidate:'), + workflow.indexOf(' named-production:'), + ); + const namedProduction = workflow.slice(workflow.indexOf(' named-production:')); + + expect(namedCandidate).toContain('candidate-attempt: ${{ github.run_attempt }}'); + expect(namedProduction).toContain( + 'candidate-${{ github.run_id }}-${{ needs.named-candidate.outputs.candidate-attempt ||', + ); + expect(namedProduction).toContain('github.run_attempt }}'); + expect(namedProduction).toContain('--expected-version "$EXPECTED_PRODUCTION_VERSION"'); +}); + test('every migration step supplies a separate D1 credential without overriding the publisher credential', async () => { const workflow = await readFile( new URL('../../../.github/workflows/release-publish.yml', import.meta.url), diff --git a/.lvbt/web-platform/standards/ruleset.json b/.lvbt/web-platform/standards/ruleset.json index f10bf8e..64d6bc8 100644 --- a/.lvbt/web-platform/standards/ruleset.json +++ b/.lvbt/web-platform/standards/ruleset.json @@ -36,6 +36,18 @@ "do_not_enforce_on_create": false, "required_status_checks": [{ "context": "Validate" }] } + }, + { + "type": "merge_queue", + "parameters": { + "merge_method": "REBASE", + "grouping_strategy": "ALLGREEN", + "check_response_timeout_minutes": 60, + "max_entries_to_build": 5, + "max_entries_to_merge": 5, + "min_entries_to_merge": 1, + "min_entries_to_merge_wait_minutes": 5 + } } ] }