diff --git a/.github/scripts/coordinate-release.mjs b/.github/scripts/coordinate-release.mjs index 1cedf2f378..1ff8beae21 100644 --- a/.github/scripts/coordinate-release.mjs +++ b/.github/scripts/coordinate-release.mjs @@ -9,59 +9,60 @@ const versionPattern = /^v\d+\.\d+\.\d+(?:-rc\.[1-9]\d*)?$/; const receiptEnvironment = "release-coordination"; const receiptTask = (version, task) => `release-coordination:${version}:${task.id}`; -// The docs and samples upmerge workflows open a pull request into edge in a -// step with this name; its conclusion tells whether a pull request exists. -const pullRequestStep = "Create pull request"; -const upmergeBase = "edge"; -const upmergeBranchPrefix = "upmerge/"; -const pullRequestSlack = 5000; +const commitPattern = /^[a-f0-9]{40}$/; +// docs and samples develop on edge, which stays their default branch. Releases +// never merge a stable branch back into it. +const developmentBranch = "edge"; +// These runs test exactly the commit they ran on, and a rerun would keep that +// commit, so a failure is replaced by a fresh run on the current branch. +const validationTasks = new Set(["docs-validation", "sample-tests"]); +const commitFields = { docs: "docsCommit", samples: "samplesCommit" }; -export function coordinationTasks(releaseType, version) { +const channelBranch = (version) => + `v${version.slice(1).split(".").slice(0, 2).join(".")}`; + +// An RC records the docs and samples commits it validated. Its final publishes +// those snapshots with release configuration; patches test the stable branch. +export function coordinationTasks(releaseType, version, snapshots = {}) { const inputs = { version: version.replace(/^v/, "") }; - const tasks = - releaseType === "rc" ? - [ - { - id: "docs-upmerge", - repo: "docs", - workflow: "upmerge.yaml", - inputs: {} - }, - { - id: "samples-upmerge", - repo: "samples", - workflow: "upmerge.yaml", - inputs: {} - } - ] - : releaseType === "final" ? - [ - { - id: "docs-release", - repo: "docs", - workflow: "release.yaml", - ref: "edge", - inputs - }, - { - id: "samples-release", - repo: "samples", - workflow: "release.yaml", - ref: "edge", - inputs - } - ] - : []; - return [ - ...tasks, - { - id: "sample-tests", - repo: "samples", - workflow: "test.yaml", - ref: "edge", - inputs + const tests = (ref) => ({ + id: "sample-tests", + repo: "samples", + workflow: "test.yaml", + ref, + inputs + }); + if (releaseType === "rc") { + return [ + { + id: "docs-validation", + repo: "docs", + workflow: "validate-release.yaml", + ref: developmentBranch, + inputs + }, + tests(developmentBranch) + ]; + } + if (releaseType === "final") { + for (const repo of ["docs", "samples"]) { + if (!commitPattern.test(snapshots[repo] ?? "")) + throw new Error( + `A final publishes the ${repo} commit validated by its last RC` + ); } - ]; + return [ + ...["docs", "samples"].map((repo) => ({ + id: `${repo}-release`, + repo, + workflow: "release.yaml", + ref: developmentBranch, + inputs: { ...inputs, commit: snapshots[repo] } + })), + tests(channelBranch(version)) + ]; + } + return releaseType === "patch" ? [tests(channelBranch(version))] : []; } export async function tagCommit(github, context, version) { @@ -96,98 +97,12 @@ async function deploymentFor(github, context, version, sourceSha, task) { return deployments[0]; } -function pullRequestUrl(context, task, number) { - return `${context.serverUrl ?? "https://github.com"}/${context.repo.owner}/${task.repo}/pull/${number}`; +function repositoryUrl(context, task) { + return `${context.serverUrl ?? "https://github.com"}/${context.repo.owner}/${task.repo}`; } -// Binds the pull request that a successful upmerge run opened. The workflow -// exposes no identifier for it, so the pull request is the single upmerge -// pull request into edge created while the run's pull-request step ran; the -// binding is stored on the receipt and never searched for again. Returns null -// when the run had nothing to merge and skipped the step. -async function createdPullRequest(call, context, task, run) { - const { data: jobs } = await call( - "GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs", - { run_id: run.id, filter: "latest", per_page: 100 } - ); - const step = jobs.jobs - .flatMap((job) => job.steps ?? []) - .find((entry) => entry.name === pullRequestStep); - if (!step) { - throw new Error( - `${run.html_url} has no '${pullRequestStep}' step; bind its pull request as the receipt's environment URL before resuming` - ); - } - if (step.conclusion === "skipped") return null; - if (step.conclusion !== "success") { - throw new Error( - `${run.html_url} did not create its pull request; reconcile the receipt before resuming` - ); - } - const earliest = Date.parse(step.started_at) - pullRequestSlack; - const latest = Date.parse(step.completed_at) + pullRequestSlack; - const { data: pulls } = await call("GET /repos/{owner}/{repo}/pulls", { - base: upmergeBase, - state: "all", - sort: "created", - direction: "desc", - per_page: 100 - }); - const candidates = pulls.filter( - (pull) => - pull.head.ref.startsWith(upmergeBranchPrefix) && - Date.parse(pull.created_at) >= earliest && - Date.parse(pull.created_at) <= latest - ); - if (candidates.length !== 1) { - throw new Error( - `${candidates.length} upmerge pull requests match ${run.html_url}; bind the right one as the receipt's environment URL before resuming` - ); - } - return candidates[0].html_url; -} - -// An upmerge is complete when the pull request its run opened has merged. -// docs and samples squash-merge, so the source commits never become -// reachable from edge and cannot serve as the completion signal. -async function verifyUpmerge({ call, context, task, run, status, record }) { - const prefix = pullRequestUrl(context, task, ""); - let url = status?.environment_url; - if (!url?.startsWith(prefix) || !/^\d+$/.test(url.slice(prefix.length))) { - url = await createdPullRequest(call, context, task, run); - if (!url) return null; - } - const number = Number(url.slice(prefix.length)); - const { data: pull } = await call( - "GET /repos/{owner}/{repo}/pulls/{pull_number}", - { pull_number: number } - ); - if ( - pull.base.ref !== upmergeBase || - !pull.head.ref.startsWith(upmergeBranchPrefix) - ) { - throw new Error( - `${url} is not an upmerge pull request into ${upmergeBase}` - ); - } - if (pull.merged) return url; - if (pull.state === "closed") { - await record( - "failure", - run.html_url, - `Pull request #${number} closed without merging`, - url - ); - return false; - } - await record( - "in_progress", - run.html_url, - `Waiting for pull request #${number} to merge`, - url - ); - throw new Error(`Merge the ${task.repo} upmerge PR ${url}, then resume`); -} +const commitUrl = (context, task, sha) => + `${repositoryUrl(context, task)}/commit/${sha}`; async function latestStatus(github, context, deployment) { const statuses = await github.paginate( @@ -214,8 +129,23 @@ async function publishedRelease(github, context, version) { return matches[0]; } -export async function checkReleaseCandidate({ github, context, plan }) { - if (plan.releaseType !== "final") return; +// The approved final plan pins the docs and samples commits its last RC +// validated, so a later change to those receipts cannot change what ships. +const snapshotFields = { + docs: "docsSourceCommit", + samples: "samplesSourceCommit" +}; + +// Returns the docs and samples commits the final's last RC validated. Each +// successful validation receipt records its commit as the environment URL. +// With requirePins, the final plan must pin exactly those commits. +export async function checkReleaseCandidate({ + github, + context, + plan, + requirePins = false +}) { + if (plan.releaseType !== "final") return {}; const version = plan.previousVersion; if ( !/^v\d+\.\d+\.0-rc\.[1-9]\d*$/.test(version) || @@ -225,6 +155,7 @@ export async function checkReleaseCandidate({ github, context, plan }) { } await publishedRelease(github, context, version); const sourceSha = await tagCommit(github, context, version); + const snapshots = {}; for (const task of coordinationTasks("rc", version)) { const deployment = await deploymentFor( github, @@ -245,7 +176,37 @@ export async function checkReleaseCandidate({ github, context, plan }) { `${version}: ${task.id} is not verified; resume that RC before preparing the final release` ); } + const commit = recordedCommit(context, task, status); + if (!commit) { + throw new Error( + `${version}: ${task.id} recorded no validated ${task.repo} commit; cut another RC` + ); + } + snapshots[task.repo] = commit; + } + for (const [repo, field] of Object.entries(snapshotFields)) { + if (!requirePins && !Object.hasOwn(plan, field)) continue; + if (!commitPattern.test(plan[field] ?? "")) { + throw new Error( + `The final plan has no valid ${field}; rerun Prepare Release` + ); + } + if (plan[field] !== snapshots[repo]) { + throw new Error( + `The final plan pins ${repo} ${plan[field]}, but ${version} validated ${snapshots[repo]}; cut another RC and prepare the final again` + ); + } } + return snapshots; +} + +function recordedCommit(context, task, status) { + const prefix = commitUrl(context, task, ""); + const commit = + status?.environment_url?.startsWith(prefix) ? + status.environment_url.slice(prefix.length) + : ""; + return commitPattern.test(commit) ? commit : undefined; } export async function coordinateTask({ @@ -279,8 +240,6 @@ export async function coordinateTask({ task ); if (!deployment) { - const ref = - task.ref || (await call("GET /repos/{owner}/{repo}")).data.default_branch; const request = { ...context.repo, ref: sourceSha, @@ -290,7 +249,7 @@ export async function coordinateTask({ required_contexts: [], production_environment: false, transient_environment: false, - payload: { version, sourceSha, task, ref }, + payload: { version, sourceSha, task, ref: task.ref }, request: { retries: 0 } }; try { @@ -310,7 +269,7 @@ export async function coordinateTask({ if ( deployment.sha !== sourceSha || deployment.payload?.version !== version || - (task.id === "bicep-recipes" && deployment.payload?.ref !== task.ref) || + deployment.payload?.ref !== task.ref || !isDeepStrictEqual(deployment.payload?.task, task) ) { throw new Error( @@ -323,6 +282,27 @@ export async function coordinateTask({ latest?.description?.startsWith("Dispatch rejected with HTTP ") ? undefined : latest; + const runPrefix = `${repositoryUrl(context, task)}/actions/runs/`; + // A successful validation is final. Rerunning its remote run later cannot + // change, or invalidate, the commit that the release validated. + const validated = + validationTasks.has(task.id) && + status?.state === "success" && + recordedCommit(context, task, status); + if ( + validated && + status.log_url?.startsWith(runPrefix) && + /^\d+$/.test(status.log_url.slice(runPrefix.length)) + ) { + return { + name: task.id, + state: "success", + runId: Number(status.log_url.slice(runPrefix.length)), + url: status.log_url, + [commitFields[task.repo]]: validated, + deploymentId: deployment.id + }; + } const record = async (state, logUrl, description, environmentUrl) => github.rest.repos.createDeploymentStatus({ ...context.repo, @@ -373,23 +353,22 @@ export async function coordinateTask({ ); await record( "in_progress", - `${context.serverUrl ?? "https://github.com"}/${context.repo.owner}/${task.repo}/actions/runs/${runID}`, + `${runPrefix}${runID}`, "Monitoring exact dispatched run" ); return runID; }; let runID; if (status) { - const prefix = `${context.serverUrl ?? "https://github.com"}/${context.repo.owner}/${task.repo}/actions/runs/`; if ( - !status.log_url?.startsWith(prefix) || - !/^\d+$/.test(status.log_url.slice(prefix.length)) + !status.log_url?.startsWith(runPrefix) || + !/^\d+$/.test(status.log_url.slice(runPrefix.length)) ) { throw new Error( `Dispatch outcome unknown for deployment ${deployment.id}; bind its exact remote run URL before resuming. No duplicate was dispatched.` ); } - runID = Number(status.log_url.slice(prefix.length)); + runID = Number(status.log_url.slice(runPrefix.length)); } else { runID = await dispatchRun(); } @@ -407,8 +386,8 @@ export async function coordinateTask({ `Run ${runID} does not match the recorded workflow and ref` ); } - if (task.id === "sample-tests" && !/^[a-f0-9]{40}$/.test(data.head_sha)) - throw new Error(`Sample-test run ${runID} has no valid source commit`); + if (validationTasks.has(task.id) && !commitPattern.test(data.head_sha)) + throw new Error(`Run ${runID} has no valid ${task.repo} commit`); if (task.runName && data.display_title !== task.runName) throw new Error(`Run ${runID} does not match '${task.runName}'`); return data; @@ -419,41 +398,26 @@ export async function coordinateTask({ Number(status.description.slice(20)) + 1 : 0; if ( - task.id === "sample-tests" && + validationTasks.has(task.id) && status && status.state !== "success" && run.status === "completed" && run.conclusion !== "success" && (!requiredAttempt || run.run_attempt >= requiredAttempt) ) { - // Reruns retain old workflow code; dispatch once per resume to refresh edge. + // Reruns retain old workflow code and content; dispatch once per resume + // so the replacement validates the branch's current commit. runID = await dispatchRun(); status = undefined; requiredAttempt = 0; run = await getRun(); } - let pullRequest; - if ( - task.workflow === "upmerge.yaml" && - run.status === "completed" && - run.conclusion === "success" && - !requiredAttempt - ) { - pullRequest = await verifyUpmerge({ - call, - context, - task, - run, - status, - record - }); - } - const replaceClosedUpmerge = pullRequest === false; if ( run.status === "completed" && !requiredAttempt && - (replaceClosedUpmerge || - (status && status.state !== "success" && run.conclusion !== "success")) + status && + status.state !== "success" && + run.conclusion !== "success" ) { requiredAttempt = run.run_attempt + 1; await record( @@ -463,9 +427,7 @@ export async function coordinateTask({ ); try { await call( - replaceClosedUpmerge ? - "POST /repos/{owner}/{repo}/actions/runs/{run_id}/rerun" - : "POST /repos/{owner}/{repo}/actions/runs/{run_id}/rerun-failed-jobs", + "POST /repos/{owner}/{repo}/actions/runs/{run_id}/rerun-failed-jobs", { run_id: runID } ); } catch (error) { @@ -475,8 +437,7 @@ export async function coordinateTask({ await record( "failure", run.html_url, - `Rerun rejected with HTTP ${httpStatus}; resume to retry`, - status?.environment_url + `Rerun rejected with HTTP ${httpStatus}; resume to retry` ); } throw error; @@ -498,50 +459,53 @@ export async function coordinateTask({ ); throw new Error( `${task.id} failed: ${run.html_url}` + - (task.id === "sample-tests" ? ` (samples commit ${run.head_sha})` : "") - ); - } - if ( - task.workflow === "upmerge.yaml" && - (pullRequest === undefined || requiredAttempt) - ) { - pullRequest = await verifyUpmerge({ - call, - context, - task, - run, - // A new attempt creates its own PR; never reuse the old attempt's binding. - status: requiredAttempt ? undefined : status, - record - }); - } - if (pullRequest === false) { - throw new Error( - `${task.repo} replacement upmerge PR closed without merging; resume to create another pull request` + (validationTasks.has(task.id) ? + ` (${task.repo} commit ${run.head_sha})` + : "") ); } - if (task.workflow === "release.yaml") { - const channel = `v${version.slice(1).split(".").slice(0, 2).join(".")}`; + let commit; + let environmentUrl; + if (validationTasks.has(task.id)) { + commit = run.head_sha; + environmentUrl = commitUrl(context, task, commit); + } else if (task.workflow === "release.yaml") { + const channel = channelBranch(version); + commit = task.inputs.commit; const { data } = await call("GET /repos/{owner}/{repo}"); - if (data.default_branch !== channel) - throw new Error(`${task.repo} did not publish channel ${channel}`); - await call("GET /repos/{owner}/{repo}/git/ref/{ref}", { - ref: `heads/${channel}` - }); + if (data.default_branch !== developmentBranch) { + throw new Error( + `${task.repo} default branch is ${data.default_branch}, not ${developmentBranch}` + ); + } + // vX.Y must branch from the validated snapshot, not merely contain it: + // a channel cut from a newer edge commit also descends from the snapshot. + const { data: comparison } = await call( + "GET /repos/{owner}/{repo}/compare/{basehead}", + { basehead: `${developmentBranch}...${channel}` } + ); + if ( + comparison.merge_base_commit?.sha !== commit || + !["ahead", "diverged"].includes(comparison.status) + ) { + throw new Error( + `${task.repo} ${channel} is not published from validated commit ${commit}` + ); + } + environmentUrl = `${repositoryUrl(context, task)}/tree/${channel}`; } await record( "success", run.html_url, "Workflow and required destination verified", - pullRequest + environmentUrl ); return { name: task.id, state: "success", runId: runID, url: run.html_url, - ...(task.id === "sample-tests" ? { samplesCommit: run.head_sha } : {}), - ...(pullRequest ? { pullRequest } : {}), + ...(commit ? { [commitFields[task.repo]]: commit } : {}), deploymentId: deployment.id }; } @@ -563,8 +527,14 @@ export default async function coordinateRelease({ !["rc", "final", "patch"].includes(plan.releaseType) ) throw new Error("Invalid release coordination plan"); + if (core.getInput("MODE") === "read-rc") { + const snapshots = await checkReleaseCandidate({ github, context, plan }); + core.setOutput("docs-commit", snapshots.docs ?? ""); + core.setOutput("samples-commit", snapshots.samples ?? ""); + return; + } if (core.getInput("MODE") === "check-rc") { - await checkReleaseCandidate({ github, context, plan }); + await checkReleaseCandidate({ github, context, plan, requirePins: true }); return; } const sourceSha = core.getInput("SOURCE_SHA", { required: true }); @@ -573,7 +543,11 @@ export default async function coordinateRelease({ const release = await publishedRelease(github, context, plan.version); if ((await tagCommit(github, context, plan.version)) !== sourceSha) throw new Error("Release tag/source conflict"); - const tasks = coordinationTasks(plan.releaseType, plan.version); + const tasks = coordinationTasks( + plan.releaseType, + plan.version, + await checkReleaseCandidate({ github, context, plan, requirePins: true }) + ); // Only new final plans opt in. Never infer a source for an older release. if (Object.hasOwn(plan, "recipeSourceCommit")) { if ( @@ -610,12 +584,13 @@ export default async function coordinateRelease({ for (const task of tasks) { try { if ( - plan.releaseType === "rc" && + plan.releaseType === "final" && task.id === "sample-tests" && - results.some((result) => result.state !== "success") + results.find((result) => result.name === "samples-release")?.state !== + "success" ) { throw new Error( - "Sample tests wait for both upmerges to merge; resume the same RC afterward" + "Final sample tests wait for the samples release; resume the same final afterward" ); } if (now() >= deadline) diff --git a/.github/scripts/coordinate-release_test.mjs b/.github/scripts/coordinate-release_test.mjs index d03f1950dd..8ded9afe04 100644 --- a/.github/scripts/coordinate-release_test.mjs +++ b/.github/scripts/coordinate-release_test.mjs @@ -9,42 +9,60 @@ import coordinateRelease, { checkReleaseCandidate } from "./coordinate-release.mjs"; +const snapshots = { docs: "d".repeat(40), samples: "5".repeat(40) }; + for (const [releaseType, version, expected] of [ [ "rc", "v0.62.0-rc.2", [ - ["docs", "upmerge.yaml", undefined], - ["samples", "upmerge.yaml", undefined], - ["samples", "test.yaml", "edge"] + ["docs", "validate-release.yaml", "edge", {}], + ["samples", "test.yaml", "edge", {}] ] ], [ "final", "v0.62.0", [ - ["docs", "release.yaml", "edge"], - ["samples", "release.yaml", "edge"], - ["samples", "test.yaml", "edge"] + ["docs", "release.yaml", "edge", { commit: snapshots.docs }], + ["samples", "release.yaml", "edge", { commit: snapshots.samples }], + ["samples", "test.yaml", "v0.62", {}] ] ], - ["patch", "v0.62.1", [["samples", "test.yaml", "edge"]]] + ["patch", "v0.62.1", [["samples", "test.yaml", "v0.62", {}]]] ]) { test(`${releaseType} coordinates only its intended downstream workflows`, () => { - const tasks = coordinationTasks(releaseType, version); + const tasks = coordinationTasks(releaseType, version, snapshots); assert.deepEqual( - tasks.map(({ repo, workflow, ref }) => [repo, workflow, ref]), - expected + tasks.map(({ repo, workflow, ref, inputs }) => [ + repo, + workflow, + ref, + inputs + ]), + expected.map(([repo, workflow, ref, extra]) => [ + repo, + workflow, + ref, + { version: version.slice(1), ...extra } + ]) ); - for (const task of tasks) { - assert.deepEqual( - task.inputs, - task.workflow === "upmerge.yaml" ? {} : { version: version.slice(1) } - ); - } }); } +test("a final cannot be coordinated without both validated RC snapshots", () => { + for (const partial of [ + {}, + { docs: snapshots.docs }, + { ...snapshots, samples: "edge" } + ]) { + assert.throws( + () => coordinationTasks("final", "v0.62.0", partial), + /commit validated by its last RC/ + ); + } +}); + async function coordinationStep(t, state, getOctokit) { const workflow = ( await readFile( @@ -100,10 +118,81 @@ async function coordinationStep(t, state, getOctokit) { }; } +// Records the successful receipts that an RC's coordination writes. +function recordCandidate(state, version, commits = snapshots) { + for (const task of coordinationTasks("rc", version)) { + const id = 1000 + state.deployments.length; + state.deployments.push({ + id, + environment: "release-coordination", + task: `release-coordination:${version}:${task.id}`, + sha: state.sourceSha, + payload: { task, version, sourceSha: state.sourceSha, ref: task.ref } + }); + state.statuses.push({ + id: 1000 + state.statuses.length, + deployment_id: id, + state: "success", + environment_url: `https://github.com/radius-project/${task.repo}/commit/${commits[task.repo]}` + }); + } +} + +// A downstream API that gives every dispatch its own run on the requested ref. +function downstreamRemote(state, title = () => "Release") { + const runs = new Map(); + state.dispatches = []; + return async (route, request) => { + state.calls.push({ route, request }); + if (route.endsWith("/dispatches")) { + const id = 100 + runs.size; + state.dispatches.push({ id, ...request }); + runs.set(id, { + id, + repo: request.repo, + workflow_id: request.workflow_id, + head_branch: request.ref, + event: "workflow_dispatch", + head_sha: state.heads[`${request.repo}:${request.ref}`], + status: "completed", + conclusion: + state.conclusions[`${request.repo}:${request.workflow_id}`] ?? + "success", + run_attempt: 1, + html_url: `https://github.com/radius-project/${request.repo}/actions/runs/${id}` + }); + return { data: { workflow_run_id: id } }; + } + if (route.endsWith("/rerun-failed-jobs")) { + const run = runs.get(request.run_id); + run.run_attempt++; + run.conclusion = + state.conclusions[`${run.repo}:${run.workflow_id}`] ?? "success"; + return {}; + } + if (route.endsWith("/{run_id}")) { + const run = runs.get(request.run_id); + return { data: { ...run, display_title: title(run) } }; + } + if (route.endsWith("/{workflow_id}")) + return { data: { id: request.workflow_id } }; + if (route.endsWith("/compare/{basehead}")) + return { + data: { + status: "diverged", + merge_base_commit: { sha: snapshots[request.repo] } + } + }; + if (route === "GET /repos/{owner}/{repo}") + return { data: { default_branch: "edge" } }; + throw new Error(`Unexpected ${route}`); + }; +} + test("workflow uses the App client remotely and the job client for receipts", async (t) => { const state = fixture(); const version = "v0.62.1"; - state.run.head_branch = "edge"; + state.run.head_branch = "v0.62"; state.run.html_url = "https://github.com/radius-project/samples/actions/runs/77"; state.github.rest.repos.listReleases = async () => [ @@ -134,6 +223,7 @@ test("workflow uses the App client remotely and the job client for receipts", as const dispatch = state.calls.find(({ route }) => route.endsWith("/dispatches") ); + assert.equal(dispatch.request.ref, "v0.62"); assert.equal(dispatch.request.request.retries, 0); assert.ok( state.calls @@ -146,6 +236,7 @@ test("workflow uses the App client remotely and the job client for receipts", as test("only a pinned public final coordinates the exact recipe run with its isolated token", async (t) => { const state = fixture(); const version = "v0.62.0"; + const candidate = "v0.62.0-rc.1"; const identifier = `${version}-${state.sourceSha}`; const recipeSource = "b".repeat(40); const release = { @@ -154,33 +245,40 @@ test("only a pinned public final coordinates the exact recipe run with its isola prerelease: false, published_at: "2026-09-10T10:00:00Z" }; - state.github.rest.repos.listReleases = async () => [release]; + state.github.rest.repos.listReleases = async () => [ + release, + { tag_name: candidate, draft: false } + ]; + recordCandidate(state, candidate); + state.heads = { + "samples:v0.62": "c".repeat(40), + "docs:edge": "e".repeat(40), + "samples:edge": "e".repeat(40) + }; state.context.ref = `refs/tags/${version}`; - const plan = { version, releaseType: "final" }; + const plan = { + version, + releaseType: "final", + previousVersion: candidate, + docsSourceCommit: snapshots.docs, + samplesSourceCommit: snapshots.samples + }; let title = `bicep-recipes / ${version}-${"c".repeat(40)}`; - const recipeDispatches = []; + const downstream = downstreamRemote(state, (run) => + run.repo === "resource-types-contrib" ? title : "Release" + ); const runStep = await coordinationStep(t, state, (token) => ({ request: async (route, request) => { const recipe = request.repo === "resource-types-contrib"; assert.equal(token, recipe ? "recipe-only" : "docs-samples"); if (recipe && route.endsWith("/dispatches")) - recipeDispatches.push(request); - if (route === "GET /repos/{owner}/{repo}") - return { data: { default_branch: "v0.62" } }; - if (route.endsWith("/{run_id}")) { - return { - data: { - ...state.run, - head_branch: recipe ? "main" : "edge", - display_title: recipe ? title : "Release", - html_url: `https://github.com/radius-project/${request.repo}/actions/runs/77` - } - }; - } - return state.remote(route, request); + assert.equal(request.ref, "main"); + return downstream(route, request); } })); const run = () => runStep(plan, "recipe-only"); + const recipeDispatches = () => + state.dispatches.filter(({ repo }) => repo === "resource-types-contrib"); assert.equal((await runStep(plan)).length, 3); // Replay an unpinned final. plan.recipeSourceCommit = recipeSource; @@ -193,10 +291,10 @@ test("only a pinned public final coordinates the exact recipe run with its isola plan.releaseType = "patch"; await assert.rejects(run, /public final tag/); plan.releaseType = "final"; - assert.deepEqual(recipeDispatches, []); + assert.deepEqual(recipeDispatches(), []); await assert.rejects(run, /does not match 'bicep-recipes/); - const [dispatch] = recipeDispatches; + const [dispatch] = recipeDispatches(); assert.equal(dispatch.workflow_id, "publish-bicep-recipes.yaml"); assert.equal(dispatch.ref, "main"); assert.deepEqual(dispatch.inputs, { @@ -205,14 +303,14 @@ test("only a pinned public final coordinates the exact recipe run with its isola release_identifier: identifier }); const receipt = state.deployments.find(({ task }) => - task.endsWith(":bicep-recipes") + task.endsWith(`${version}:bicep-recipes`) ); assert.equal(receipt.sha, state.sourceSha); assert.deepEqual(receipt.payload.task.inputs, dispatch.inputs); title = `bicep-recipes / ${identifier}`; assert.equal( (await run()).find(({ name }) => name === "bicep-recipes").url, - "https://github.com/radius-project/resource-types-contrib/actions/runs/77" + `https://github.com/radius-project/resource-types-contrib/actions/runs/${dispatch.id}` ); await state.github.rest.repos.createDeploymentStatus({ deployment_id: receipt.id, @@ -222,19 +320,20 @@ test("only a pinned public final coordinates the exact recipe run with its isola await assert.rejects(run, /Dispatch outcome unknown/); plan.recipeSourceCommit = "d".repeat(40); await assert.rejects(run, /Conflicting coordination payload/); - assert.equal(recipeDispatches.length, 1); + assert.equal(recipeDispatches().length, 1); }); function fixture() { const sourceSha = "a".repeat(40); - const task = coordinationTasks("rc", "v0.61.0-rc.1")[0]; + const version = "v0.61.0"; + const task = coordinationTasks("final", version, snapshots)[0]; const deployments = []; const statuses = []; const calls = []; const run = { id: 77, workflow_id: 3, - head_branch: "v0.60", + head_branch: "edge", event: "workflow_dispatch", head_sha: sourceSha, status: "completed", @@ -242,33 +341,7 @@ function fixture() { run_attempt: 1, html_url: "https://github.com/radius-project/docs/actions/runs/77" }; - // The upmerge run opened one pull request while its pull-request step ran. - const step = { - name: "Create pull request", - conclusion: "success", - started_at: "2026-09-10T10:00:00Z", - completed_at: "2026-09-10T10:00:03Z" - }; - const pulls = [ - { - number: 5, - html_url: "https://github.com/radius-project/docs/pull/5", - created_at: "2026-09-10T09:30:00Z", - state: "closed", - merged: true, - base: { ref: "edge" }, - head: { ref: "upmerge/2026-09-10-1a2b" } - }, - { - number: 6, - html_url: "https://github.com/radius-project/docs/pull/6", - created_at: "2026-09-10T10:00:02Z", - state: "closed", - merged: true, - base: { ref: "edge" }, - head: { ref: "upmerge/2026-09-10-3c4d" } - } - ]; + const state = {}; const github = { rest: { repos: { @@ -314,43 +387,23 @@ function fixture() { run.conclusion = "success"; return {}; } - if (route.endsWith("/rerun")) { - run.run_attempt++; - step.started_at = new Date( - Date.parse(step.started_at) + 60000 - ).toISOString(); - step.completed_at = new Date( - Date.parse(step.completed_at) + 60000 - ).toISOString(); - const number = pulls.at(-1).number + 1; - pulls.push({ - number, - html_url: `https://github.com/radius-project/docs/pull/${number}`, - created_at: step.started_at, - state: "open", - merged: false, - base: { ref: "edge" }, - head: { ref: `upmerge/${run.id}-${run.run_attempt}` } - }); - return {}; - } if (route.endsWith("/{run_id}")) return { data: { ...run } }; - if (route.endsWith("/{run_id}/jobs")) - return { data: { jobs: [{ steps: [{ ...step }] }] } }; - if (route.endsWith("/pulls")) return { data: pulls.map((p) => ({ ...p })) }; - if (route.endsWith("/{pull_number}")) + if (route.endsWith("/{workflow_id}")) return { data: { id: 3 } }; + if (route.endsWith("/compare/{basehead}")) return { - data: { ...pulls.find((p) => p.number === request.pull_number) } + data: { + status: state.comparison, + merge_base_commit: { sha: state.mergeBase } + } }; - if (route.endsWith("/{workflow_id}")) return { data: { id: 3 } }; - return { data: { default_branch: "v0.60" } }; + return { data: { default_branch: state.defaultBranch } }; }; - return { + return Object.assign(state, { github, remote, context: { repo: { owner: "radius-project", repo: "radius" } }, task, - version: "v0.61.0-rc.1", + version, sourceSha, deadline: Date.now() + 10000, sleep: async () => {}, @@ -358,16 +411,28 @@ function fixture() { statuses, calls, run, - step, - pulls - }; + heads: {}, + conclusions: {}, + defaultBranch: "edge", + comparison: "ahead", + mergeBase: snapshots.docs + }); } -function sampleFixture(releaseType = "rc", version = "v0.61.0-rc.1") { +const commitField = (task) => + task.repo === "docs" ? "docsCommit" : "samplesCommit"; + +function validationFixture( + releaseType = "rc", + version = "v0.61.0-rc.1", + id = "sample-tests" +) { const state = fixture(); - state.task = coordinationTasks(releaseType, version).at(-1); + state.task = coordinationTasks(releaseType, version, snapshots).find( + (task) => task.id === id + ); state.version = version; - state.samplesHead = "b".repeat(40); + state.head = "b".repeat(40); state.nextRunStatus = "completed"; state.nextRunConclusion = "failure"; state.runs = []; @@ -377,64 +442,71 @@ function sampleFixture(releaseType = "rc", version = "v0.61.0-rc.1") { state.calls.push({ route, request }); assert.equal(state.statuses.at(-1).state, "queued"); assert.equal(state.statuses.at(-1).log_url, ""); - assert.equal(request.workflow_id, "test.yaml"); - assert.equal(request.ref, "edge"); + assert.equal(request.repo, state.task.repo); + assert.equal(request.workflow_id, state.task.workflow); + assert.equal(request.ref, state.task.ref); assert.deepEqual(request.inputs, { version: version.slice(1) }); assert.equal(request.request.retries, 0); const id = 77 + state.runs.length; state.runs.push({ ...state.run, id, - head_branch: "edge", - head_sha: state.samplesHead, + head_branch: state.task.ref, + head_sha: state.head, status: state.nextRunStatus, conclusion: state.nextRunConclusion, - html_url: `https://github.com/radius-project/samples/actions/runs/${id}` + html_url: `https://github.com/radius-project/${state.task.repo}/actions/runs/${id}` }); return { data: { workflow_run_id: id } }; } if (route.endsWith("/{run_id}")) { state.calls.push({ route, request }); const run = state.runs.find((entry) => entry.id === request.run_id); - assert.ok(run, `unknown sample-test run ${request.run_id}`); + assert.ok(run, `unknown validation run ${request.run_id}`); return { data: { ...run } }; } assert.ok( !route.endsWith("/rerun") && !route.endsWith("/rerun-failed-jobs"), - "sample-test retries must dispatch a new complete workflow" + "validation retries must dispatch a new complete workflow" ); return remote(route, request); }; return state; } -for (const [releaseType, version] of [ - ["rc", "v0.61.0-rc.1"], - ["final", "v0.61.0"], - ["patch", "v0.61.1"] +for (const [releaseType, version, id] of [ + ["rc", "v0.61.0-rc.1", "docs-validation"], + ["rc", "v0.61.0-rc.1", "sample-tests"], + ["final", "v0.61.0", "sample-tests"], + ["patch", "v0.61.1", "sample-tests"] ]) { - test(`${releaseType} sample-test retries dispatch current edge on the same receipt`, async () => { + test(`${releaseType} ${id} retries dispatch the current branch on the same receipt`, async () => { for (const conclusion of ["failure", "cancelled", "timed_out"]) { - const state = sampleFixture(releaseType, version); + const state = validationFixture(releaseType, version, id); state.nextRunConclusion = conclusion; - await assert.rejects(() => coordinateTask(state), /sample-tests failed/); + await assert.rejects(() => coordinateTask(state), /failed: .*commit b/); assert.equal(state.runs.length, 1, "initial failure must not loop"); const receipt = structuredClone(state.deployments[0]); const originalRun = { ...state.runs[0] }; - state.samplesHead = "c".repeat(40); + state.head = "c".repeat(40); state.nextRunConclusion = "success"; const result = await coordinateTask(state); assert.equal(result.runId, 78); - assert.equal(result.samplesCommit, state.samplesHead); + assert.equal(result[commitField(state.task)], state.head); assert.deepEqual(state.runs[0], originalRun); assert.equal(state.runs[1].run_attempt, 1); assert.deepEqual(state.deployments, [receipt]); assert.equal(receipt.sha, state.sourceSha); assert.equal(receipt.payload.version, version); + assert.equal(receipt.payload.ref, state.task.ref); assert.equal(state.statuses.at(-1).state, "success"); assert.equal(state.statuses.at(-1).log_url, state.runs[1].html_url); + assert.equal( + state.statuses.at(-1).environment_url, + `https://github.com/radius-project/${state.task.repo}/commit/${state.head}` + ); assert.equal(result.deploymentId, receipt.id); assert.equal( state.calls.filter(({ route }) => route.endsWith("/dispatches")).length, @@ -452,7 +524,7 @@ for (const [releaseType, version] of [ } test("a fresh sample-test failure waits for the next resume before redispatching", async () => { - const state = sampleFixture(); + const state = validationFixture(); for (const runCount of [1, 2, 3]) { await assert.rejects(() => coordinateTask(state), /sample-tests failed/); assert.equal(state.runs.length, runCount); @@ -462,7 +534,7 @@ test("a fresh sample-test failure waits for the next resume before redispatching test("pending and successful sample-test runs are reused even when edge advances", async () => { for (const status of ["queued", "in_progress"]) { - const state = sampleFixture(); + const state = validationFixture(); state.nextRunStatus = status; state.nextRunConclusion = null; let clock = 0; @@ -472,7 +544,7 @@ test("pending and successful sample-test runs are reused even when edge advances clock += milliseconds; }; await assert.rejects(() => coordinateTask(state), /Timed out monitoring/); - state.samplesHead = "c".repeat(40); + state.head = "c".repeat(40); clock = 0; await assert.rejects(() => coordinateTask(state), /Timed out monitoring/); assert.equal(state.runs.length, 1); @@ -488,9 +560,9 @@ test("pending and successful sample-test runs are reused even when edge advances }); test("a timed-out replacement remains bound for the next resume", async () => { - const state = sampleFixture(); + const state = validationFixture(); await assert.rejects(() => coordinateTask(state), /sample-tests failed/); - state.samplesHead = "c".repeat(40); + state.head = "c".repeat(40); state.nextRunStatus = "in_progress"; state.nextRunConclusion = null; let clock = 0; @@ -511,7 +583,7 @@ test("a timed-out replacement remains bound for the next resume", async () => { test("an explicitly rejected sample-test replacement can be dispatched on resume", async () => { for (const status of [403, 429]) { - const state = sampleFixture(); + const state = validationFixture(); await assert.rejects(() => coordinateTask(state), /sample-tests failed/); const remote = state.remote; state.remote = async (route, request) => { @@ -531,7 +603,7 @@ test("an explicitly rejected sample-test replacement can be dispatched on resume assert.equal(state.runs.length, 1); state.remote = remote; - state.samplesHead = "c".repeat(40); + state.head = "c".repeat(40); state.nextRunConclusion = "success"; const result = await coordinateTask(state); assert.equal(result.runId, 78); @@ -551,7 +623,7 @@ test("uncertain sample-test replacement outcomes stop without another dispatch", "missing-run-id", "receipt-write" ]) { - const state = sampleFixture(); + const state = validationFixture(); await assert.rejects(() => coordinateTask(state), /sample-tests failed/); const remote = state.remote; const record = state.github.rest.repos.createDeploymentStatus; @@ -593,7 +665,7 @@ test("uncertain sample-test replacement outcomes stop without another dispatch", }); test("an unresolved legacy sample-test rerun marker is not replaced blindly", async () => { - const state = sampleFixture(); + const state = validationFixture(); await assert.rejects(() => coordinateTask(state), /sample-tests failed/); state.statuses.push({ id: state.statuses.length + 1, @@ -612,7 +684,7 @@ test("an unresolved legacy sample-test rerun marker is not replaced blindly", as assert.equal(state.runs.length, 1); state.runs[0].run_attempt = 2; - state.samplesHead = "c".repeat(40); + state.head = "c".repeat(40); state.nextRunConclusion = "success"; const result = await coordinateTask(state); assert.equal(result.runId, 78); @@ -627,7 +699,7 @@ test("replacement sample tests require the recorded workflow, event, ref and a c { head_sha: "edge" }, { head_sha: null } ]) { - const state = sampleFixture(); + const state = validationFixture(); await assert.rejects(() => coordinateTask(state), /sample-tests failed/); state.nextRunConclusion = "success"; const remote = state.remote; @@ -640,7 +712,7 @@ test("replacement sample tests require the recorded workflow, event, ref and a c await assert.rejects( () => coordinateTask(state), Object.hasOwn(mismatch, "head_sha") ? - /no valid source commit/ + /no valid samples commit/ : /does not match/ ); assert.notEqual(state.statuses.at(-1).state, "success"); @@ -649,9 +721,9 @@ test("replacement sample tests require the recorded workflow, event, ref and a c }); test("an accepted replacement receipt is reused after its response is lost", async () => { - const state = sampleFixture(); + const state = validationFixture(); await assert.rejects(() => coordinateTask(state), /sample-tests failed/); - state.samplesHead = "c".repeat(40); + state.head = "c".repeat(40); state.nextRunConclusion = "success"; const record = state.github.rest.repos.createDeploymentStatus; state.github.rest.repos.createDeploymentStatus = async (request) => { @@ -673,7 +745,7 @@ test("uses native dispatch run IDs and resumes without duplicate work", async () const state = fixture(); const result = await coordinateTask(state); assert.equal(result.runId, 77); - assert.equal(result.pullRequest, state.pulls[1].html_url); + assert.equal(result.docsCommit, snapshots.docs); await coordinateTask(state); const dispatches = state.calls.filter((call) => call.route.endsWith("/dispatches") @@ -684,21 +756,58 @@ test("uses native dispatch run IDs and resumes without duplicate work", async () "2026-03-10" ); assert.equal(dispatches[0].request.request.retries, 0); + assert.deepEqual(dispatches[0].request.inputs, { + version: "0.61.0", + commit: snapshots.docs + }); assert.deepEqual(state.deployments[0].required_contexts, []); assert.equal(state.deployments[0].auto_merge, false); assert.equal(state.deployments[0].environment, "release-coordination"); assert.equal( state.deployments[0].task, - "release-coordination:v0.61.0-rc.1:docs-upmerge" + "release-coordination:v0.61.0:docs-release" ); - assert.equal(state.statuses.at(-1).environment_url, state.pulls[1].html_url); - // The bound pull request is read directly; the list is searched only once. assert.equal( - state.calls.filter((call) => call.route.endsWith("/pulls")).length, - 1 + state.statuses.at(-1).environment_url, + "https://github.com/radius-project/docs/tree/v0.61" ); }); +test("a release must branch vX.Y from the validated snapshot and keep edge as the default branch", async () => { + for (const [field, value, message] of [ + ["defaultBranch", "v0.61", /default branch is v0.61, not edge/], + // A channel cut from a newer edge commit still contains the snapshot. + ["mergeBase", "e".repeat(40), /not published from validated commit d{40}/], + ["comparison", "identical", /not published from validated commit/], + ["comparison", "behind", /not published from validated commit/] + ]) { + const state = fixture(); + state[field] = value; + await assert.rejects(() => coordinateTask(state), message); + assert.notEqual(state.statuses.at(-1).state, "success"); + state[field] = fixture()[field]; + await coordinateTask(state); + assert.equal(state.statuses.at(-1).state, "success"); + assert.equal( + state.calls.filter((call) => call.route.endsWith("/dispatches")).length, + 1, + "verification failures resume the same run" + ); + assert.ok( + state.calls.some( + ({ route, request }) => + route.endsWith("/compare/{basehead}") && + request.basehead === "edge...v0.61" + ) + ); + } + // edge advancing after publication leaves the branch point unchanged. + const state = fixture(); + state.comparison = "diverged"; + await coordinateTask(state); + assert.equal(state.statuses.at(-1).state, "success"); +}); + test("uncertain dispatch fails closed and cannot be repeated by resume", async () => { const state = fixture(); const remote = state.remote; @@ -740,280 +849,10 @@ test("an explicitly rejected dispatch can be dispatched again on resume", async } }); -test("an open upmerge PR is not a successful final-release gate", async () => { - const state = fixture(); - state.pulls[1].state = "open"; - state.pulls[1].merged = false; - await assert.rejects( - () => coordinateTask(state), - /Merge the docs upmerge PR https:\/\/github.com\/radius-project\/docs\/pull\/6/ - ); - assert.equal(state.statuses.at(-1).state, "in_progress"); - assert.equal(state.statuses.at(-1).environment_url, state.pulls[1].html_url); - // A squash merge leaves the source commits unreachable from edge; only the - // bound pull request's merge state decides. - state.pulls[1].state = "closed"; - state.pulls[1].merged = true; - await coordinateTask(state); - assert.equal(state.statuses.at(-1).state, "success"); - assert.equal( - state.calls.filter((call) => call.route.endsWith("/dispatches")).length, - 1 - ); - assert.equal( - state.calls.filter((call) => call.route.endsWith("/pulls")).length, - 1 - ); -}); - -test("an upmerge run that had nothing to merge is complete without a pull request", async () => { - const state = fixture(); - state.step.conclusion = "skipped"; - const result = await coordinateTask(state); - assert.equal(result.state, "success"); - assert.equal(result.pullRequest, undefined); - assert.equal( - state.calls.some((call) => call.route.endsWith("/pulls")), - false - ); -}); - -test("an upmerge pull request that cannot be bound exactly stops for reconciliation", async () => { - const state = fixture(); - state.pulls[0].created_at = state.pulls[1].created_at; - await assert.rejects( - () => coordinateTask(state), - /2 upmerge pull requests match/ - ); - assert.notEqual(state.statuses.at(-1).state, "success"); - // An operator binding on the receipt is honored on resume. - state.statuses.push({ - id: 50, - deployment_id: state.deployments[0].id, - state: "in_progress", - log_url: state.run.html_url, - environment_url: state.pulls[1].html_url - }); - const result = await coordinateTask(state); - assert.equal(result.pullRequest, state.pulls[1].html_url); -}); - -test("a closed unmerged upmerge reruns all jobs and binds the replacement PR", async () => { - const state = fixture(); - state.pulls[1].state = "open"; - state.pulls[1].merged = false; - await assert.rejects( - () => coordinateTask(state), - /Merge the docs upmerge PR/ - ); - const original = state.pulls[1]; - original.state = "closed"; - - await assert.rejects(() => coordinateTask(state), /upmerge PR .*\/pull\/7/); - const replacement = state.pulls.at(-1); - assert.equal(original.state, "closed"); - assert.equal(original.merged, false); - assert.equal(state.run.run_attempt, 2); - assert.equal(state.deployments.length, 1); - assert.equal(state.statuses.at(-1).state, "in_progress"); - assert.equal(state.statuses.at(-1).environment_url, replacement.html_url); - assert.equal( - state.statuses.find( - (status) => status.description === "Retry after attempt 1" - ).environment_url, - "" - ); - replacement.state = "closed"; - replacement.merged = true; - const result = await coordinateTask(state); - assert.equal(result.pullRequest, replacement.html_url); - assert.equal(state.statuses.at(-1).state, "success"); - assert.equal( - state.calls.filter(({ route }) => route.endsWith("/dispatches")).length, - 1 - ); - assert.equal( - state.calls.filter(({ route }) => route.endsWith("/rerun")).length, - 1 - ); - assert.equal( - state.calls.filter(({ route }) => route.endsWith("/rerun-failed-jobs")) - .length, - 0 - ); -}); - -test("a replacement upmerge with no changes clears the closed PR binding", async () => { - const state = fixture(); - state.pulls[1].state = "open"; - state.pulls[1].merged = false; - await assert.rejects( - () => coordinateTask(state), - /Merge the docs upmerge PR/ - ); - state.pulls[1].state = "closed"; - const remote = state.remote; - state.remote = async (route, request) => { - const result = await remote(route, request); - if (route.endsWith("/rerun")) state.step.conclusion = "skipped"; - return result; - }; - const result = await coordinateTask(state); - assert.equal(result.state, "success"); - assert.equal(result.pullRequest, undefined); - assert.equal(state.statuses.at(-1).environment_url, ""); -}); - -test("rejected replacements preserve bound PRs and retry without redispatching", async () => { - for (const [status, manuallyBound] of [ - [403, true], - [429, true], - [403, false], - [429, false] - ]) { - const state = fixture(); - state.pulls[1].state = "open"; - state.pulls[1].merged = false; - if (manuallyBound) { - state.pulls[0].created_at = state.pulls[1].created_at; - await assert.rejects( - () => coordinateTask(state), - /2 upmerge pull requests match/ - ); - state.statuses.push({ - id: state.statuses.length + 1, - deployment_id: state.deployments[0].id, - state: "in_progress", - log_url: state.run.html_url, - environment_url: state.pulls[1].html_url - }); - } - await assert.rejects( - () => coordinateTask(state), - /Merge the docs upmerge PR/ - ); - state.pulls[1].state = "closed"; - const remote = state.remote; - state.remote = async (route, request) => { - if (route.endsWith("/rerun")) { - state.calls.push({ route, request }); - throw Object.assign(new Error("replacement rejected"), { status }); - } - return remote(route, request); - }; - await assert.rejects(() => coordinateTask(state), /replacement rejected/); - const rejection = state.statuses.at(-1); - assert.equal(state.run.run_attempt, 1); - assert.equal( - state.statuses.find( - (entry) => entry.description === "Retry after attempt 1" - ).environment_url, - "" - ); - state.remote = remote; - await assert.rejects(() => coordinateTask(state), /upmerge PR .*\/pull\/7/); - assert.equal(rejection.state, "failure"); - assert.equal(rejection.environment_url, state.pulls[1].html_url); - assert.equal(state.run.run_attempt, 2); - assert.equal( - state.statuses.at(-1).environment_url, - state.pulls[2].html_url - ); - assert.equal( - state.calls.filter(({ route }) => route.endsWith("/pulls")).length, - 2, - "resume must not rediscover the original bound PR" - ); - assert.equal( - state.calls.filter(({ route }) => route.endsWith("/dispatches")).length, - 1 - ); - assert.equal( - state.calls.filter(({ route }) => route.endsWith("/rerun")).length, - 2 - ); - } -}); - -test("an uncertain replacement request is not repeated on resume", async () => { - const state = fixture(); - state.pulls[1].state = "open"; - state.pulls[1].merged = false; - await assert.rejects( - () => coordinateTask(state), - /Merge the docs upmerge PR/ - ); - state.pulls[0].created_at = state.pulls[1].created_at; - state.pulls[1].state = "closed"; - const remote = state.remote; - state.remote = async (route, request) => { - if (route.endsWith("/rerun")) { - state.calls.push({ route, request }); - throw new Error("lost replacement response"); - } - return remote(route, request); - }; - await assert.rejects( - () => coordinateTask(state), - /lost replacement response/ - ); - assert.equal(state.statuses.at(-1).description, "Retry after attempt 1"); - assert.equal(state.statuses.at(-1).environment_url, ""); - let clock = 0; - state.now = () => clock; - state.deadline = 10; - state.sleep = async () => { - clock += 10; - }; - await assert.rejects(() => coordinateTask(state), /Timed out monitoring/); - assert.equal( - state.calls.filter(({ route }) => route.endsWith("/rerun")).length, - 1 - ); - - state.step.started_at = "2026-09-10T10:01:00Z"; - state.step.completed_at = "2026-09-10T10:01:03Z"; - state.run.run_attempt = 2; - state.pulls.push({ - ...state.pulls[1], - number: 7, - html_url: "https://github.com/radius-project/docs/pull/7", - created_at: "2026-09-10T10:01:01Z", - state: "open", - head: { ref: "upmerge/77-2" } - }); - await assert.rejects(() => coordinateTask(state), /upmerge PR .*\/pull\/7/); - assert.equal( - state.calls.filter(({ route }) => route.endsWith("/rerun")).length, - 1 - ); -}); - -test("a replacement closed immediately requires another resume rather than a loop", async () => { - const state = fixture(); - state.pulls[1].state = "closed"; - state.pulls[1].merged = false; - const remote = state.remote; - state.remote = async (route, request) => { - const result = await remote(route, request); - if (route.endsWith("/rerun")) state.pulls.at(-1).state = "closed"; - return result; - }; - await assert.rejects( - () => coordinateTask(state), - /replacement upmerge PR closed/ - ); - assert.equal( - state.calls.filter(({ route }) => route.endsWith("/rerun")).length, - 1 - ); - assert.equal(state.statuses.at(-1).state, "failure"); -}); - test("failed downstream work retries the same run ID", async () => { const state = fixture(); state.run.conclusion = "failure"; - await assert.rejects(() => coordinateTask(state), /docs-upmerge failed/); + await assert.rejects(() => coordinateTask(state), /docs-release failed/); await coordinateTask(state); assert.equal(state.run.run_attempt, 2); assert.equal( @@ -1032,7 +871,7 @@ test("an explicitly rejected rerun can be requested again on resume", async () = const state = fixture(); const remote = state.remote; state.run.conclusion = "failure"; - await assert.rejects(() => coordinateTask(state), /docs-upmerge failed/); + await assert.rejects(() => coordinateTask(state), /docs-release failed/); state.remote = async (route, request) => { if (route.endsWith("/rerun-failed-jobs")) { state.calls.push({ route, request }); @@ -1064,7 +903,7 @@ test("an uncertain rerun outcome is never requested twice", async () => { clock += 10; }; state.run.conclusion = "failure"; - await assert.rejects(() => coordinateTask(state), /docs-upmerge failed/); + await assert.rejects(() => coordinateTask(state), /docs-release failed/); state.remote = async (route, request) => { if (route.endsWith("/rerun-failed-jobs")) { state.calls.push({ route, request }); @@ -1082,12 +921,21 @@ test("an uncertain rerun outcome is never requested twice", async () => { ); }); -test("rejects a conflicting source and a receipt pointing to another workflow", async () => { +test("rejects a conflicting source, snapshot or ref and a receipt pointing to another workflow", async () => { const state = fixture(); await coordinateTask(state); state.sourceSha = "b".repeat(40); await assert.rejects(() => coordinateTask(state), /Conflicting/); state.sourceSha = "a".repeat(40); + state.task = coordinationTasks("final", state.version, { + ...snapshots, + docs: "e".repeat(40) + })[0]; + await assert.rejects(() => coordinateTask(state), /Conflicting/); + state.task = { ...coordinationTasks("final", state.version, snapshots)[0] }; + state.deployments[0].payload.ref = "v0.61"; + await assert.rejects(() => coordinateTask(state), /Conflicting/); + state.deployments[0].payload.ref = "edge"; state.run.workflow_id = 88; await assert.rejects(() => coordinateTask(state), /does not match/); }); @@ -1101,46 +949,119 @@ test("final preparation rejects an RC without complete coordination receipts", a plan: { releaseType: "final", version: "v0.61.0", - previousVersion: state.version + previousVersion: "v0.61.0-rc.1" } }), - /not verified/ + /docs-validation is not verified/ ); - await checkReleaseCandidate({ ...state, plan: { releaseType: "patch" } }); assert.deepEqual( - coordinationTasks("patch", "v0.61.1").map((task) => task.id), - ["sample-tests"] - ); - assert.deepEqual( - coordinationTasks("final", "v0.61.0").map((task) => task.id), - ["docs-release", "samples-release", "sample-tests"] + await checkReleaseCandidate({ ...state, plan: { releaseType: "patch" } }), + {} ); }); -test("final preparation accepts all source-bound RC gates and rejects a later failure", async () => { - const state = fixture(); +test("final preparation returns the RC's validated snapshots and rejects a later failure", async () => { + const candidate = "v0.61.0-rc.1"; const plan = { releaseType: "final", version: "v0.61.0", - previousVersion: state.version + previousVersion: candidate }; - for (const task of coordinationTasks("rc", state.version)) { - const id = state.deployments.length + 1; - state.deployments.push({ - id, - environment: "release-coordination", - task: `release-coordination:${state.version}:${task.id}`, - sha: state.sourceSha, - payload: { task, version: state.version, sourceSha: state.sourceSha } - }); - state.statuses.push({ id, deployment_id: id, state: "success" }); - } - await checkReleaseCandidate({ ...state, plan }); - state.statuses.push({ id: 99, deployment_id: 3, state: "failure" }); + let state = fixture(); + recordCandidate(state, candidate); + assert.deepEqual(await checkReleaseCandidate({ ...state, plan }), snapshots); + state.statuses.push({ + id: 2000, + deployment_id: state.deployments[1].id, + state: "failure" + }); await assert.rejects( () => checkReleaseCandidate({ ...state, plan }), /sample-tests is not verified/ ); + + for (const environmentUrl of [ + undefined, + "", + "https://github.com/radius-project/docs/pull/5", + "https://github.com/radius-project/samples/commit/" + "d".repeat(40), + "https://github.com/radius-project/docs/commit/edge" + ]) { + state = fixture(); + recordCandidate(state, candidate); + state.statuses[0].environment_url = environmentUrl; + await assert.rejects( + () => checkReleaseCandidate({ ...state, plan }), + /docs-validation recorded no validated docs commit/ + ); + } +}); + +test("later final gates require the plan to pin exactly the RC's validated snapshots", async () => { + const candidate = "v0.61.0-rc.1"; + const plan = { + releaseType: "final", + version: "v0.61.0", + previousVersion: candidate + }; + const state = fixture(); + recordCandidate(state, candidate); + // Preparation reads the snapshots before the plan exists. + assert.deepEqual(await checkReleaseCandidate({ ...state, plan }), snapshots); + await assert.rejects( + () => checkReleaseCandidate({ ...state, plan, requirePins: true }), + /no valid docsSourceCommit; rerun Prepare Release/ + ); + const pinned = { + ...plan, + docsSourceCommit: snapshots.docs, + samplesSourceCommit: snapshots.samples + }; + assert.deepEqual( + await checkReleaseCandidate({ ...state, plan: pinned, requirePins: true }), + snapshots + ); + for (const change of [ + { samplesSourceCommit: "e".repeat(40) }, + { docsSourceCommit: "edge" } + ]) { + await assert.rejects( + () => + checkReleaseCandidate({ + ...state, + plan: { ...pinned, ...change }, + requirePins: true + }), + /pins samples e{40}, but v0\.61\.0-rc\.1 validated 5{40}|no valid docsSourceCommit/ + ); + } + // A receipt replaced after approval no longer matches the approved pin. + state.statuses.push({ + id: 2000, + deployment_id: state.deployments[0].id, + state: "success", + environment_url: `https://github.com/radius-project/docs/commit/${"e".repeat(40)}` + }); + await assert.rejects( + () => checkReleaseCandidate({ ...state, plan: pinned, requirePins: true }), + /pins docs d{40}, but v0\.61\.0-rc\.1 validated e{40}; cut another RC/ + ); +}); + +test("a successful validation is final even if its remote run is rerun later", async () => { + const state = validationFixture(); + state.nextRunConclusion = "success"; + const first = await coordinateTask(state); + assert.equal(first.samplesCommit, "b".repeat(40)); + // Someone reruns the remote run and it fails; edge has also advanced. + state.runs[0].run_attempt = 2; + state.runs[0].conclusion = "failure"; + state.head = "c".repeat(40); + const statuses = state.statuses.length; + const result = await coordinateTask(state); + assert.deepEqual(result, first); + assert.equal(state.statuses.length, statuses, "the receipt is not rewritten"); + assert.equal(state.runs.length, 1, "no replacement run is dispatched"); }); test("monitor timeout retains exact run correlation for the next resume", async () => { @@ -1162,17 +1083,86 @@ test("monitor timeout retains exact run correlation for the next resume", async ); }); -test("sample tests are not dispatched while either RC upmerge is incomplete", async () => { +test("Prepare Release reads both validated RC snapshots into its step outputs", async (t) => { + const workflow = ( + await readFile( + new URL("../workflows/prepare-release.yaml", import.meta.url), + "utf8" + ) + ).replace(/\r\n/g, "\n"); + const step = workflow.match( + / id: content-snapshots\n[\s\S]*? script: \|\n([\s\S]*?)(?=\n\n - name:)/ + ); + assert.ok(step, "the snapshot step must exist"); + assert.match(step[0], / INPUT_MODE: read-rc\n/); + assert.match( + workflow, + /DOCS_SOURCE_COMMIT: \$\{\{ steps\.content-snapshots\.outputs\.docs-commit \}\}/ + ); + assert.match( + workflow, + /SAMPLES_SOURCE_COMMIT: \$\{\{ steps\.content-snapshots\.outputs\.samples-commit \}\}/ + ); + const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor; + const stepScript = new AsyncFunction( + "github", + "context", + "core", + "process", + step[1].replace(/^ /gm, "") + ); + const directory = await mkdtemp(path.join(os.tmpdir(), "read-rc-")); + t.after(() => rm(directory, { recursive: true, force: true })); const state = fixture(); + const candidate = "v0.61.0-rc.1"; + recordCandidate(state, candidate); + const env = { + INPUT_MODE: "read-rc", + VERSION: "v0.61.0", + RELEASE_CANDIDATE: candidate, + RUNNER_TEMP: directory, + GITHUB_WORKSPACE: new URL("../../", import.meta.url).href.replace(/\/$/, "") + }; + const outputs = {}; + // Like actions/core, inputs come from INPUT_* variables the step may set. + const core = { + getInput: (name, options) => { + const value = env[`INPUT_${name}`] ?? ""; + if (options?.required && !value) throw new Error(`Missing ${name}`); + return value; + }, + setOutput: (name, value) => { + outputs[name] = value; + } + }; + await stepScript(state.github, state.context, core, { env }); + assert.deepEqual(outputs, { + "docs-commit": snapshots.docs, + "samples-commit": snapshots.samples + }); + + // An RC without a validated receipt yields no snapshot to pin. + const missing = fixture(); + await assert.rejects( + () => stepScript(missing.github, missing.context, core, { env }), + /docs-validation is not verified/ + ); +}); + +test("a final publishes its RC's snapshots, not newer edge, and then tests the stable branch", async (t) => { const directory = await mkdtemp( path.join(os.tmpdir(), "coordinate-release-") ); - try { - const planFile = path.join(directory, "plan.json"); - await writeFile( - planFile, - JSON.stringify({ version: state.version, releaseType: "rc" }) - ); + t.after(() => rm(directory, { recursive: true, force: true })); + const state = fixture(); + state.remote = downstreamRemote(state); + state.github.rest.repos.listReleases = async () => [ + { tag_name: "v0.63.0-rc.1", draft: false }, + { tag_name: "v0.63.0", draft: false } + ]; + const coordinate = async (plan) => { + const planFile = path.join(directory, `${plan.version}.json`); + await writeFile(planFile, JSON.stringify(plan)); const outputs = {}; state.core = { getInput: (name) => @@ -1181,24 +1171,103 @@ test("sample tests are not dispatched while either RC upmerge is incomplete", as outputs[name] = value; } }; - state.pulls[1].state = "open"; - state.pulls[1].merged = false; - await assert.rejects(() => coordinateRelease(state), /Sample tests wait/); - assert.equal( - state.calls.some( - (call) => - call.route.endsWith("/dispatches") && - call.request.workflow_id === "test.yaml" - ), - false - ); - assert.equal( - JSON.parse(outputs.results).find( - (result) => result.name === "sample-tests" - ).state, - "incomplete" - ); - } finally { - await rm(directory, { recursive: true, force: true }); - } + try { + await coordinateRelease(state); + } finally { + state.results = outputs.results && JSON.parse(outputs.results); + } + }; + + state.heads = { + "docs:edge": snapshots.docs, + "samples:edge": snapshots.samples + }; + await coordinate({ version: "v0.63.0-rc.1", releaseType: "rc" }); + assert.deepEqual( + state.results.map(({ name, docsCommit, samplesCommit }) => [ + name, + docsCommit ?? samplesCommit + ]), + [ + ["docs-validation", snapshots.docs], + ["sample-tests", snapshots.samples] + ] + ); + + // edge moves on after the RC; the final must not pick that content up. + state.heads = { + "docs:edge": "e".repeat(40), + "samples:edge": "e".repeat(40), + "samples:v0.63": "f".repeat(40) + }; + state.dispatches.length = 0; + state.conclusions["samples:release.yaml"] = "failure"; + const final = { + version: "v0.63.0", + releaseType: "final", + previousVersion: "v0.63.0-rc.1", + docsSourceCommit: snapshots.docs, + samplesSourceCommit: snapshots.samples + }; + // A final without approved pins cannot be coordinated. + await assert.rejects( + () => + coordinate({ + version: final.version, + releaseType: "final", + previousVersion: final.previousVersion + }), + /rerun Prepare Release/ + ); + assert.deepEqual(state.dispatches, []); + await assert.rejects(() => coordinate(final), /wait for the samples release/); + assert.deepEqual( + state.dispatches.map(({ repo, workflow_id, ref, inputs }) => [ + repo, + workflow_id, + ref, + inputs + ]), + [ + [ + "docs", + "release.yaml", + "edge", + { version: "0.63.0", commit: snapshots.docs } + ], + [ + "samples", + "release.yaml", + "edge", + { version: "0.63.0", commit: snapshots.samples } + ] + ] + ); + assert.equal( + state.results.find(({ name }) => name === "sample-tests").state, + "incomplete" + ); + + // Resume reruns the failed publication job; only then do final tests start. + delete state.conclusions["samples:release.yaml"]; + state.dispatches.length = 0; + await coordinate(final); + assert.equal( + state.calls.filter(({ route }) => route.endsWith("/rerun-failed-jobs")) + .length, + 1 + ); + assert.deepEqual( + state.dispatches.map(({ repo, workflow_id, ref, inputs }) => [ + repo, + workflow_id, + ref, + inputs + ]), + [["samples", "test.yaml", "v0.63", { version: "0.63.0" }]] + ); + assert.equal( + state.results.find(({ name }) => name === "sample-tests").samplesCommit, + "f".repeat(40) + ); }); diff --git a/.github/scripts/prepare-release.sh b/.github/scripts/prepare-release.sh index a33e02624e..6c2c382a10 100644 --- a/.github/scripts/prepare-release.sh +++ b/.github/scripts/prepare-release.sh @@ -53,7 +53,8 @@ Usage: prepare-release.sh --release-type --channel \ --backports-file --sibling-repositories-file \ --output-dir [file options] -Final preparation requires RECIPE_SOURCE_COMMIT from contrib main. +Final preparation requires RECIPE_SOURCE_COMMIT from contrib main, and +DOCS_SOURCE_COMMIT and SAMPLES_SOURCE_COMMIT validated by the last RC. File options: --versions-file @@ -550,7 +551,9 @@ write_release_plan() { ' > "${plan_file}" if [[ "${RELEASE_TYPE}" == final ]]; then - yq -i '.recipeSourceCommit = strenv(RECIPE_SOURCE_COMMIT)' \ + yq -i '.recipeSourceCommit = strenv(RECIPE_SOURCE_COMMIT) | + .docsSourceCommit = strenv(DOCS_SOURCE_COMMIT) | + .samplesSourceCommit = strenv(SAMPLES_SOURCE_COMMIT)' \ "${plan_file}" fi mkdir -p "$(dirname "${tracked_plan_file}")" @@ -575,6 +578,7 @@ write_release_plan() { echo "- [ ] Verify the source commit and included backports." if [[ "${RELEASE_TYPE}" == final ]]; then echo "- [ ] Review the [Bicep recipe source](https://github.com/radius-project/resource-types-contrib/commit/${RECIPE_SOURCE_COMMIT}) and its signed recipe inventory." + echo "- [ ] Review the [docs](https://github.com/radius-project/docs/commit/${DOCS_SOURCE_COMMIT}) and [samples](https://github.com/radius-project/samples/commit/${SAMPLES_SOURCE_COMMIT}) commits validated by the last RC; this final publishes exactly those." fi if [[ "${requires_backport}" == "true" ]]; then echo "- [ ] Rebase-merge this PR's generated backport after merge." @@ -693,6 +697,10 @@ main() { if [[ "${RELEASE_TYPE}" == final && ! "${RECIPE_SOURCE_COMMIT:-}" =~ ^[0-9a-f]{40}$ ]]; then fail "final preparation requires a full RECIPE_SOURCE_COMMIT" fi + if [[ "${RELEASE_TYPE}" == final ]] && + [[ ! "${DOCS_SOURCE_COMMIT:-}" =~ ^[0-9a-f]{40}$ || ! "${SAMPLES_SOURCE_COMMIT:-}" =~ ^[0-9a-f]{40}$ ]]; then + fail "final preparation requires full DOCS_SOURCE_COMMIT and SAMPLES_SOURCE_COMMIT values from the last RC" + fi [[ -f "${TARGETS_FILE}" ]] || fail "release targets file not found" [[ -f "${CLIFF_CONFIG}" ]] || fail "git-cliff config not found" require_command jq diff --git a/.github/scripts/prepare-release_test.sh b/.github/scripts/prepare-release_test.sh index 744054bd61..db3457bcbf 100644 --- a/.github/scripts/prepare-release_test.sh +++ b/.github/scripts/prepare-release_test.sh @@ -192,6 +192,8 @@ run_prepare() { cd "${REPO}" \ && GIT_CLIFF="${renderer}" \ RECIPE_SOURCE_COMMIT="${RECIPE_SOURCE_COMMIT-eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee}" \ + DOCS_SOURCE_COMMIT="${DOCS_SOURCE_COMMIT-dddddddddddddddddddddddddddddddddddddddd}" \ + SAMPLES_SOURCE_COMMIT="${SAMPLES_SOURCE_COMMIT-5555555555555555555555555555555555555555}" \ CHANGELOG_RANGE_SCRIPT="${range_script}" \ bash "${SCRIPT}" \ --release-type "${release_type}" \ @@ -647,14 +649,31 @@ test_final() { fail_test "final preparation must not guess a missing recipe source" return fi + for snapshot in DOCS_SOURCE_COMMIT SAMPLES_SOURCE_COMMIT; do + if [[ "${snapshot}" == DOCS_SOURCE_COMMIT ]]; then + DOCS_SOURCE_COMMIT=main run_prepare final 0.60 + else + SAMPLES_SOURCE_COMMIT="" run_prepare final 0.60 + fi + if [[ "${LAST_STATUS}" == 0 || "${LAST_OUTPUT}" != *"${snapshot}"* ]]; then + fail_test "final preparation must require the RC-validated ${snapshot}" + return + fi + done run_prepare final 0.60 assert_version "v0.60.0" || return assert_file_contains "${REPO}/out/release-plan.yaml" \ 'releaseType: final' || return assert_yq_value "${REPO}/.github/release-plans/v0.60.0.yaml" \ '.recipeSourceCommit' 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' || return + assert_yq_value "${REPO}/.github/release-plans/v0.60.0.yaml" \ + '.docsSourceCommit' 'dddddddddddddddddddddddddddddddddddddddd' || return + assert_yq_value "${REPO}/.github/release-plans/v0.60.0.yaml" \ + '.samplesSourceCommit' '5555555555555555555555555555555555555555' || return assert_file_contains "${REPO}/out/release-pr-body.md" \ 'recipeSourceCommit: eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' || return + assert_file_contains "${REPO}/out/release-pr-body.md" \ + 'docs/commit/dddddddddddddddddddddddddddddddddddddddd' || return assert_file_contains "${REPO}/out/requires-backport.txt" 'true' || return assert_file_contains "${REPO}/docs/release-notes/v0.60.0.md" \ '## Upgrading to Radius v0.60.0' || return diff --git a/.github/scripts/release-status.mjs b/.github/scripts/release-status.mjs index c13ae8f3cf..1fc4fcd3dc 100644 --- a/.github/scripts/release-status.mjs +++ b/.github/scripts/release-status.mjs @@ -30,6 +30,7 @@ export function releaseStatus({ ...downstream.map( (entry) => `${entry.name}: ${entry.state} ${entry.url ?? entry.recovery ?? ""}` + + (entry.docsCommit ? ` (docs commit ${entry.docsCommit})` : "") + (entry.samplesCommit ? ` (samples commit ${entry.samplesCommit})` : "") ) ]; diff --git a/.github/scripts/release-status_test.mjs b/.github/scripts/release-status_test.mjs index 131caa0afc..5aef8455f8 100644 --- a/.github/scripts/release-status_test.mjs +++ b/.github/scripts/release-status_test.mjs @@ -63,10 +63,12 @@ test("summaries remain actionable when verification failed before producing a ma assert.match(report.markdown, /Resume the same run/); }); -test("sample-test summaries distinguish the tested commit from the Radius source", () => { +test("validation summaries distinguish the tested commits from the Radius source", () => { const sourceSha = "a".repeat(40); const samplesCommit = "b".repeat(40); + const docsCommit = "c".repeat(40); const url = "https://github.com/radius-project/samples/actions/runs/78"; + const docsUrl = "https://github.com/radius-project/docs/actions/runs/79"; const report = releaseStatus({ version: "v0.61.0-rc.1", sourceSha, @@ -74,9 +76,17 @@ test("sample-test summaries distinguish the tested commit from the Radius source state: "success", releaseState: "published", runUrl: "https://github.com/radius-project/radius/actions/runs/12", - downstream: [{ name: "sample-tests", state: "success", url, samplesCommit }] + downstream: [ + { name: "docs-validation", state: "success", url: docsUrl, docsCommit }, + { name: "sample-tests", state: "success", url, samplesCommit } + ] }); assert.ok(report.markdown.includes(`Source: ${sourceSha}`)); + assert.ok( + report.markdown.includes( + `docs-validation: success ${docsUrl} (docs commit ${docsCommit})` + ) + ); assert.ok( report.markdown.includes( `sample-tests: success ${url} (samples commit ${samplesCommit})` diff --git a/.github/scripts/resolve-release-controller.mjs b/.github/scripts/resolve-release-controller.mjs index 433a5073ed..73029bffed 100644 --- a/.github/scripts/resolve-release-controller.mjs +++ b/.github/scripts/resolve-release-controller.mjs @@ -209,6 +209,8 @@ export async function verifyReleaseBuildSource({ github, core, run = tool }) { "--expected-targets", targetsFile ]; + // A published release may resume with its tagged docs/samples coordinator. + if (!manifest) args.push("--require-current-coordination"); if (plan.changelogPolicy === "stable-only") args.push("--require-sibling-releases"); if (!manifest) diff --git a/.github/scripts/resolve-release-controller_test.mjs b/.github/scripts/resolve-release-controller_test.mjs index f5fd2e1c5a..f861b8ab67 100644 --- a/.github/scripts/resolve-release-controller_test.mjs +++ b/.github/scripts/resolve-release-controller_test.mjs @@ -194,6 +194,11 @@ test("published historical sources retain validation and recovery; unpublished s ]); assert.ok(args.includes("--require-sibling-releases")); assert.ok(args.includes("--expected-targets")); + assert.equal( + args.includes("--require-current-coordination"), + ["draft", "absent"].includes(state), + "only unpublished sources need the current docs/samples coordinator" + ); assert.deepEqual( JSON.parse( await readFile(args[args.indexOf("--expected-targets") + 1], "utf8") diff --git a/.github/scripts/validate-release-plan.sh b/.github/scripts/validate-release-plan.sh index 512579e3a7..253833b0d6 100644 --- a/.github/scripts/validate-release-plan.sh +++ b/.github/scripts/validate-release-plan.sh @@ -212,7 +212,7 @@ validate_generated_contents() { local release_date="$4" local plan_path="$5" local expected_backports planned_siblings expected_notes actual_notes - local recipe_commit="" plan_format='.' + local recipe_commit="" docs_commit="" samples_commit="" content_commits plan_format='.' expected_backports="${BACKPORTS_FILE}" canonical_json "${TEMP_DIR}/release-plan.yaml" '.includedBackports' \ @@ -231,10 +231,18 @@ validate_generated_contents() { if [[ "${release_type}" == final ]]; then recipe_commit="$(bash "${SCRIPT_DIR}/resolve-recipe-source.sh" \ "${TEMP_DIR}/release-plan.yaml")" + # The build checks these pins against the last RC's receipts. + content_commits="$(yq -o=json -I=0 'to_entries' "${TEMP_DIR}/release-plan.yaml" | jq -ers ' + select(length == 1) | .[0] | select(length == (unique_by(.key) | length)) | + from_entries | [.docsSourceCommit, .samplesSourceCommit] | + select(all(.[]; type == "string" and test("^[0-9a-f]{40}\\z"))) | join(" ") + ')" || fail "a final plan must pin unambiguous docsSourceCommit and samplesSourceCommit values" + read -r docs_commit samples_commit <<<"${content_commits}" # Keep duplicate top-level keys visible in the committed copy too. plan_format='to_entries | sort_by(.key)' fi - RECIPE_SOURCE_COMMIT="${recipe_commit}" regenerate_release \ + RECIPE_SOURCE_COMMIT="${recipe_commit}" DOCS_SOURCE_COMMIT="${docs_commit}" \ + SAMPLES_SOURCE_COMMIT="${samples_commit}" regenerate_release \ "${release_type}" "${channel}" "${release_date}" \ "${expected_backports}" "${planned_siblings}" diff --git a/.github/scripts/validate-release-plan_test.sh b/.github/scripts/validate-release-plan_test.sh index b562f29736..9cb3a7e9c1 100644 --- a/.github/scripts/validate-release-plan_test.sh +++ b/.github/scripts/validate-release-plan_test.sh @@ -374,6 +374,8 @@ EOF yq -o=json '.siblingRepositories' "${EXPECTED_PLAN}" > "${siblings}" FAKE_PREPARE="${SCRIPT_DIR}/prepare-release.sh" if ! GITHUB_TOKEN="" RECIPE_SOURCE_COMMIT="${recipe_commit}" \ + DOCS_SOURCE_COMMIT=dddddddddddddddddddddddddddddddddddddddd \ + SAMPLES_SOURCE_COMMIT=5555555555555555555555555555555555555555 \ run_with_fixture bash "${FAKE_PREPARE}" \ --release-type "${release_type}" --channel 0.61 \ --release-date 2026-08-24 \ @@ -415,7 +417,9 @@ EOF fi for mutation in 'del(.recipeSourceCommit)' \ '.recipeSourceCommit = "main"' \ - '.recipeSourceCommit = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"'; do + '.recipeSourceCommit = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"' \ + 'del(.docsSourceCommit)' \ + '.samplesSourceCommit = "edge"'; do yq "${mutation}" "${output}/release-plan.yaml" > "${EXPECTED_PLAN}" wrap_body cp "${EXPECTED_PLAN}" "${HEAD_DIR}/${plan}" @@ -423,7 +427,7 @@ EOF fail_test "final regeneration accepted ${mutation}" return fi - if ! grep -Eq 'recipeSourceCommit|not reachable from resource-types-contrib' "${log}"; then + if ! grep -Eq 'recipeSourceCommit|not reachable from resource-types-contrib|docsSourceCommit and samplesSourceCommit' "${log}"; then cat "${log}" fail_test "final regeneration must reject ${mutation}" return diff --git a/.github/scripts/verify-release-build-contract.sh b/.github/scripts/verify-release-build-contract.sh index b46cc7ef2a..3352a939a8 100644 --- a/.github/scripts/verify-release-build-contract.sh +++ b/.github/scripts/verify-release-build-contract.sh @@ -32,6 +32,7 @@ BICEP_DUAL_PIPELINE=false GHCR_ONLY=false REQUIRE_CURRENT_BICEP=false REQUIRE_CURRENT_ENGINE=false +REQUIRE_CURRENT_COORDINATION=false fail() { echo "Error: $*" >&2 @@ -481,7 +482,7 @@ verify_historical_bicep_resume_gate() { main() { local job name - [[ $# -ge 1 ]] || fail "usage: verify-release-build-contract.sh [--require-sibling-releases] [--expected-targets ] [--require-current-bicep] [--require-current-engine]" + [[ $# -ge 1 ]] || fail "usage: verify-release-build-contract.sh [--require-sibling-releases] [--expected-targets ] [--require-current-bicep] [--require-current-engine] [--require-current-coordination]" local revision="$1" shift EXPECTED_TARGETS="" @@ -490,6 +491,7 @@ main() { --require-sibling-releases) REQUIRE_SIBLING_RELEASES=true; shift ;; --require-current-bicep) REQUIRE_CURRENT_BICEP=true; shift ;; --require-current-engine) REQUIRE_CURRENT_ENGINE=true; shift ;; + --require-current-coordination) REQUIRE_CURRENT_COORDINATION=true; shift ;; --expected-targets) [[ $# -ge 2 && -f "$2" ]] || fail "expected targets JSON is required" EXPECTED_TARGETS="$2"; shift 2 ;; @@ -556,6 +558,13 @@ main() { fi done < <(git ls-tree --name-only "${COMMIT}:.github/workflows") + # docs and samples publish validated snapshots and no longer have upmerge + # workflows. Published releases may still resume with their tagged scripts. + if [[ "${REQUIRE_CURRENT_COORDINATION}" == true ]] && + git grep -q -F 'upmerge.yaml' "${COMMIT}" -- .github/scripts/coordinate-release.mjs; then + reject "still coordinates retired docs and samples upmerges" + fi + if [[ "${REQUIRE_BICEP_RECIPES:-false}" == true ]]; then yq_true "${BUILD_WORKFLOW}" ' [.jobs."coordinate-release".steps[] | diff --git a/.github/scripts/verify-release-build-contract_test.sh b/.github/scripts/verify-release-build-contract_test.sh index 368aa809f6..5ad7b3b56d 100644 --- a/.github/scripts/verify-release-build-contract_test.sh +++ b/.github/scripts/verify-release-build-contract_test.sh @@ -367,6 +367,14 @@ main() { cp "${ROOT}/.github/scripts/coordinate-release.mjs" "${REPO}/.github/scripts/" REQUIRE_BICEP_RECIPES=true expect pass "new finals require the recipe coordinator" HEAD --require-sibling-releases + local coordinator="${REPO}/.github/scripts/coordinate-release.mjs" + printf '\nconst retired = { workflow: "upmerge.yaml" };\n' >>"${coordinator}" + expect pass "published resume keeps its tagged upmerge coordinator" + expect "still coordinates retired docs and samples upmerges" \ + "new release cannot use an upmerge coordinator" HEAD --require-current-coordination + cp "${ROOT}/.github/scripts/coordinate-release.mjs" "${coordinator}" + expect pass "current coordinator needs no upmerge" HEAD --require-current-coordination + rm "${REPO}/.github/scripts/coordinate-release.mjs" REQUIRE_BICEP_RECIPES=true expect "does not coordinate the Bicep recipe publisher" \ "new final cannot use an old coordination script" diff --git a/.github/workflows/build-release.yaml b/.github/workflows/build-release.yaml index 0a097d8c87..0d17e74a2e 100644 --- a/.github/workflows/build-release.yaml +++ b/.github/workflows/build-release.yaml @@ -1444,7 +1444,6 @@ jobs: repositories: docs,samples permission-actions: write permission-contents: read - permission-pull-requests: read - name: Get final Bicep recipe dispatch token if: steps.plan.outputs.recipes == 'true' diff --git a/.github/workflows/prepare-release.yaml b/.github/workflows/prepare-release.yaml index ff7d876471..873d76e88d 100644 --- a/.github/workflows/prepare-release.yaml +++ b/.github/workflows/prepare-release.yaml @@ -124,6 +124,7 @@ jobs: >/dev/null || release_ref=HEAD bash ./.github/scripts/verify-release-build-contract.sh \ "${release_ref}" --require-sibling-releases --require-current-bicep --require-current-engine \ + --require-current-coordination \ --expected-targets .github/release-parity/targets.json # A final promotes the channel's last release candidate. @@ -288,10 +289,34 @@ jobs: --add-label "${label}" done < <(jq -r '.[].source_pr' "${RUNNER_TEMP}/release-backports.json") + - name: Read validated docs and samples snapshots + if: inputs.release-type == 'final' + id: content-snapshots + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + INPUT_MODE: read-rc + VERSION: ${{ steps.preflight.outputs.version }} + RELEASE_CANDIDATE: ${{ steps.preflight.outputs.release-candidate }} + with: + retries: 5 + script: | + const { writeFile } = await import("node:fs/promises") + const planFile = `${process.env.RUNNER_TEMP}/release-candidate-plan.json` + await writeFile(planFile, JSON.stringify({ + version: process.env.VERSION, + releaseType: "final", + previousVersion: process.env.RELEASE_CANDIDATE + })) + process.env.INPUT_PLAN_FILE = planFile + const { default: coordinate } = await import(`${process.env.GITHUB_WORKSPACE}/.github/scripts/coordinate-release.mjs`) + await coordinate({ github, context, core }) + - name: Prepare release changes and plan id: prepare env: RECIPE_SOURCE_COMMIT: ${{ steps.recipe-source.outputs.commit }} + DOCS_SOURCE_COMMIT: ${{ steps.content-snapshots.outputs.docs-commit }} + SAMPLES_SOURCE_COMMIT: ${{ steps.content-snapshots.outputs.samples-commit }} GITHUB_TOKEN: ${{ steps.app-token.outputs.token || github.token }} GITHUB_REPO: ${{ github.repository }} RELEASE_TYPE: ${{ inputs.release-type }} @@ -330,6 +355,7 @@ jobs: if: inputs.release-type == 'final' uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 env: + # Also checks that the plan pins the RC's validated snapshots. INPUT_MODE: check-rc INPUT_PLAN_FILE: ${{ runner.temp }}/release-preparation/plan.json with: diff --git a/docs/contributing/contributing-releases/README.md b/docs/contributing/contributing-releases/README.md index 42242959c5..bec4835777 100644 --- a/docs/contributing/contributing-releases/README.md +++ b/docs/contributing/contributing-releases/README.md @@ -20,7 +20,7 @@ Backport selection, collection, preparation, and their tests live only in the [s - Release from a branch on the current release pipeline. A tag runs the workflows in the tagged commit, not those on `main`. Prepare Release and the controller require draft-only GoReleaser publication and a `build-release.yaml` that runs on `v*` tags with the complete staging, verification, approval, finalization, and coordination job graph. The check validates the dependency graph, final/RC approval conditions, mandatory verification and recheck steps, and their ordering before alias promotion and publication. It also rejects another workflow with a tag filter, such as the legacy `build.yaml`. A branch cut earlier, such as `release/0.61`, must first receive the complete current release pipeline, including the scripts and Make targets it calls, through a reviewed pull request to `release/.`. A passing source check does not replace the live release-cycle verification below. - Release the required resource type namespaces and recipe packs and merge their generated Radius update before preparation, as described in [Release resource type namespaces and recipe packs](#release-resource-type-namespaces-and-recipe-packs). - Roll out final Bicep recipe publication **receiver first**: merge the correlated [Publish Bicep Recipes](https://github.com/radius-project/resource-types-contrib/actions/workflows/publish-bicep-recipes.yaml) workflow on `resource-types-contrib` `main` and wait for its push run to publish and attest the immutable recipe inventory. Install `RADIUS_RELEASE_BOT` on that repository with Actions write; the caller mints a separate installation token scoped to that repository and permission, not a package or contents writer. Then deploy the Radius caller on `main` and on the branch that will be tagged, before the last validated RC for the first automated final. Roll out between final preparations: a retry does not invent a missing pin for an older open draft. Older recipe SHAs without a signed inventory cannot be promoted. -- Configure the release App identities, including `RADIUS_RELEASE_BOT` Actions write, Contents read, Pull requests read, and Metadata read on `docs` and `samples`. Give the Radius repository Actions package-write access to the GHCR `dashboard` and `deployment-engine` packages for gated channel promotion. Helm publication waits up to ten minutes for a missing full-version image whose publisher is still building the planned source; an existing full-version tag with conflicting provenance fails immediately. Install the same release App (`RADIUS_RELEASE_BOT`) on `radius-project/deployment-engine` for private source reads, approved tag creation and sibling GitHub Release publication. Give the Deployment Engine repository package-write access to its own public GHCR package; GHCR writes use the publishing repository's `GITHUB_TOKEN`, not an App token. Coordination records same-repository deployment receipts with `GITHUB_TOKEN` and `deployments: write` in the `release-coordination` environment, which must stay free of protection rules. +- Configure the release App identities, including `RADIUS_RELEASE_BOT` Actions write, Contents read, and Metadata read on `docs` and `samples`. Give the Radius repository Actions package-write access to the GHCR `dashboard` and `deployment-engine` packages for gated channel promotion. Helm publication waits up to ten minutes for a missing full-version image whose publisher is still building the planned source; an existing full-version tag with conflicting provenance fails immediately. Install the same release App (`RADIUS_RELEASE_BOT`) on `radius-project/deployment-engine` for private source reads, approved tag creation and sibling GitHub Release publication. Give the Deployment Engine repository package-write access to its own public GHCR package; GHCR writes use the publishing repository's `GITHUB_TOKEN`, not an App token. Coordination records same-repository deployment receipts with `GITHUB_TOKEN` and `deployments: write` in the `release-coordination` environment, which must stay free of protection rules. - Require the dashboard publisher to stamp `org.opencontainers.image.revision` with the exact built commit. Verify the actual image build reached by `yarn run build-image`, not just the workflow's source checkout. The publisher change must be included in the dashboard commit frozen by preparation, including on an existing `release/X.Y` branch. Both external-image pinning and the release manifest require the label. Missing provenance, conflicting digests, or incomplete platforms must not be waived. - Give the release App Contents write and Workflows write on `radius`, `recipes`, `dashboard`, `bicep-types-aws`, and `deployment-engine`. Workflows write permits backporting workflow changes and satisfies GitHub's release-creation authorization when the pinned commit changes workflows relative to the default branch. Each job requests these permissions only for its target repositories; grant/approve the App installation permissions separately before rollout. Release entries use the existing approved tags; publishing them does not edit workflows, create source commits, or change registry aliases. - The controller creates the matching **Deployment Engine tag** in `radius-project/deployment-engine` after release approval when GitHub reports it missing; any other lookup error stops validation. It tags Deployment Engine `main` for an RC or patch. A final releases the Deployment Engine commit that its last RC locked on `automation/release-state-`; that RC's Deployment Engine tag, and an existing final tag, must still point there, so cut another RC to release a different commit. Prepare Release checks that commit, and the controller shows it in the validation summary before approval. Only `radius-release` pushes the automated tag, at an existing commit; the controller creates no Deployment Engine commits. The tag push starts the Deployment Engine tag build, which stages the image that the controller then verifies and locks. To release a commit that is not on `main`, such as a hotfix, push a signed annotated tag before preparation instead: in a clean Deployment Engine clone, run `git tag -s -m "release tag " `, then `git push origin `. GitHub must verify that signature; an unsigned tag is accepted only at a GitHub-verified commit on `main`. Never manually tag the Radius repositories. @@ -34,7 +34,7 @@ Check the live repository settings and publisher contracts, not just the merged 1. Confirm the required reviewers, branch/tag deployment restrictions, required check contexts, App installation permissions, and GHCR package access listed above. The `release-coordination` environment must remain unprotected; it stores receipts rather than publication approvals. 2. Confirm Deployment Engine publishes `edge` from `main` and the exact version (without `v`) from a protected release tag. Verify anonymous GHCR pulls, the index digest, and the source URL, revision and tag-ref labels on every required platform. For Bicep, verify the authenticated native evidence contract below, the paired GHCR lock, and the finalization receipt, including anonymous access to both locked full-version tags before any alias write. Private Bicep receiver checks apply only to the transitional handoff. Confirm the frozen dashboard source produces its required revision label. Successful edge builds do not exercise signed release tags, stable alias promotion, or the release approval gates. -3. Record an approved RC-to-final cycle on the complete pipeline, including the staged installation, all three RC coordination receipts, and a controlled failure/resume exercise. Verify that resuming preserves locked digests and that a digest mismatch blocks publication. Run any destructive failure injection only against disposable test artifacts, never existing releases. Separately verify an upgrade from the previous supported release; the automatic installation gate only exercises a same-version Helm upgrade. +3. Record an approved RC-to-final cycle on the complete pipeline, including the staged installation, both RC coordination receipts, and a controlled failure/resume exercise. Verify that resuming preserves locked digests and that a digest mismatch blocks publication. Run any destructive failure injection only against disposable test artifacts, never existing releases. Separately verify an upgrade from the previous supported release; the automatic installation gate only exercises a same-version Helm upgrade. Do not declare production readiness from a green snapshot or an earlier pipeline's tag build. Keep the exact workflow run URLs and verification artifacts with the release record. @@ -97,9 +97,11 @@ For an existing channel, the controller run started by the main PR merge stops a 1. Follow the [release controller](https://github.com/radius-project/radius/actions/workflows/release-controller.yaml) summary. It verifies the Deployment Engine tag, or shows the commit it will tag, then pauses on its **Approve release reconciliation** job in the `release` environment. Review the version, metadata-bearing source commit, Deployment Engine commit, and frozen sibling commits it shows, then approve. The Radius controller makes no changes before this approval; external repositories may already have staged immutable artifacts from their own tag builds. The controller then creates the Deployment Engine tag if it is absent. Until the image digest is locked, it waits up to 15 minutes for the tag build to stage the image, including when it resumes after an interrupted attempt. It verifies and locks the full-version Deployment Engine image, reconciles the frozen sibling commits, and creates the Radius tag last. 2. Open the [release build workflow](https://github.com/radius-project/radius/actions/workflows/build-release.yaml), select the run for the approved version, and confirm its source commit matches the controller summary. GoReleaser stages core artifacts; the retained Bicep image, Helm chart, and Bicep extension stage complete before verification. The controller has authenticated AWS output before the Radius tag; the build calls the native Radius producer and retains `bicep-extension-lock.json` with both exact GHCR full-version references and matching source/revision/version annotations. Verify that pair and the finalization receipts under `bicep-publication--`, not ACR copies. New selector-free publication is rejected; published historical releases retain read-only ACR verification. The Bicep container uses full-version GHCR references, never aliases that await approval. `testrp` and `magpiego` are test-workflow outputs, not release assets or channel aliases. 3. Review `release-manifest.json` and the staged-installation result. **Finals and patches** wait for a second approval, **Approve final or patch publication**, in the `release` environment; approve only the verified version/source pair. **RCs** publish without this second approval after the same mandatory gate. Outputs are rechecked after approval before alias promotion or publication. -4. Follow the exact downstream run URLs. For RCs, review and merge docs and samples upmerge PRs, then resume the release. Automation binds the pull request each upmerge run opened and requires it to be merged before running sample tests; both repositories squash-merge, so the source commits never become reachable from `edge`, and a run with nothing to merge is complete. All three successful receipts are required for final preparation and publication; the release build rechecks them during verification and again after publication approval, before any alias moves. Receipts exist only for RCs published with this coordination in place; if the last validated RC predates it, cut another RC before preparing the final. Finals publish docs and samples and run sample tests; patches run sample tests without recutting their release branches. +4. Follow the exact downstream run URLs. Docs and samples develop on `edge`, which stays their default branch; releases never merge a stable branch back into it. Each **RC** validates content snapshots: it dispatches docs `validate-release.yaml` and samples `test.yaml` on `edge` with the RC version and records each run's tested commit on its receipt. A successful validation is final: a later rerun of that remote run cannot change or invalidate it. Final preparation reads both successful receipts of the last RC and pins their commits in the plan as `docsSourceCommit` and `samplesSourceCommit`, so approving the final approves the exact content it ships. A **final** dispatches docs and samples `release.yaml` on `edge` with the final version and the pinned `commit`. Each publishes `vX.Y` from the snapshot plus release configuration only, such as versions, URLs, and extension tags, so newer `edge` content is not picked up. The coordinator then checks that both default branches are still `edge` and that `vX.Y` branches from exactly the pinned commit, and runs sample tests on the published `vX.Y`. **Patches** run sample tests on `vX.Y` and republish neither repository. The release build checks that the RC receipts still match the plan's pins during verification and again after publication approval, before any alias moves. Receipts exist only for RCs published with this coordination in place; if the last validated RC predates it, cut another RC before preparing the final. -RC upmerges copy the current default release branch into `edge` through reviewed PRs; they do not change either repository's default branch or publish a new stable docs/samples channel. Only final coordination dispatches their `release.yaml` workflows to publish `vX.Y` and select it as the new default. The release App client handles these cross-repository calls; the Radius job token remains responsible for same-repository coordination receipts. +Fix docs and samples on `edge` first. A final never adopts content its last RC did not validate; to ship newer content, cut another RC. Backport a fix that a supported release needs with a separate reviewed PR into that repository's `vX.Y` branch; the shared backport automation covers only `main` to `release/X.Y`. The release App client handles these cross-repository calls; the Radius job token remains responsible for same-repository coordination receipts. + +**Cutting over from upmerges.** Older tagged Radius coordinators dispatch the removed `upmerge.yaml` and call docs and samples `release.yaml` without `commit`, so they cannot complete docs and samples coordination after the receivers change. Make the switch with no release in progress: finish, or abandon and re-cut, any RC or final tagged before this coordinator, then cut a new RC whose tag contains it. Published releases can still resume their other stages with their tagged scripts. Before the first GHCR-only final, the docs and samples release configuration must also reference the GHCR extension channels, because GHCR-only finals no longer promote ACR channel tags and the final tests the published `vX.Y`. After Radius is public, **Publish sibling GitHub Releases** creates or resumes source-bound entries for `recipes`, `dashboard`, `bicep-types-aws`, and Deployment Engine. Notes come from GitHub's native release-notes API. Finals compare against the preceding stable tag, later RCs against the preceding RC, and patches against their preceding stable tag. An initial release without a preceding stable tag uses GitHub's full-history generation. RC entries are prereleases and never Latest. Finals and patches become GitHub's Latest only when no newer stable release exists. This does not change container or OCI `latest` semantics. A failure leaves completed entries intact; the same release can resume without replacing their notes or artifacts. @@ -352,25 +354,19 @@ Run `bash .github/scripts/release-verification_test.sh` with Helm, Bash, jq, and For final recipes, inspect the `bicep-recipes` receipt. The version and Radius release SHA in the run title and the recipe source in the inputs must match the approved plan. Resume reuses the recorded run, including failed-job retries; it does not select today's recipe source. If the run URL is unknown, follow the binding procedure below rather than dispatching the publisher manually. -Downstream tasks have GitHub deployment receipts in the `release-coordination` environment, one per version and task (`release-coordination::`), bound to the Radius source SHA. If a dispatch response was lost before its returned run ID was persisted, automation stops instead of dispatching twice. Find the accepted run, verify its workflow, branch, inputs, and source, and add an `in_progress` status with its exact `log_url` to the reported receipt before resuming. If no run was accepted, reconcile the receipt explicitly before retrying. Never guess a run from a time window. For an upmerge, the receipt's environment URL is the pull request the run opened; automation binds it once, from the single upmerge pull request into `edge` created while the run's pull-request step ran, then checks only that pull request's merge state. If it cannot bind exactly one pull request, add an `in_progress` status with the run's `log_url` and the pull request as `environment_url` to the receipt before resuming. +Downstream tasks have GitHub deployment receipts in the `release-coordination` environment, one per version and task (`release-coordination::`), bound to the Radius source SHA. If a dispatch response was lost before its returned run ID was persisted, automation stops instead of dispatching twice. Find the accepted run, verify its workflow, branch, inputs, and source, and add an `in_progress` status with its exact `log_url` to the reported receipt before resuming. If no run was accepted, reconcile the receipt explicitly before retrying. Never guess a run from a time window. -### Retrying failed sample tests +### Retrying failed docs validation or sample tests -After merging a samples or test-workflow fix into `radius-project/samples` `edge`, resume the same Radius version and approved source. When the previously recorded sample-test run completed unsuccessfully, the coordinator dispatches a new `test.yaml` run on current `edge`, retaining the original Radius version input. This reloads both the workflow definition and sample code and runs the complete matrix at the new run's commit; retrying jobs of the old samples run would retain its old workflow and source. The existing receipt automatically records the returned replacement run URL, and the release summary reports the tested samples commit separately from the approved Radius source. No routine manual receipt edit is needed. +After merging a fix into `edge`, or into `vX.Y` for a final's or patch's sample tests, resume the same Radius version and approved source. When the previously recorded docs validation or sample-test run completed unsuccessfully, the coordinator dispatches a new run of the same workflow on the same branch, retaining the original Radius version input. This reloads both the workflow definition and content and validates the new run's commit; retrying jobs of the old run would retain its old workflow and content. For an RC, the replacement's commit becomes the snapshot its final publishes. The existing receipt automatically records the replacement run URL and its commit, and the release summary reports the tested docs and samples commits separately from the approved Radius source. No routine manual receipt edit is needed. -An active test run is monitored rather than replaced, and a successful gate is reused even if `edge` later advances. Each resume starts at most one replacement; a new failure waits for another resume. A missing dispatch acknowledgement or an unresolved legacy rerun marker still stops for [exact-run reconciliation](#lost-dispatch-response), rather than risking duplicate work. Other downstream tasks retain their existing retry behavior. +An active validation run is monitored rather than replaced, and a successful gate is reused even if its branch later advances. Each resume starts at most one replacement; a new failure waits for another resume. A missing dispatch acknowledgement or an unresolved legacy rerun marker still stops for [exact-run reconciliation](#lost-dispatch-response), rather than risking duplicate work. Docs and samples releases and the final Bicep recipe task instead rerun the failed jobs of their recorded run, so a release keeps its snapshot input. This policy must be present in the tagged Radius coordinator. Merging it into `main` does not update an already-tagged RC's code. For an older release, use the existing exact-run receipt recovery after a fresh samples test against the same Radius version, or include the reviewed coordinator fix before tagging a later release. Never move a tag or change the approved release source to adopt new recovery code. -### Closed or conflicting upmerge pull requests - -With the current coordinator, closing an upmerge PR without merging it is retryable: resume the same release. The coordinator reruns **all jobs** of that exact downstream run, clears the old PR binding, and binds the replacement created by the new attempt. The closed PR stays closed, merged upmerges are not repeated, and sample tests still wait for both upmerges to complete. A replacement that has no net changes is successful without a PR. An explicitly rejected rerun restores the previous PR binding; accepted or uncertain requests leave that old binding cleared. An uncertain rerun response retains its attempt marker and is not requested twice. - -Clean upmerges open ready for review. Genuine content conflicts stop with a file list instead of publishing a draft source snapshot that could omit edge-only changes. Resolve the conflicts on either the selected release branch or `edge` through normal review, then rerun. The shared upmerge workflow fetches both branches' latest commits at the start of every attempt and records their exact SHAs in its summary and PR body; commits pushed after that fetch enter the next attempt. This does not change the approved Radius release source or its receipt identity. Do not mark an older provisional snapshot ready without reconciling all edge-only content. - -For a downstream upmerge run created before fresh-head retries were deployed, choose **Re-run all jobs** on that docs/samples run after the shared fix merges. GitHub re-resolves the shared workflow's `@main` for a full rerun; rerunning only failed or specific jobs retains the first attempt's shared-workflow commit and can still use the old source-selection behavior. A run created with the updated implementation refreshes both content heads on every retry. +### Changing docs or samples content after an RC -This coordinator change cannot alter an already-tagged release's scripts. Rerunning an older tag-build job still uses that tag's coordinator. For such a release, either bind a separately verified replacement downstream run and PR using the existing receipt-reconciliation procedure, or include the fix in the next candidate; never move the tag or edit its approved source. +A final publishes exactly the docs and samples commits its last RC validated, recorded as each successful RC receipt's environment URL and pinned in the final plan as `docsSourceCommit` and `samplesSourceCommit`. Content merged into `edge` afterwards ships only in a later RC. If the final must include it, cut another RC so both snapshots are validated again, then prepare the final again; never edit a receipt or pin to point at an unvalidated commit. If a receipt no longer matches the approved pin, the release build stops before publication. After the final publishes `vX.Y`, a supported release receives docs or samples fixes only through a reviewed backport PR into `vX.Y`; patches test that branch and do not republish it. ### Backport conflicts or missing prerequisites diff --git a/docs/contributing/contributing-releases/release-runbook.md b/docs/contributing/contributing-releases/release-runbook.md index 7b974626e5..e646e26123 100644 --- a/docs/contributing/contributing-releases/release-runbook.md +++ b/docs/contributing/contributing-releases/release-runbook.md @@ -22,7 +22,7 @@ Choose the release type: | Type | When to use it | |---------|--------------------------------------------------------------------------------------------------------------------------------------------------| | `rc` | First or subsequent candidate for a new minor release. | -| `final` | Promote the last RC after its docs upmerge, samples upmerge, and sample tests succeed. Do not add untested product or Deployment Engine changes. | +| `final` | Promote the last RC after its docs validation and sample tests succeed. Do not add untested product, Deployment Engine, docs or samples changes. | | `patch` | Release fixes on an existing stable channel. | Run [Prepare Release](https://github.com/radius-project/radius/actions/workflows/prepare-release.yaml) from `main`: @@ -43,7 +43,7 @@ While the first-RC PR remains open, rerunning with the same type/channel retains Review the generated draft PR: version, product commit, sibling commits, selected backports, and expected outputs in `.github/release-plans/`. For RC/final notes, edit only **Highlights** and **Upgrading**; retain the image-pinning warning. Patch notes are fully generated. -For a new final, review `recipeSourceCommit` in `resource-types-contrib` and confirm its `main` push published the signed recipe inventory. This is separate from the `recipes` sibling commit. Preparation retries retain the original recipe SHA. +For a new final, review `recipeSourceCommit` in `resource-types-contrib` and confirm its `main` push published the signed recipe inventory. This is separate from the `recipes` sibling commit. Preparation retries retain the original recipe SHA. Also review `docsSourceCommit` and `samplesSourceCommit`: preparation pins the commits the last RC validated, and the final publishes exactly those. Root `CHANGELOG.md` contains finals and patches only. RC.1 and final notes cover the full new-version changes; later RCs show only changes since the preceding RC, and patches only changes since the preceding stable tag in that channel. Entries are newest first within each category. New plans record `changelogPolicy: stable-only`; an RC changes three metadata files, leaving the root changelog unchanged. @@ -76,15 +76,15 @@ Then require **Publish sibling GitHub Releases** to succeed for recipes, dashboa ### 5. Finish downstream work -Follow the exact downstream run and PR links in the release summary: +Follow the exact downstream run links in the release summary: -| Type | Maintainer action | -|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| RC | Review and squash-merge the docs and samples upmerge PRs into `edge`, if created. Then [resume the same release](#troubleshooting) so sample tests run. Require all three successful coordination receipts before preparing the final. | -| Final | Confirm docs publication, samples publication, sample tests, and the final Bicep recipe run all succeed. | -| Patch | Confirm sample tests succeed; no docs/samples release-branch recut is needed. | +| Type | Maintainer action | +|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| RC | Confirm docs validation and sample tests succeed on `edge`. The summary records the tested docs and samples commits; both successful receipts are required before preparing the final. | +| Final | Confirm docs and samples publish `vX.Y` from the plan's pinned `docsSourceCommit` and `samplesSourceCommit`, sample tests pass on `vX.Y`, and the final Bicep recipe run succeeds. | +| Patch | Confirm sample tests succeed on `vX.Y`; docs and samples are not republished. | -RC upmerges affect only `edge`, not the docs/samples default release branches. Only a final publishes their new `vX.Y` branches and switches their defaults; patches only run sample tests. +Docs and samples have no upmerges, and `edge` stays their default branch. Fix their content on `edge` first; a final never ships content its last RC did not validate, so cut another RC to include it. Backport a fix a supported release needs with a separate PR into that repository's `vX.Y`. See [docs and samples snapshots](./README.md#monitor-and-approve-publication). **Finals with `recipeSourceCommit`:** follow the `bicep-recipes / vX.Y.0-` run from the release summary. It publishes the version tags and eligible `latest` aliases from the approved recipe inventory. If the receipt has no run URL, [reconcile the unknown dispatch](./README.md#lost-dispatch-response); do not launch a second publisher. @@ -96,9 +96,9 @@ gh workflow run publish-bicep-recipes.yaml --repo radius-project/resource-types- ## Verification -- [ ] The release build and required downstream stages succeeded; no approval or upmerge is still pending. +- [ ] The release build and required downstream stages succeeded; no approval is still pending. - [ ] The GitHub Release is public with the correct version, and `release-manifest.json` and staged-installation evidence match the approved source. -- [ ] RC: all three coordination receipts succeeded. Final/patch: eligible aliases were promoted from verified digests. Final: Bicep recipe publication succeeded. +- [ ] RC: both coordination receipts succeeded and recorded docs and samples commits. Final/patch: eligible aliases were promoted from verified digests. Final: docs and samples `vX.Y` branch from the plan's pinned commits, and Bicep recipe publication succeeded. - [ ] Save the version, source commit, PR links, workflow URLs, and verification evidence in the Teams release thread. A public GitHub Release alone does not mean downstream work is complete. ## Troubleshooting @@ -121,7 +121,7 @@ For a frozen first RC, use the resolved release commit from the summary. Before **Provenance attestation or verification failed:** for a transient GitHub or Sigstore error, resume the same release; signing the same staged digests again is safe. A missing or mismatched attestation means the artifact did not come from this tag build. Investigate it instead of bypassing verification. -**Upmerge PR closed without merging:** with the updated coordinator, resume the same release to rerun the bound downstream workflow and create a replacement PR. Merged upmerges are reused. Clean merges create ready PRs; real content conflicts stop for resolution rather than creating draft snapshots. An older tagged coordinator does not gain this behavior by rerunning: follow [closed or conflicting upmerge recovery](./README.md#closed-or-conflicting-upmerge-pull-requests). +**Docs validation or sample tests failed:** merge the fix into `edge` (or `vX.Y` for final and patch sample tests), then resume the same release. The coordinator dispatches one fresh run on that branch; for an RC, its commit becomes the snapshot the final publishes. See [retrying failed validation](./README.md#retrying-failed-docs-validation-or-sample-tests). **Controller never started after merge:** follow [manual-start recovery](./README.md#controller-never-started-after-merge) to get the version and source commit from the merged release PR or metadata backport, then run [Approve Release](https://github.com/radius-project/radius/actions/workflows/approve-release.yaml) from `main`. This starts reconciliation; it does not bypass environment approval. diff --git a/eng/design-notes/tools/2026-03-goreleaser-release-lifecycle.md b/eng/design-notes/tools/2026-03-goreleaser-release-lifecycle.md index d75ff34114..26958a82f3 100644 --- a/eng/design-notes/tools/2026-03-goreleaser-release-lifecycle.md +++ b/eng/design-notes/tools/2026-03-goreleaser-release-lifecycle.md @@ -425,7 +425,7 @@ The release controller reconciles one explicit resource at a time using these ru - An existing draft release for the planned tag is reused. Matching assets are retained or replaced deterministically. An already published release is verified and treated as complete only when every expected digest matches. - The expected digest for an immutable container tag is the digest recorded in the release manifest at push and locked by verification, never the output of a fresh rebuild - image builds are not assumed reproducible. Before the lock, a rerun of the staging stage may re-stage the tags of the same unpublished attempt and record new digests. After the lock, a matching tag is success and is skipped without rebuilding, and a diverging tag is a non-retryable conflict. Mutable aliases (release channels and `latest`) are changed only during finalization and are verified after promotion; `edge` belongs to the main-branch workflow and is never touched by the release. - A remote publisher receives a stable release identifier such as `-`. Its workflow run name and concurrency group include that identifier. The controller finds that exact run, waits for an active run, reruns a failed retryable run, or dispatches only when no matching run exists. -- For downstream `workflow_dispatch`, prefer the native run ID returned by GitHub REST API version `2026-03-10`. A source-bound GitHub deployment receipt records the task and exact remote run URL; receipts share one `release-coordination` environment, are keyed by version and task, and are bound to the source SHA, so releases create no environments of their own. This avoids changing docs and samples run names or correlating runs by time windows. An upmerge pull request has no native identifier: it is bound once from the run's pull-request step and stored on the receipt. Write dispatch intent before calling the non-retried dispatch endpoint; if the response is lost before its ID is recorded, stop for operator reconciliation. Resume monitors or reruns that same run once its identity is known. +- For downstream `workflow_dispatch`, prefer the native run ID returned by GitHub REST API version `2026-03-10`. A source-bound GitHub deployment receipt records the task and exact remote run URL; receipts share one `release-coordination` environment, are keyed by version and task, and are bound to the source SHA, so releases create no environments of their own. This avoids changing docs and samples run names or correlating runs by time windows. A validation run's tested commit is stored as its successful receipt's environment URL. Write dispatch intent before calling the non-retried dispatch endpoint; if the response is lost before its ID is recorded, stop for operator reconciliation. Resume monitors or reruns that same run once its identity is known. - Every stage verifies the destination, not merely the exit code of the command that attempted to create it. #### Retry and fallback policy @@ -467,9 +467,9 @@ If any mandatory stage fails before finalization, the GitHub Release stays draft Only work that does not determine whether the core release is installable waits for the published release event. This includes docs and samples publication, announcements, and metadata synchronization. Required sibling images and Deployment Engine publication move before the Radius tag; Bicep and Helm publication move before the publication gate. -For RC releases, coordination also covers the docs and samples upmerge workflows and the sample test workflow that installs the published RC. The controller dispatches and correlates them with the release identifier like any other remote work, and their results gate approval of the next release plan - the final release - rather than the RC's own publication. This replaces the manually dispatched upmerge and sample-test steps in the current runbook. +For RC releases, coordination validates docs and samples content snapshots: docs release validation and the sample test workflow that installs the published RC, both on `edge`. The controller dispatches and correlates them with the release identifier like any other remote work, and their results gate approval of the next release plan - the final release - rather than the RC's own publication. This replaces the manually dispatched upmerge and sample-test steps in the earlier runbook. -An upmerge workflow opening a PR is not completion: the receipt binds that pull request and becomes successful only when it has merged. docs and samples squash-merge, so reachability of the source commits from `edge` is never observable; a run with nothing to merge is complete. Sample tests start only after both upmerges complete. Both final preparation and final publication verify the receipts of the exact previous RC. The existing docs and samples publication workflows cut new channel branches, so finals invoke them after publication; patches run sample tests without recutting those branches. The release App token for this coordination has only Actions write, Contents read, and Pull requests read, with implicit Metadata read, on docs and samples. Radius deployment receipts and tag-build reruns use the built-in token. +docs and samples develop on `edge`, which stays their default branch, and have no upmerges. Each RC receipt records the exact commit its run validated; a successful validation is final, and a failed one is replaced by one fresh run of the current branch per resume. Final preparation pins both commits in the final plan, and both final preparation and final publication require the exact previous RC's receipts to match those pins. Finals pass the pinned commits to the docs and samples publication workflows, which publish `vX.Y` from the validated snapshot plus release configuration only; the coordinator verifies that `vX.Y` branches from the snapshot and that `edge` is still the default branch, then runs sample tests on `vX.Y`. Changing approved content requires another RC. Patches run sample tests on `vX.Y` without republishing, and supported branches receive fixes only by selective backport. The release App token for this coordination has only Actions write and Contents read, with implicit Metadata read, on docs and samples. Radius deployment receipts and tag-build reruns use the built-in token. The publication manifest reuses the parity observations and immutable digest locks. It checks actual downloaded binaries with native Go metadata inspection and installs the staged binary with the downloaded chart on an isolated kind cluster. Digest overrides isolate that installation from aliases that have not yet advanced. Finals and patches wait for environment approval after verification, then recheck every recorded output before mutation; RCs use the same mandatory gate without an approval wait. Stage summaries and optional Teams Adaptive Card notifications share the manifest and downstream receipts; a notification failure cannot change publication eligibility.