diff --git a/.github/scripts/monitor-remote-workflow.mjs b/.github/scripts/monitor-remote-workflow.mjs deleted file mode 100644 index 620c408bdb..0000000000 --- a/.github/scripts/monitor-remote-workflow.mjs +++ /dev/null @@ -1,416 +0,0 @@ -// @ts-nocheck - -const RELEASE_IDENTIFIER_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,199}$/; -const EVENT_TYPE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/; -const API_RETRY_ATTEMPTS = 5; -const API_RETRY_BASE_DELAY_MS = 1000; -const API_RETRY_MAX_DELAY_MS = 15000; -const RETRYABLE_NETWORK_CODES = new Set([ - "ECONNRESET", - "ETIMEDOUT", - "EAI_AGAIN", - "UND_ERR_CONNECT_TIMEOUT" -]); - -/** @param {string} name @param {string} value @param {number} fallback */ -function positiveNumber(name, value, fallback) { - const parsed = Number(value || String(fallback)); - if (!Number.isFinite(parsed) || parsed <= 0) { - throw new Error(`${name} must be a positive number`); - } - return parsed; -} - -/** @param {unknown} error */ -function errorText(error) { - return error instanceof Error ? error.message : String(error); -} - -/** @param {string} operationName @param {number} attempts @param {unknown} error */ -function describeFailure(operationName, attempts, error) { - const suffix = attempts > 1 ? ` after ${attempts} attempts` : ""; - return `${operationName} failed${suffix}: ${errorText(error)}`; -} - -/** @param {any} error */ -function isRateLimitError(error) { - const status = Number(error?.status ?? error?.response?.status ?? 0); - const headers = error?.response?.headers || {}; - return ( - status === 429 || - (status === 403 && - Boolean( - headers["retry-after"] || headers["x-ratelimit-remaining"] === "0" - )) - ); -} - -/** @param {any} error */ -function isRetryableAPIError(error) { - const status = Number(error?.status ?? error?.response?.status ?? 0); - return ( - isRateLimitError(error) || - (status >= 500 && status <= 599) || - RETRYABLE_NETWORK_CODES.has(error?.code) || - RETRYABLE_NETWORK_CODES.has(error?.cause?.code) - ); -} - -/** @param {any} error */ -function retryAfterMilliseconds(error) { - const value = Number(error?.response?.headers?.["retry-after"] ?? 0); - return Number.isFinite(value) && value > 0 ? value * 1000 : 0; -} - -/** - * Dispatch or resume one correlated publisher run. - * - * @param {{ - * github: any, - * core: any, - * sleep?: (ms: number) => Promise, - * now?: () => number, - * random?: () => number, - * }} options - */ -export default async ({ - github, - core, - sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)), - now = () => Date.now(), - random = () => Math.random() -}) => { - try { - const remoteOwner = core.getInput("OWNER", { required: true }); - const remoteRepo = core.getInput("REPO", { required: true }); - const remoteWorkflowFile = core.getInput("WORKFLOW_FILE", { - required: true - }); - const eventType = core.getInput("EVENT_TYPE", { required: true }); - const releaseIdentifier = core.getInput("RELEASE_IDENTIFIER", { - required: true - }); - const clientPayloadText = core.getInput("CLIENT_PAYLOAD", { - required: true - }); - const reuseSuccessfulText = core.getInput("REUSE_SUCCESSFUL") || "true"; - if (!/^(true|false)$/.test(reuseSuccessfulText)) { - throw new Error("REUSE_SUCCESSFUL must be true or false"); - } - const reuseSuccessful = reuseSuccessfulText === "true"; - const dispatchIfMissingText = - core.getInput("DISPATCH_IF_MISSING") || "true"; - if (!/^(true|false)$/.test(dispatchIfMissingText)) { - throw new Error("DISPATCH_IF_MISSING must be true or false"); - } - const dispatchIfMissing = dispatchIfMissingText === "true"; - - if (!EVENT_TYPE_PATTERN.test(eventType)) { - throw new Error(`Invalid event type: ${eventType}`); - } - if (!RELEASE_IDENTIFIER_PATTERN.test(releaseIdentifier)) { - throw new Error( - "Release identifier must contain 1-200 letters, numbers, dots, underscores, hyphens, or plus signs" - ); - } - - const clientPayload = JSON.parse(clientPayloadText); - if ( - clientPayload === null || - Array.isArray(clientPayload) || - typeof clientPayload !== "object" - ) { - throw new Error("CLIENT_PAYLOAD must be a JSON object"); - } - if ( - clientPayload.release_identifier && - clientPayload.release_identifier !== releaseIdentifier - ) { - throw new Error("CLIENT_PAYLOAD release_identifier does not match input"); - } - clientPayload.release_identifier = releaseIdentifier; - - const maxWaitSeconds = positiveNumber( - "MAX_WAIT_SECONDS", - core.getInput("MAX_WAIT_SECONDS"), - 900 - ); - const pollIntervalSeconds = positiveNumber( - "POLL_INTERVAL_SECONDS", - core.getInput("POLL_INTERVAL_SECONDS"), - 10 - ); - const deadline = now() + maxWaitSeconds * 1000; - const expectedRunName = `${eventType} / ${releaseIdentifier}`; - - const sleepWithinBudget = async (milliseconds) => { - const remaining = deadline - now(); - if (remaining <= 0) { - return false; - } - await sleep(Math.min(milliseconds, remaining)); - return now() < deadline; - }; - - const retryDelay = (attempt, error) => { - const exponentialDelay = Math.min( - API_RETRY_MAX_DELAY_MS, - API_RETRY_BASE_DELAY_MS * 2 ** (attempt - 1) - ); - const jitteredDelay = - exponentialDelay / 2 + random() * (exponentialDelay / 2); - return Math.max(Math.ceil(jitteredDelay), retryAfterMilliseconds(error)); - }; - - const retryAPI = async (operationName, operation) => { - for (let attempt = 1; attempt <= API_RETRY_ATTEMPTS; attempt += 1) { - try { - return await operation(); - } catch (error) { - if ( - !isRetryableAPIError(error) || - attempt === API_RETRY_ATTEMPTS || - now() >= deadline - ) { - throw new Error(describeFailure(operationName, attempt, error)); - } - - const delay = retryDelay(attempt, error); - core.info( - `Transient GitHub API failure during ${operationName}; retrying in ${delay}ms (attempt ${attempt + 1}/${API_RETRY_ATTEMPTS})` - ); - if (!(await sleepWithinBudget(delay))) { - throw new Error(describeFailure(operationName, attempt, error)); - } - } - } - throw new Error(`${operationName} exhausted its retry budget`); - }; - - core.setOutput("release_identifier", releaseIdentifier); - core.info( - `Reconciling publisher run '${expectedRunName}' in ${remoteOwner}/${remoteRepo}` - ); - - /** @param {any[]} runs */ - const correlatedRuns = (runs) => - (runs || []) - .filter( - (run) => - run.event === "repository_dispatch" && - run.display_title === expectedRunName - ) - .sort((left, right) => right.id - left.id); - - /** @param {any[]} runs */ - const selectReusableRun = (runs) => - runs.find((run) => run.status !== "completed") || - (reuseSuccessful && - runs.find( - (run) => run.status === "completed" && run.conclusion === "success" - )); - - const matchingRuns = async ({ allPages = true } = {}) => { - const parameters = { - owner: remoteOwner, - repo: remoteRepo, - workflow_id: remoteWorkflowFile, - per_page: 100 - }; - - if (!allPages) { - const response = await retryAPI("recent publisher run lookup", () => - github.rest.actions.listWorkflowRuns(parameters) - ); - return correlatedRuns(response.data.workflow_runs); - } - - const runs = await retryAPI("publisher run lookup", () => - github.paginate( - github.rest.actions.listWorkflowRuns, - parameters, - (response) => { - if (now() >= deadline) { - throw new Error( - "the monitor budget ran out before every history page was read; refusing to dispatch without completing discovery" - ); - } - return correlatedRuns(response.data); - } - ) - ); - return correlatedRuns(runs); - }; - - let uncertainDispatchFailure = ""; - const dispatchRun = async (previousRunID) => { - const operationName = `publisher dispatch '${eventType}'`; - for (let attempt = 1; attempt <= API_RETRY_ATTEMPTS; attempt += 1) { - try { - await github.rest.repos.createDispatchEvent({ - owner: remoteOwner, - repo: remoteRepo, - event_type: eventType, - client_payload: clientPayload - }); - core.setOutput("run_state", "unknown"); - return undefined; - } catch (error) { - if (!isRetryableAPIError(error)) { - throw new Error(describeFailure(operationName, attempt, error)); - } - if (!isRateLimitError(error)) { - uncertainDispatchFailure = describeFailure( - operationName, - attempt, - error - ); - core.setOutput("run_state", "unknown"); - core.info( - `${uncertainDispatchFailure}; the request may have been accepted. Waiting for '${expectedRunName}' without redispatching` - ); - return undefined; - } - - const delay = Math.max( - pollIntervalSeconds * 1000, - retryDelay(attempt, error) - ); - core.info( - `Publisher dispatch was rate limited; checking for '${expectedRunName}' before retrying the rejected request` - ); - if (now() < deadline) { - await sleepWithinBudget(delay); - } - - const newRuns = (await matchingRuns({ allPages: false })).filter( - (candidate) => candidate.id > previousRunID - ); - const discoveredRun = selectReusableRun(newRuns) || newRuns[0]; - if (discoveredRun) { - core.info( - `Found correlated run ${discoveredRun.id}; skipping redispatch` - ); - return discoveredRun; - } - if (attempt === API_RETRY_ATTEMPTS || now() >= deadline) { - throw new Error( - `${describeFailure(operationName, attempt, error)}; no run '${expectedRunName}' appeared. Inspect publisher runs and destination artifacts before retrying` - ); - } - } - } - throw new Error("Publisher dispatch exhausted its retry budget"); - }; - - const existingRuns = await matchingRuns(); - const previousRunID = existingRuns.reduce( - (highest, candidate) => Math.max(highest, candidate.id), - 0 - ); - let run = selectReusableRun(existingRuns); - if (!run) { - if (!dispatchIfMissing) { - core.info( - `No active correlated run found for '${expectedRunName}'; dispatch is not required` - ); - core.setOutput("run_state", "absent"); - return; - } - core.info( - existingRuns.length > 0 ? - `Previous correlated runs failed; dispatching retry '${eventType}'` - : `No existing run found; dispatching '${eventType}'` - ); - run = await dispatchRun(previousRunID); - - while (!run && now() <= deadline) { - const newRuns = (await matchingRuns({ allPages: false })).filter( - (candidate) => candidate.id > previousRunID - ); - run = selectReusableRun(newRuns) || newRuns[0]; - if (run || now() >= deadline) { - break; - } - await sleep( - Math.min(pollIntervalSeconds * 1000, Math.max(0, deadline - now())) - ); - } - } else { - core.info(`Reusing correlated remote run ${run.id}`); - } - - if (!run) { - core.setOutput("run_state", "unknown"); - core.setFailed( - `${uncertainDispatchFailure ? `${uncertainDispatchFailure}. ` : ""}Timed out waiting for publisher run '${expectedRunName}': https://github.com/${remoteOwner}/${remoteRepo}/actions/workflows/${remoteWorkflowFile}. The dispatch outcome is unknown; no additional dispatch was sent after the uncertain outcome. Inspect publisher runs and destination artifacts before retrying` - ); - return; - } - - const runUrl = - run.html_url || - `https://github.com/${remoteOwner}/${remoteRepo}/actions/runs/${run.id}`; - core.setOutput("run_id", String(run.id)); - core.setOutput("run_url", runUrl); - core.setOutput("run_state", "found"); - core.info(`Monitoring correlated remote run: ${runUrl}`); - - while (true) { - if (run.status === "completed") { - const conclusion = run.conclusion || ""; - core.setOutput("conclusion", conclusion); - if (conclusion === "success") { - core.info("Correlated remote workflow completed successfully"); - return; - } - - const jobsResponse = await retryAPI("publisher job diagnostics", () => - github.rest.actions.listJobsForWorkflowRun({ - owner: remoteOwner, - repo: remoteRepo, - run_id: run.id, - per_page: 100 - }) - ); - const failedJobs = (jobsResponse.data.jobs || []).filter( - (job) => job.conclusion !== "success" - ); - const failedJobText = failedJobs - .map((job) => { - const failedSteps = (job.steps || []) - .filter((step) => step.conclusion === "failure") - .map((step) => ` - Step: ${step.name}`) - .join("\n"); - return `- Job: ${job.name} [${job.conclusion}]${failedSteps ? `\n${failedSteps}` : ""}`; - }) - .join("\n"); - - core.setFailed( - `Correlated remote workflow failed with conclusion: ${conclusion}\nRemote workflow run: ${runUrl}${failedJobText ? `\nFailed jobs/steps:\n${failedJobText}` : ""}` - ); - return; - } - - if (now() >= deadline) { - core.setFailed( - `Timed out waiting for correlated remote workflow completion: ${runUrl}` - ); - return; - } - await sleep( - Math.min(pollIntervalSeconds * 1000, Math.max(0, deadline - now())) - ); - const runResponse = await retryAPI("publisher run status", () => - github.rest.actions.getWorkflowRun({ - owner: remoteOwner, - repo: remoteRepo, - run_id: run.id - }) - ); - run = runResponse.data; - } - } catch (error) { - core.setFailed(errorText(error)); - } -}; diff --git a/.github/scripts/monitor-remote-workflow_test.mjs b/.github/scripts/monitor-remote-workflow_test.mjs deleted file mode 100644 index fb3e194f41..0000000000 --- a/.github/scripts/monitor-remote-workflow_test.mjs +++ /dev/null @@ -1,848 +0,0 @@ -// Copyright 2026 The Radius Authors. -// Licensed under the Apache License, Version 2.0. - -import assert from "node:assert/strict"; -import { readFile } from "node:fs/promises"; -import test from "node:test"; - -import monitorRemoteWorkflow from "./monitor-remote-workflow.mjs"; - -function createCore(overrides = {}) { - const inputs = { - OWNER: "azure-octo", - REPO: "radius-publisher", - WORKFLOW_FILE: "publish-deployment-engine.yml", - EVENT_TYPE: "deployment-engine", - RELEASE_IDENTIFIER: "0.61.0-aaaaaaaa", - CLIENT_PAYLOAD: JSON.stringify({ tag: "0.61" }), - REUSE_SUCCESSFUL: "true", - DISPATCH_IF_MISSING: "true", - MAX_WAIT_SECONDS: "30", - POLL_INTERVAL_SECONDS: "1", - ...overrides - }; - const outputs = new Map(); - const failures = []; - const infos = []; - - return { - inputs, - outputs, - failures, - infos, - getInput(name, options = {}) { - const value = inputs[name] || ""; - if (options.required && !value) { - throw new Error(`Input required and not supplied: ${name}`); - } - return value; - }, - setOutput(name, value) { - outputs.set(name, value); - }, - setFailed(message) { - failures.push(message); - }, - info(message) { - infos.push(message); - } - }; -} - -function createClock() { - let time = 0; - return { - now: () => time, - sleep: async (milliseconds) => { - time += milliseconds; - } - }; -} - -function apiError(status, message = `GitHub API returned ${status}`) { - return Object.assign(new Error(message), { status }); -} - -function createGithub({ runs = [], getRun, jobs = [], pages } = {}) { - const dispatches = []; - const calls = { list: 0, get: 0, jobs: 0, pages: 0 }; - let nextRunID = 1000; - let paginating = false; - - const github = { - dispatches, - calls, - runs, - // Mirrors octokit: the map callback gets a `done` stopper, and pages are - // fetched until it is called or the fixture runs out of pages. - async paginate(method, parameters, map) { - const collected = []; - let stopped = false; - const done = () => { - stopped = true; - }; - paginating = true; - try { - const pageCount = - pages ? - Math.min(pages.length, parameters.event ? 10 : pages.length) - : 1; - for (let page = 0; page < pageCount && !stopped; page += 1) { - const response = await method({ ...parameters, page: page + 1 }); - collected.push( - ...map({ ...response, data: response.data.workflow_runs }, done) - ); - } - } finally { - paginating = false; - } - return collected; - }, - rest: { - actions: { - async listWorkflowRuns({ page = 1 } = {}) { - calls.list += 1; - if (pages && paginating) { - calls.pages += 1; - return { - data: { - workflow_runs: (pages[page - 1] || []).map((run) => ({ - event: "repository_dispatch", - ...run - })) - } - }; - } - return { - data: { - workflow_runs: runs.map((run) => ({ - event: "repository_dispatch", - ...run - })) - } - }; - }, - async getWorkflowRun({ run_id: runID }) { - calls.get += 1; - const current = - getRun?.(runID, calls.get) || runs.find((run) => run.id === runID); - return { data: current }; - }, - async listJobsForWorkflowRun() { - calls.jobs += 1; - return { data: { jobs } }; - } - }, - repos: { - async createDispatchEvent({ - event_type: eventType, - client_payload: payload - }) { - dispatches.push({ eventType, payload }); - runs.push({ - id: nextRunID++, - event: "repository_dispatch", - display_title: `${eventType} / ${payload.release_identifier}`, - status: "completed", - conclusion: "success", - html_url: `https://example.test/runs/${nextRunID - 1}` - }); - } - } - } - }; - return github; -} - -function successfulRun(id, identifier) { - return { - id, - event: "repository_dispatch", - display_title: `deployment-engine / ${identifier}`, - status: "completed", - conclusion: "success", - html_url: `https://example.test/runs/${id}` - }; -} - -test("finds correlated runs beyond unrelated history pages", async () => { - const identifier = "0.61.0-abababab"; - const core = createCore({ RELEASE_IDENTIFIER: identifier }); - const github = createGithub({ - pages: [ - [{ ...successfulRun(44, identifier), conclusion: "failure" }], - [successfulRun(43, "another-release")], - [successfulRun(42, identifier)] - ] - }); - - await monitorRemoteWorkflow({ github, core, ...createClock() }); - - assert.deepEqual(core.failures, []); - assert.equal(github.calls.pages, 3); - assert.equal(github.dispatches.length, 0); - assert.equal(core.outputs.get("run_id"), "42"); -}); - -test("finds an existing run beyond five pages without redispatching", async () => { - const identifier = "0.61.0-acacacac"; - const core = createCore({ RELEASE_IDENTIFIER: identifier }); - const unrelated = [{ id: 7, display_title: "deployment-engine / other" }]; - const github = createGithub({ - pages: [ - ...Array.from({ length: 7 }, () => unrelated), - [successfulRun(6, identifier)] - ] - }); - - await monitorRemoteWorkflow({ github, core, ...createClock() }); - - assert.deepEqual(core.failures, []); - assert.equal(github.calls.pages, 8); - assert.equal(github.dispatches.length, 0); - assert.equal(core.outputs.get("run_id"), "6"); - assert.equal(core.outputs.get("conclusion"), "success"); -}); - -test("finds a successful run beyond the filtered 1000-result cap", async () => { - const identifier = "0.61.0-aeaeaeae"; - const core = createCore({ RELEASE_IDENTIFIER: identifier }); - const pages = Array.from({ length: 10 }, (unused, page) => - Array.from({ length: 100 }, (unused, index) => - successfulRun(2000 - page * 100 - index, "unrelated") - ) - ); - pages.push([successfulRun(42, identifier)]); - const github = createGithub({ pages }); - - await monitorRemoteWorkflow({ github, core, ...createClock() }); - - assert.deepEqual(core.failures, []); - assert.equal(github.calls.pages, 11); - assert.equal(github.dispatches.length, 0); - assert.equal(core.outputs.get("run_id"), "42"); -}); - -test("ignores matching titles from non-dispatch events", async () => { - const identifier = "0.61.0-afafafaf"; - const core = createCore({ RELEASE_IDENTIFIER: identifier }); - const github = createGithub({ - runs: [{ ...successfulRun(42, identifier), event: "workflow_dispatch" }] - }); - - await monitorRemoteWorkflow({ github, core, ...createClock() }); - - assert.deepEqual(core.failures, []); - assert.equal(github.dispatches.length, 1); - assert.equal(core.outputs.get("run_id"), "1000"); -}); - -test("never dispatches when history discovery times out", async () => { - const core = createCore(); - const clock = createClock(); - const github = createGithub({ pages: [[], [], []] }); - const listWorkflowRuns = github.rest.actions.listWorkflowRuns; - github.rest.actions.listWorkflowRuns = async (parameters) => { - await clock.sleep(15000); - return listWorkflowRuns(parameters); - }; - - await monitorRemoteWorkflow({ github, core, ...clock }); - - assert.match(core.failures[0], /refusing to dispatch/); - assert.equal(github.dispatches.length, 0); -}); - -test("restarts paginated discovery after a transient failure", async () => { - const identifier = "0.61.0-adadadad"; - const core = createCore({ RELEASE_IDENTIFIER: identifier }); - const github = createGithub({ - pages: [[], [], [], [successfulRun(51, identifier)], []] - }); - const listWorkflowRuns = github.rest.actions.listWorkflowRuns; - let failed = false; - github.rest.actions.listWorkflowRuns = async (parameters) => { - if (!failed && parameters.page === 2) { - failed = true; - throw apiError(500); - } - return listWorkflowRuns(parameters); - }; - - await monitorRemoteWorkflow({ - github, - core, - ...createClock(), - random: () => 0 - }); - - assert.deepEqual(core.failures, []); - assert.equal(github.dispatches.length, 0); - assert.equal(core.outputs.get("run_id"), "51"); -}); - -test("reuses an existing successful run without dispatching", async () => { - const identifier = "0.61.0-aaaaaaaa"; - const core = createCore({ RELEASE_IDENTIFIER: identifier }); - const github = createGithub({ runs: [successfulRun(42, identifier)] }); - const clock = createClock(); - - await monitorRemoteWorkflow({ github, core, ...clock }); - - assert.deepEqual(core.failures, []); - assert.equal(github.dispatches.length, 0); - assert.equal(core.outputs.get("run_id"), "42"); - assert.equal(core.outputs.get("conclusion"), "success"); -}); - -test("prefers a newer active retry over an older success", async () => { - const identifier = "0.61.0-a0a0a0a0"; - const success = successfulRun(41, identifier); - const active = { - ...successfulRun(42, identifier), - status: "in_progress", - conclusion: null - }; - const core = createCore({ RELEASE_IDENTIFIER: identifier }); - const github = createGithub({ - runs: [success, active], - getRun: () => ({ ...active, status: "completed", conclusion: "success" }) - }); - - await monitorRemoteWorkflow({ github, core, ...createClock() }); - - assert.deepEqual(core.failures, []); - assert.equal(core.outputs.get("run_id"), "42"); - assert.deepEqual(github.dispatches, []); -}); - -test("query-only mode does not dispatch when no run exists", async () => { - const core = createCore({ DISPATCH_IF_MISSING: "false" }); - const github = createGithub(); - - await monitorRemoteWorkflow({ github, core, ...createClock() }); - - assert.deepEqual(core.failures, []); - assert.deepEqual(github.dispatches, []); - assert.equal(core.outputs.get("run_state"), "absent"); -}); - -test("retries a successful run when its destination is absent", async () => { - const identifier = "0.61.0-a1a1a1a1"; - const previous = successfulRun(41, identifier); - const core = createCore({ - RELEASE_IDENTIFIER: identifier, - REUSE_SUCCESSFUL: "false" - }); - const github = createGithub({ runs: [previous] }); - - await monitorRemoteWorkflow({ github, core, ...createClock() }); - - assert.deepEqual(core.failures, []); - assert.equal(github.dispatches.length, 1); - assert.notEqual(core.outputs.get("run_id"), "41"); -}); - -test("dispatches once and injects the release identifier into the payload", async () => { - const identifier = "0.61.0-bbbbbbbb"; - const core = createCore({ - RELEASE_IDENTIFIER: identifier, - CLIENT_PAYLOAD: JSON.stringify({ tag: "0.61", source_sha: "b".repeat(40) }) - }); - const github = createGithub(); - const clock = createClock(); - - await monitorRemoteWorkflow({ github, core, ...clock }); - - assert.deepEqual(core.failures, []); - assert.equal(github.dispatches.length, 1); - assert.deepEqual(github.dispatches[0], { - eventType: "deployment-engine", - payload: { - tag: "0.61", - source_sha: "b".repeat(40), - release_identifier: identifier - } - }); -}); - -test("dispatches and reuses identifiers with SemVer build metadata", async (context) => { - for (const version of ["1.2.3+meta", "v1.2.3+meta", "v1.2.3-rc.1+build.42"]) { - await context.test(version, async () => { - const identifier = `${version}-${"a".repeat(40)}`; - const inputs = { - RELEASE_IDENTIFIER: identifier, - CLIENT_PAYLOAD: JSON.stringify({ tag: version }) - }; - const core = createCore(inputs); - const github = createGithub(); - - await monitorRemoteWorkflow({ github, core, ...createClock() }); - - assert.deepEqual(core.failures, []); - assert.equal(github.dispatches.length, 1); - assert.deepEqual(github.dispatches[0].payload, { - tag: version, - release_identifier: identifier - }); - assert.equal(core.outputs.get("release_identifier"), identifier); - assert.equal(core.outputs.get("conclusion"), "success"); - - const resumedCore = createCore(inputs); - await monitorRemoteWorkflow({ - github, - core: resumedCore, - ...createClock() - }); - - assert.deepEqual(resumedCore.failures, []); - assert.equal(github.dispatches.length, 1); - assert.equal( - resumedCore.outputs.get("run_id"), - core.outputs.get("run_id") - ); - assert.equal(resumedCore.outputs.get("conclusion"), "success"); - }); - } -}); - -test("retries transient run lookups with bounded backoff", async () => { - const identifier = "0.61.0-bcbcbcbc"; - const core = createCore({ RELEASE_IDENTIFIER: identifier }); - const github = createGithub({ runs: [successfulRun(45, identifier)] }); - const listWorkflowRuns = github.rest.actions.listWorkflowRuns; - let attempts = 0; - github.rest.actions.listWorkflowRuns = async (parameters) => { - attempts += 1; - if (attempts < 3) { - throw apiError(503); - } - return listWorkflowRuns(parameters); - }; - - await monitorRemoteWorkflow({ - github, - core, - ...createClock(), - random: () => 0 - }); - - assert.deepEqual(core.failures, []); - assert.equal(attempts, 3); - assert.equal(github.dispatches.length, 0); - assert.equal(core.outputs.get("run_id"), "45"); -}); - -test("does not retry non-transient API failures", async () => { - const core = createCore(); - const github = createGithub(); - let attempts = 0; - github.rest.actions.listWorkflowRuns = async () => { - attempts += 1; - throw apiError(422, "Invalid workflow query"); - }; - - await monitorRemoteWorkflow({ - github, - core, - ...createClock(), - random: () => 0 - }); - - assert.equal(attempts, 1); - assert.equal( - core.failures[0], - "publisher run lookup failed: Invalid workflow query" - ); -}); - -test("reconciles an accepted dispatch after a transient response error", async () => { - const identifier = "0.61.0-bdbdbdbd"; - const core = createCore({ RELEASE_IDENTIFIER: identifier }); - const github = createGithub(); - const createDispatchEvent = github.rest.repos.createDispatchEvent; - let attempts = 0; - github.rest.repos.createDispatchEvent = async (parameters) => { - attempts += 1; - await createDispatchEvent(parameters); - throw apiError(502); - }; - - await monitorRemoteWorkflow({ - github, - core, - ...createClock(), - random: () => 0 - }); - - assert.deepEqual(core.failures, []); - assert.equal(attempts, 1); - assert.equal(github.dispatches.length, 1); - assert.equal(core.outputs.get("conclusion"), "success"); -}); - -test("waits for delayed visibility without repeating an uncertain dispatch", async (context) => { - for (const error of [ - apiError(503), - Object.assign(new Error("response lost"), { code: "ECONNRESET" }), - Object.assign(new Error("request timed out"), { code: "ETIMEDOUT" }) - ]) { - await context.test(error.message, async () => { - const core = createCore({ - MAX_WAIT_SECONDS: "60", - POLL_INTERVAL_SECONDS: "15", - REUSE_SUCCESSFUL: "false" - }); - const clock = createClock(); - const github = createGithub(); - const createDispatchEvent = github.rest.repos.createDispatchEvent; - const listWorkflowRuns = github.rest.actions.listWorkflowRuns; - let attempts = 0; - github.rest.repos.createDispatchEvent = async (parameters) => { - attempts += 1; - await createDispatchEvent(parameters); - throw error; - }; - github.rest.actions.listWorkflowRuns = async (parameters) => { - const response = await listWorkflowRuns(parameters); - if (clock.now() < 30000) { - response.data.workflow_runs = []; - } - return response; - }; - - await monitorRemoteWorkflow({ github, core, ...clock, random: () => 0 }); - - assert.deepEqual(core.failures, []); - assert.equal(attempts, 1); - assert.equal(github.dispatches.length, 1); - assert.equal(core.outputs.get("run_id"), "1000"); - assert.equal(core.outputs.get("run_state"), "found"); - assert.equal(core.outputs.get("conclusion"), "success"); - assert.equal(clock.now(), 30000); - }); - } -}); - -test("retries only explicitly rate-limited dispatches after correlated lookup", async (context) => { - for (const error of [ - apiError(429), - Object.assign(apiError(403), { - response: { headers: { "retry-after": "2" } } - }) - ]) { - await context.test(String(error.status), async () => { - const core = createCore(); - const github = createGithub(); - const createDispatchEvent = github.rest.repos.createDispatchEvent; - let attempts = 0; - github.rest.repos.createDispatchEvent = async (parameters) => { - attempts += 1; - if (attempts === 1) { - throw error; - } - return createDispatchEvent(parameters); - }; - - await monitorRemoteWorkflow({ - github, - core, - ...createClock(), - random: () => 0 - }); - - assert.deepEqual(core.failures, []); - assert.equal(attempts, 2); - assert.equal(github.dispatches.length, 1); - assert.equal(core.outputs.get("conclusion"), "success"); - }); - } -}); - -test("fails closed when an uncertain dispatch never becomes visible", async () => { - const core = createCore(); - const github = createGithub(); - const clock = createClock(); - let attempts = 0; - github.rest.repos.createDispatchEvent = async () => { - attempts += 1; - throw apiError(503); - }; - - await monitorRemoteWorkflow({ github, core, ...clock }); - - assert.equal(attempts, 1); - assert.equal(clock.now(), 30000); - assert.equal(core.outputs.get("run_state"), "unknown"); - assert.equal(core.failures.length, 1); - assert.match(core.failures[0], /publisher dispatch.*503/); - assert.match(core.failures[0], /outcome is unknown/); - assert.match( - core.failures[0], - /Inspect publisher runs and destination artifacts before retrying/ - ); -}); - -test("preserves the uncertain outcome when discovery fails", async () => { - const core = createCore(); - const github = createGithub(); - let attempts = 0; - github.rest.repos.createDispatchEvent = async () => { - attempts += 1; - github.rest.actions.listWorkflowRuns = async () => { - throw apiError(403, "Forbidden"); - }; - throw apiError(502); - }; - - await monitorRemoteWorkflow({ github, core, ...createClock() }); - - assert.equal(attempts, 1); - assert.equal(core.outputs.get("run_state"), "unknown"); - assert.match( - core.failures[0], - /recent publisher run lookup failed: Forbidden/ - ); -}); - -test("names the operation when lookup retries are exhausted", async () => { - const core = createCore(); - const github = createGithub(); - let attempts = 0; - github.rest.actions.listWorkflowRuns = async () => { - attempts += 1; - throw apiError(503); - }; - - await monitorRemoteWorkflow({ - github, - core, - ...createClock(), - random: () => 0 - }); - - assert.equal(attempts, 5); - assert.equal(github.dispatches.length, 0); - assert.equal( - core.failures[0], - "publisher run lookup failed after 5 attempts: GitHub API returned 503" - ); -}); - -test("names the expected run when rate-limited dispatch retries are exhausted", async () => { - const identifier = "0.61.0-bfbfbfbf"; - const core = createCore({ RELEASE_IDENTIFIER: identifier }); - const github = createGithub(); - let attempts = 0; - github.rest.repos.createDispatchEvent = async () => { - attempts += 1; - throw apiError(429); - }; - - await monitorRemoteWorkflow({ - github, - core, - ...createClock(), - random: () => 0 - }); - - assert.equal(attempts, 5); - assert.equal(github.dispatches.length, 0); - assert.equal( - core.failures[0], - `publisher dispatch 'deployment-engine' failed after 5 attempts: GitHub API returned 429; no run 'deployment-engine / ${identifier}' appeared. Inspect publisher runs and destination artifacts before retrying` - ); -}); - -test("monitors an existing active run to completion", async () => { - const identifier = "0.61.0-cccccccc"; - const active = { - id: 43, - display_title: `deployment-engine / ${identifier}`, - status: "in_progress", - conclusion: null - }; - const core = createCore({ RELEASE_IDENTIFIER: identifier }); - const github = createGithub({ - runs: [active], - getRun: (runID) => ({ - ...active, - id: runID, - status: "completed", - conclusion: "success" - }) - }); - const clock = createClock(); - - await monitorRemoteWorkflow({ github, core, ...clock }); - - assert.deepEqual(core.failures, []); - assert.equal(github.dispatches.length, 0); - assert.equal(github.calls.get, 1); - assert.equal(core.outputs.get("conclusion"), "success"); -}); - -test("dispatches a retry after an existing failed run", async () => { - const identifier = "0.61.0-dddddddd"; - const failed = { - id: 44, - display_title: `deployment-engine / ${identifier}`, - status: "completed", - conclusion: "failure", - html_url: "https://example.test/runs/44" - }; - const core = createCore({ RELEASE_IDENTIFIER: identifier }); - const github = createGithub({ runs: [failed] }); - - await monitorRemoteWorkflow({ github, core, ...createClock() }); - - assert.deepEqual(core.failures, []); - assert.equal(github.dispatches.length, 1); - assert.notEqual(core.outputs.get("run_id"), "44"); - assert.equal(core.outputs.get("conclusion"), "success"); -}); - -test("reports a newly dispatched failed retry with job diagnostics", async () => { - const identifier = "0.61.0-ffffffff"; - const core = createCore({ RELEASE_IDENTIFIER: identifier }); - const github = createGithub({ - runs: [], - jobs: [ - { - name: "Publish", - conclusion: "failure", - steps: [{ name: "Copy", conclusion: "failure" }] - } - ] - }); - github.rest.repos.createDispatchEvent = async ({ - event_type: eventType, - client_payload: payload - }) => { - github.dispatches.push({ eventType, payload }); - github.runs.push({ - id: 1001, - display_title: `${eventType} / ${payload.release_identifier}`, - status: "completed", - conclusion: "failure", - html_url: "https://example.test/runs/1001" - }); - }; - - await monitorRemoteWorkflow({ github, core, ...createClock() }); - - assert.equal(github.dispatches.length, 1); - assert.equal(github.calls.jobs, 1); - assert.match(core.failures[0], /Correlated remote workflow failed/); - assert.match(core.failures[0], /Step: Copy/); -}); - -test("ignores concurrent runs with other identifiers", async () => { - const firstID = "0.61.0-11111111"; - const secondID = "0.61.0-22222222"; - const runs = []; - const github = createGithub({ runs }); - const firstCore = createCore({ RELEASE_IDENTIFIER: firstID }); - const secondCore = createCore({ RELEASE_IDENTIFIER: secondID }); - - await Promise.all([ - monitorRemoteWorkflow({ github, core: firstCore, ...createClock() }), - monitorRemoteWorkflow({ github, core: secondCore, ...createClock() }) - ]); - - assert.deepEqual(firstCore.failures, []); - assert.deepEqual(secondCore.failures, []); - assert.equal(github.dispatches.length, 2); - assert.notEqual( - firstCore.outputs.get("run_id"), - secondCore.outputs.get("run_id") - ); - assert.equal( - github.dispatches.find( - (item) => item.payload.release_identifier === firstID - ).payload.release_identifier, - firstID - ); - assert.equal( - github.dispatches.find( - (item) => item.payload.release_identifier === secondID - ).payload.release_identifier, - secondID - ); -}); - -test("rejects malformed identifiers and mismatched payloads before API calls", async () => { - for (const identifier of ["bad identifier", "+meta", "a".repeat(201)]) { - const malformedCore = createCore({ RELEASE_IDENTIFIER: identifier }); - const malformedGithub = createGithub(); - await monitorRemoteWorkflow({ - github: malformedGithub, - core: malformedCore, - ...createClock() - }); - assert.match(malformedCore.failures[0], /Release identifier/); - assert.equal(malformedGithub.calls.list, 0); - assert.equal(malformedGithub.dispatches.length, 0); - } - - const mismatchedCore = createCore({ - CLIENT_PAYLOAD: JSON.stringify({ release_identifier: "other" }) - }); - const mismatchedGithub = createGithub(); - await monitorRemoteWorkflow({ - github: mismatchedGithub, - core: mismatchedCore, - ...createClock() - }); - assert.match(mismatchedCore.failures[0], /does not match/); - assert.equal(mismatchedGithub.calls.list, 0); -}); - -test("rejects plus signs in event types before API calls", async () => { - const core = createCore({ - EVENT_TYPE: "deployment+engine", - RELEASE_IDENTIFIER: "v1.2.3+meta" - }); - const github = createGithub(); - - await monitorRemoteWorkflow({ github, core, ...createClock() }); - - assert.match(core.failures[0], /Invalid event type/); - assert.equal(github.calls.list, 0); - assert.equal(github.dispatches.length, 0); -}); - -test("uses one total timeout budget for discovery and completion", async () => { - const identifier = "0.61.0-eeeeeeee"; - const core = createCore({ - RELEASE_IDENTIFIER: identifier, - MAX_WAIT_SECONDS: "2", - POLL_INTERVAL_SECONDS: "1" - }); - const github = createGithub(); - github.rest.repos.createDispatchEvent = async ({ - event_type: eventType, - client_payload: payload - }) => { - github.dispatches.push({ eventType, payload }); - }; - const clock = createClock(); - - await monitorRemoteWorkflow({ github, core, ...clock }); - - assert.equal(github.dispatches.length, 1); - assert.match(core.failures[0], /Timed out waiting for publisher run/); - assert.equal(core.outputs.get("run_state"), "unknown"); - assert.equal(clock.now(), 2000); -}); - -test("the controller never dispatches a second Deployment Engine publisher", async () => { - const workflow = await readFile( - new URL("../workflows/__release-controller.yaml", import.meta.url), - "utf8" - ); - assert.doesNotMatch( - workflow, - /publish-deployment-engine\.yml|monitor-remote-workflow\.mjs|radiusdeploymentengine\.azurecr\.io/ - ); -}); diff --git a/.github/scripts/release-controller_test.sh b/.github/scripts/release-controller_test.sh index fd939e9fc1..9d1f59fb2a 100644 --- a/.github/scripts/release-controller_test.sh +++ b/.github/scripts/release-controller_test.sh @@ -118,6 +118,14 @@ test_shared_controller_contract() { assert_not_contains "${workflow}" "RADIUS_PUBLISHER_BOT_" \ "current release controller must not pass or require publisher credentials" done + # The controller verifies the Deployment Engine image published by its own + # tag build; it never dispatches a second publisher or copies from ACR. + local publisher + for publisher in publish-deployment-engine.yml monitor-remote-workflow.mjs \ + radiusdeploymentengine.azurecr.io; do + assert_not_contains "${CONTROLLER}" "${publisher}" \ + "release controller must not use the retired Deployment Engine publisher (${publisher})" + done assert_yq "${APPROVE}" \ '.jobs.dispatch.uses == "./.github/workflows/__dispatch-release-controller.yaml"' \ diff --git a/.github/scripts/resolve-release-controller.mjs b/.github/scripts/resolve-release-controller.mjs index 433a5073ed..00cf44dd2b 100644 --- a/.github/scripts/resolve-release-controller.mjs +++ b/.github/scripts/resolve-release-controller.mjs @@ -211,8 +211,9 @@ export async function verifyReleaseBuildSource({ github, core, run = tool }) { ]; if (plan.changelogPolicy === "stable-only") args.push("--require-sibling-releases"); - if (!manifest) - args.push("--require-current-bicep", "--require-current-engine"); + // Published releases resume with their tagged workflows too. Reject sources + // that still need the retired azure-octo/radius-publisher or its App. + args.push("--require-current-bicep", "--require-current-engine"); await run(args); if (engine) { core.setOutput("de-source-commit", engine.sourceSha); diff --git a/.github/scripts/resolve-release-controller_test.mjs b/.github/scripts/resolve-release-controller_test.mjs index f5fd2e1c5a..0ca570a923 100644 --- a/.github/scripts/resolve-release-controller_test.mjs +++ b/.github/scripts/resolve-release-controller_test.mjs @@ -81,7 +81,7 @@ test("absent and draft releases reject selector-free approved plans against actu } }); -test("published historical sources retain validation and recovery; unpublished sources require GHCR-only writers", async (t) => { +test("published sources retain recovery evidence, and every source requires current GHCR and Deployment Engine writers", async (t) => { const directory = await mkdtemp(join(tmpdir(), "approved-build-contract-")); t.after(() => rm(directory, { recursive: true, force: true })); for (const state of [ @@ -201,13 +201,10 @@ test("published historical sources retain validation and recovery; unpublished s plan.expectedOutputs ); calls.push("build-contract"); - if (["draft", "absent"].includes(state)) { - assert.ok(args.includes("--require-current-bicep")); - assert.ok(args.includes("--require-current-engine")); + assert.ok(args.includes("--require-current-bicep")); + assert.ok(args.includes("--require-current-engine")); + if (["draft", "absent"].includes(state)) throw new Error("requires the retired Bicep ACR writer"); - } - assert.ok(!args.includes("--require-current-bicep")); - assert.ok(!args.includes("--require-current-engine")); if (state === "unsupported workflow") throw new Error("does not enforce the publication gate"); return ""; diff --git a/build/test.mk b/build/test.mk index 93fda34f5f..ebc3b37dcf 100644 --- a/build/test.mk +++ b/build/test.mk @@ -54,7 +54,7 @@ GOTESTSUM_JSONFILE_DIR ?= GOTEST_TOOL ?= go tool gotestsum $(GOTESTSUM_OPTS) $(if $(GOTESTSUM_JSONFILE_DIR),--jsonfile=$(GOTESTSUM_JSONFILE_DIR)/$@.jsonl) -- .PHONY: test -test: test-get-envtools test-helm test-azure-oidc-login test-cloud-test-helpers test-manage-radius-installation test-purge-old-images test-release-parity-manifest test-verify-goreleaser-snapshot test-changelog-range test-changelog-config test-build-summary test-capture-release-image-digests test-release-tag-and-branch test-monitor-remote-workflow test-release-version-format test-prepare-release test-release-plan test-release-branch-commits test-release-cutover test-release-oci-artifacts test-release-sboms test-release-controller test-release-publication test-authz-would-deny-check ## Runs unit tests, excluding kubernetes controller tests +test: test-get-envtools test-helm test-azure-oidc-login test-cloud-test-helpers test-manage-radius-installation test-purge-old-images test-release-parity-manifest test-verify-goreleaser-snapshot test-changelog-range test-changelog-config test-build-summary test-capture-release-image-digests test-release-tag-and-branch test-release-version-format test-prepare-release test-release-plan test-release-branch-commits test-release-cutover test-release-oci-artifacts test-release-sboms test-release-controller test-release-publication test-authz-would-deny-check ## Runs unit tests, excluding kubernetes controller tests KUBEBUILDER_ASSETS="$(shell $(ENV_SETUP) use -p path ${K8S_VERSION} --arch amd64)" CGO_ENABLED=1 $(GOTEST_TOOL) ./pkg/... ./test/validation/... ./test/rogue/... $(GOTEST_OPTS) .PHONY: test-azure-oidc-login @@ -230,10 +230,6 @@ test-release-tag-and-branch: ## Tests release tag and branch reconciliation test-release-version-format: ## Tests release SemVer validation and tag parsing @bash ./.github/scripts/release-version-format_test.sh -.PHONY: test-monitor-remote-workflow -test-monitor-remote-workflow: ## Tests exact remote workflow dispatch correlation - @node --test ./.github/scripts/monitor-remote-workflow_test.mjs - .PHONY: test-workflow-changes test-workflow-changes: ## Tests reusable workflow change detection @node --test ./.github/scripts/changes_test.mjs diff --git a/docs/contributing/contributing-code/contributing-code-github-workflows/README.md b/docs/contributing/contributing-code/contributing-code-github-workflows/README.md index 5114e9bcc7..6f44ea623f 100644 --- a/docs/contributing/contributing-code/contributing-code-github-workflows/README.md +++ b/docs/contributing/contributing-code/contributing-code-github-workflows/README.md @@ -145,7 +145,7 @@ Run the focused checks without registry credentials: ```bash make install-yq -PATH="${YQ_INSTALL_DIR:-$HOME/.local/bin}:$PATH" node --test .github/scripts/bicep-types.test.mjs .github/scripts/monitor-remote-workflow_test.mjs +PATH="${YQ_INSTALL_DIR:-$HOME/.local/bin}:$PATH" node --test .github/scripts/bicep-types.test.mjs actionlint .github/workflows/build-main.yaml .github/workflows/__publish-bicep-types.yaml ``` @@ -195,7 +195,7 @@ Remaining production ACR references are intentional and must be classified befor The final retirement PR follows consumer rollout. First establish required canonical version/channel/RC/digest coverage and a CLI/container release that uses it, update supported external consumers, and finish unpublished legacy and transitional mirror-dependent releases. Public `edge` alone is insufficient. Preserve already-published plans, release branches, locks, receipts and read-only reconciliation; stopping publication does not authorize deleting ACR data or shared credentials. -The final layer retains GHCR native digest, source, retry and public-access checks; paired locks, AWS evidence, attestation, staged installation, post-approval rechecks and channel/latest eligibility remain required. Published historical resume authenticates the exact Radius tag/source, retained verified release manifest and existing AWS tag before inspecting the old workflow contract. It preserves downstream recovery but never recreates the AWS tag or regenerates missing published AWS evidence. Unsupported old contracts fail explicitly. The source retirements precede the private receiver guard; no new identity system or global credential gate is introduced. +The final layer retains GHCR native digest, source, retry and public-access checks; paired locks, AWS evidence, attestation, staged installation, post-approval rechecks and channel/latest eligibility remain required. Published resume authenticates the exact Radius tag/source, retained verified release manifest and existing AWS tag, then requires the same GHCR-only Bicep and transferred Deployment Engine contract as a new release, so a tagged workflow that still uses the retired `azure-octo/radius-publisher` or its App cannot resume. It never recreates the AWS tag or regenerates missing published AWS evidence. Unsupported old contracts fail explicitly. The source retirements precede the private receiver guard; no new identity system or global credential gate is introduced. ## Verification diff --git a/docs/contributing/contributing-releases/README.md b/docs/contributing/contributing-releases/README.md index 42242959c5..e0d5e6bf56 100644 --- a/docs/contributing/contributing-releases/README.md +++ b/docs/contributing/contributing-releases/README.md @@ -25,7 +25,7 @@ Backport selection, collection, preparation, and their tests live only in the [s - 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. - Deploy the coordinated publishers before using this Radius pipeline. Bicep releases require native GHCR producers, the immutable AWS/Radius paired lock, and anonymous access to both full-version references; no private Bicep copy or promotion receiver is used after retirement. Finish the [transitional Bicep handoff](#ordered-merge-and-writer-handoff) before disabling its old receivers. For Deployment Engine, drain old mirror runs and retire the private DE copy receiver before activating the direct publisher. The approved commit must include `.github/workflows/build-and-push.yaml` from the transferred repository. A final cannot promote an RC that predates this publisher; cut a new RC instead. Dashboard release builds must stage full-version tags without updating channels. Production Azure remains private. -- Before switching the Deployment Engine controller on `main`, list every approved but unpublished Radius release, including drafts with a staged image. At each **approved Radius SHA**, check that `engine-token` in `build-release.yaml` uses `RADIUS_RELEASE_BOT_*` for `radius-project/deployment-engine`. Without a verified published manifest, the controller rejects a workflow that still targets `azure-octo` or uses the publisher credentials. A backport does not change an already approved SHA. Finish affected releases on a compatible path before cutover, or record a maintainer-approved break-glass decision for each in the release thread. Published releases may resume with their original tagged workflows; retain `RADIUS_PUBLISHER_BOT_*` and its installation access while those retries are supported. Do not move tags or treat a staged image as a published manifest. +- Before switching the Deployment Engine controller on `main`, list every approved but unpublished Radius release, including drafts with a staged image. At each **approved Radius SHA**, check that `engine-token` in `build-release.yaml` uses `RADIUS_RELEASE_BOT_*` for `radius-project/deployment-engine`. Without a verified published manifest, the controller rejects a workflow that still targets `azure-octo` or uses the publisher credentials. A backport does not change an already approved SHA. Finish affected releases on a compatible path before cutover, or record a maintainer-approved break-glass decision for each in the release thread. The controller applies the same check, and the GHCR-only Bicep check, when it resumes a published release, so no release workflow may use the retired `azure-octo/radius-publisher` repository, its App, or `RADIUS_PUBLISHER_BOT_*`. Do not move tags or treat a staged image as a published manifest. - Use the Teams release thread for approvals and exceptional recovery. Set the optional `RELEASE_TEAMS_WEBHOOK` secret to an HTTPS Adaptive Card endpoint for automated updates. GitHub summaries remain authoritative when notifications are unavailable. ### Confirm readiness before the first production cycle @@ -175,7 +175,7 @@ Pair reconciliation has package-read permission; finalization uses its existing Writes are not transactional. Finalization retains a 24-minute operation budget inside its 30-minute job, reserving time for receipts. Inspect `bicep-publication--`: `receipt.json` records finalization status/errors and `ghcr-receipt.json` records partial aliases. Retry against the same immutable lock; exact readback reconciles uncertain writes without recopying verified aliases. Old mirror receipts remain historical evidence and are not rewritten. -Published historical resume authenticates the exact Radius tag/source and retained verified `release-manifest.json`, then checks the historical workflow contract rather than requiring the new writer. It also requires the existing AWS tag at the frozen source, skips recreating that tag, and rejects missing published GHCR AWS evidence before collection/dispatch. API, provenance and unsupported-contract failures stop recovery. Bicep producers and finalizers remain skipped for published releases; existing Deployment Engine, sibling-release, docs and samples recovery is retained. Historical ACR inspection does not backfill artifacts or repair aliases. +Published resume authenticates the exact Radius tag/source and retained verified `release-manifest.json`, then requires the same GHCR-only Bicep and transferred Deployment Engine contract as a new release. A tagged workflow that still reaches the retired `azure-octo/radius-publisher` or its App cannot resume. It also requires the existing AWS tag at the frozen source, skips recreating that tag, and rejects missing published GHCR AWS evidence before collection/dispatch. API, provenance and unsupported-contract failures stop recovery. Bicep producers and finalizers remain skipped for published releases; existing Deployment Engine, sibling-release, docs and samples recovery is retained. Historical ACR inspection does not backfill artifacts or repair aliases. GHCR Bicep `latest` means newest stable and `edge` means development; only legacy ACR Bicep `latest` retains its development meaning. Dashboard and Deployment Engine images follow the same newest-stable `latest` and main-only `edge` policy as other release images. @@ -224,7 +224,7 @@ Authenticated AWS evidence is stored once in `.github/release-state/bicep-extens #### Ordered merge and writer handoff -Steps 1-7 describe the transitional dual-publish rollout. They remain prerequisites/history, not instructions to restore removed callers after final retirement. +The handoff is complete and `azure-octo/radius-publisher` is retired. No `radius-project` workflow may dispatch to it, mint a token for it or its App, or use `RADIUS_PUBLISHER_BOT_*`, and the controller rejects release sources, published or not, whose tagged workflows still do. Steps 1-7 record the completed transitional dual-publish rollout. They are history, not instructions to restore removed callers or receivers. 1. Deploy and test private copy capability from [azure-octo/radius-publisher#38](https://github.com/azure-octo/radius-publisher/pull/38) first. Prepare the corrected Radius and AWS callers before the first public GHCR edge/cutover. Keep private Azure authority and both staging events plus the promotion receiver; do not disable the service or remove shared credentials. 2. Build on the merged release foundation in dependency order: cloud isolation, main publishing (#13119), R1 (#13179), R2 (#13177), and R3 (#13178). The AWS companion and private-copy caller are merged in [radius-project/bicep-types-aws#321](https://github.com/radius-project/bicep-types-aws/pull/321) and [radius-project/bicep-types-aws#322](https://github.com/radius-project/bicep-types-aws/pull/322); include their required source support in the frozen sibling and retain original-snapshot recovery. Their legacy tag-only publisher remains for releases before R3 activation. At the coordinated handoff, drain old plans and retire that generation route before tagging a new `ghcr-v1` release: it must not independently generate ACR bytes for the same version that R3 will copy by digest. A1 staging alone does not establish GHCR/ACR parity. @@ -250,7 +250,7 @@ Preserve private `test/radius` and `test/aws`, Deployment Engine, Static Web App Final retirement order is **verified GHCR consumer coverage and completed old work -> both source caller retirements -> private receiver guard last**. Finish unpublished legacy plans and transitional GHCR releases whose tagged workflows still require mirrors; drain old queued/running source and receiver revisions. A new-main guard cannot retroactively change tagged workflow code. Coordinate AWS caller retirement in [radius-project/bicep-types-aws#389](https://github.com/radius-project/bicep-types-aws/pull/389), then private guard [azure-octo/radius-publisher#40](https://github.com/azure-octo/radius-publisher/pull/40). Required versioned packages, supported external consumers and real RC/stable rehearsals must be verified; these code changes do not assert readiness or perform activation. -Published historical releases retain read-only ACR reconciliation and existing downstream recovery. Unpublished legacy or mirror-dependent sources are rejected by the current controller before mutation. Never rewrite an approved plan, move an existing tag or replace a lock to evade that rejection. Keep ACR data, explicit Test routes, unrelated images/recipes/services and shared credentials. See the [migration design](../../../eng/design-notes/tools/2026-09-bicep-extension-ghcr-migration.md#parallel-execution-and-queueing). +The current controller rejects legacy or mirror-dependent sources before mutation, including when resuming a published release. Never rewrite an approved plan, move an existing tag or replace a lock to evade that rejection. Keep ACR data, explicit Test routes, unrelated images/recipes/services and shared credentials. See the [migration design](../../../eng/design-notes/tools/2026-09-bicep-extension-ghcr-migration.md#parallel-execution-and-queueing). Default parity inspection reads the release source's `targets.json`. Published releases predating that file, such as `v0.60.0` and `v0.60.1`, use the frozen [legacy inventory](../../../.github/release-parity/legacy-targets.json) only when GitHub confirms both the targets file and that version's release plan are absent (HTTP 404). This inventory preserves the original parity tooling's ACR channel references and historical test images; it does not inherit current GHCR defaults. Staged releases, a present approved plan with missing targets, authentication failures and network errors never take this fallback. Explicit `RELEASE_PARITY_TARGETS` or `--plan-file` inputs retain their existing behavior. diff --git a/docs/contributing/contributing-releases/release-runbook.md b/docs/contributing/contributing-releases/release-runbook.md index 7b974626e5..2b6d3071c8 100644 --- a/docs/contributing/contributing-releases/release-runbook.md +++ b/docs/contributing/contributing-releases/release-runbook.md @@ -106,9 +106,11 @@ gh workflow run publish-bicep-recipes.yaml --repo radius-project/resource-types- **Resume a failed or interrupted release:** fix the reported cause, then use [Resume Release](https://github.com/radius-project/radius/actions/workflows/resume-release.yaml) from `main`. Prefer the exact command in the failed summary. Otherwise replace both example inputs below with that summary's version and full source SHA: ```bash -gh workflow run resume-release.yaml --repo radius-project/radius --ref main -f version=v0.62.0-rc.1 -f source-commit="" +gh workflow run resume-release.yaml --repo radius-project/radius --ref main -f version=v0.63.0-rc.1 -f source-commit="" ``` +Resume requires the current GHCR-only Bicep and Deployment Engine release contract, including for published releases. A release whose tagged workflows still use the retired `azure-octo/radius-publisher` cannot resume. + For a frozen first RC, use the resolved release commit from the summary. Before resolution, use the merged metadata PR commit; replaying that same approval identity reuses the original resolved commit. Legacy first RCs and existing-channel releases retain their original release PR squash or metadata-backport commit. **Never substitute the raw product cutoff or current branch tip.** Resume preserves matching tags and locked digests; approvals may be required again. **Older open first-RC preparation:** after frozen-source support is deployed, rerun preparation once with the same type/channel to migrate an unmerged `productRef: HEAD` plan. This retains its cutoff and PM curation and returns the PR to draft for renewed review. Do not migrate or reprepare a merged or tagged release; resume its existing identity. diff --git a/eng/design-notes/tools/2026-09-bicep-extension-ghcr-migration.md b/eng/design-notes/tools/2026-09-bicep-extension-ghcr-migration.md index 357d4f9c41..f882e8c8b0 100644 --- a/eng/design-notes/tools/2026-09-bicep-extension-ghcr-migration.md +++ b/eng/design-notes/tools/2026-09-bicep-extension-ghcr-migration.md @@ -2,6 +2,8 @@ - **Author**: Will Smith (@willdavsmith) +> **Status:** The private `azure-octo/radius-publisher` writer is retired. No `radius-project` workflow may dispatch to it, mint a token for it or its App, or use `RADIUS_PUBLISHER_BOT_*`, and the Radius release controller rejects release sources, published or not, that still do. Sections below that describe the private receivers, historical-resume recovery, or retaining publisher credentials record the transition and are superseded. + ## Overview Radius publishes the Radius and AWS Bicep extensions to Azure Container Registry (ACR) and generates `bicepconfig.json` files that reference those artifacts. [Bicep v0.45.6 added support for publishing and restoring extensions from generic OCI registries](https://github.com/Azure/bicep/pull/18956), including GitHub Container Registry (GHCR). @@ -126,7 +128,7 @@ Work is split by repository and merged through explicit gates. The dual-publish handoffs below describe phases 3-5. **Phase 6 is a separate final retirement layer**, after required GHCR version/channel/RC/digest coverage, supported consumer rollout and completion of old work. Radius then removes main private-copy requests, release mirror staging/readback, the legacy dispatch workflow and private alias promotion helper. New receipts report GHCR-only publication; paired locks, AWS evidence, live source/digest verification, approvals, attestation, partial retry and GHCR alias eligibility remain required. No historical plan, lock or receipt is rewritten. -Before retiring either source caller, finish unpublished legacy releases and transitional GHCR releases whose tagged workflows still require ACR mirrors, and drain old queued/running revisions. Current-main code cannot revoke old tagged workflows. The trusted controller rejects unpublished sources requiring the retired writer before approval/tag creation. Published historical recovery authenticates the exact Radius tag/source, retained verified release manifest and existing AWS tag, then checks the historical workflow contract. It never recreates that AWS tag or regenerates missing published AWS evidence; Bicep producers/finalizers stay skipped while unrelated downstream recovery remains available. +Before retiring either source caller, finish unpublished legacy releases and transitional GHCR releases whose tagged workflows still require ACR mirrors, and drain old queued/running revisions. Current-main code cannot revoke old tagged workflows. The trusted controller rejects unpublished sources requiring the retired writer before approval/tag creation. *Superseded by the publisher retirement:* published historical recovery originally checked the historical workflow contract. The controller now requires the current writers for published resumes too, so historical sources that need the private publisher cannot resume. It still never recreates the AWS tag or regenerates missing published AWS evidence. Land both source caller retirements before the private production receiver guard: [radius-project/bicep-types-aws#389](https://github.com/radius-project/bicep-types-aws/pull/389) is the AWS companion and [azure-octo/radius-publisher#40](https://github.com/azure-octo/radius-publisher/pull/40) is last. Preserve explicit Test targets, unrelated images/recipes/private services, shared credentials and ACR resources. Missing versioned GHCR artifacts and external-consumer gates still block activation; local tests and this design are not evidence that those gates passed. @@ -235,6 +237,8 @@ Release branches and existing user repositories cannot be rewritten centrally. T ### GitHub configuration cleanup +> **Superseded:** the guidance in this section to keep publisher secrets, App access or `azure-octo/radius-publisher` credentials for historical tagged jobs no longer applies. The publisher is retired and the controller rejects every source that needs it, so remove `RADIUS_PUBLISHER_BOT_*` and the publisher App's access to `radius-project` repositories once the private publisher's own non-Radius consumers are accounted for. + Remove settings only after their last workflow consumer is gone. The following retirement inventory applies after ACR compatibility ends, not at GHCR activation: retain the private Bicep exact-digest copy workflows, their Azure credentials, and scoped publisher App access throughout compatibility. Do not retire the private publisher wholesale. | Repository | Remove | Retain or repurpose |