diff --git a/.github/workflows/daily-release.yml b/.github/workflows/daily-release.yml index dc42d3a0..e164fec5 100644 --- a/.github/workflows/daily-release.yml +++ b/.github/workflows/daily-release.yml @@ -253,7 +253,6 @@ jobs: checks: [], sameRepo: open.head?.repo?.full_name === open.base?.repo?.full_name, }, - mergedPrs: [], tags: state.tags, orphanBranches: state.orphanBranches, ciOk: state.ciOk, diff --git a/changelog.d/866-retire-drive-tag-action.changed.md b/changelog.d/866-retire-drive-tag-action.changed.md new file mode 100644 index 00000000..1f04b947 --- /dev/null +++ b/changelog.d/866-retire-drive-tag-action.changed.md @@ -0,0 +1 @@ +The daily release drive no longer carries a `tag` action. The release job never supplied it the merged pull request list, so the action could neither run nor be reported while `docs/deploy.md` said it was; the tag job remains the only tag writer and repairs a merged release pull request without a tag on its push and scheduled runs. diff --git a/docs/deploy.md b/docs/deploy.md index a29a4433..fcbb05ed 100644 --- a/docs/deploy.md +++ b/docs/deploy.md @@ -575,10 +575,12 @@ for someone to notice. A scheduled run acts on the merge commit of the merged later merge the tip is no longer that merge and the identity check would correctly refuse it; a scheduled run that cannot name exactly one such pull request keeps the tip, and the identity check then refuses it with its own reason rather than -guessing a release to repair. The release job's drive still reports `tag` (a merged -release pull request with no tag) — that is the night's summary line, not the -writer. **The tag job is the only tag writer**: the release job never creates a -tag, and its `tag` action is documented here rather than executed. +guessing a release to repair. **The tag job is the only tag writer**: the release +job never creates a tag, and its drive no longer carries a `tag` action at all. +That action was unreachable — the release job never fed it the merged pull request +list, so it could neither execute nor be reported — and it was removed rather than +left as a claim in the code; a merged release pull request without a tag is found +by the tag job itself (#866). Two recovery steps remain owner actions, unchanged by this slice: an orphan `release/vX.Y.Z` branch still cannot be deleted through the `keep release diff --git a/scripts/lib/release-drive.d.mts b/scripts/lib/release-drive.d.mts index dd979c88..017e423a 100644 --- a/scripts/lib/release-drive.d.mts +++ b/scripts/lib/release-drive.d.mts @@ -24,18 +24,9 @@ export interface DriveOpenReleasePr { sameRepo?: boolean } -export interface DriveMergedPr { - number: number - title: string - headRef?: string - mergeCommitSha?: string - mergedAt?: string -} - export interface DriveState { plan?: DrivePlan openReleasePr?: DriveOpenReleasePr | null - mergedPrs?: DriveMergedPr[] lastMergedPr?: { number: number; title: string; headRef: string } | null tags?: string[] ciOk?: string @@ -46,12 +37,10 @@ export interface DriveState { } export interface DriveDecision { - action: 'open-pr' | 'enqueue' | 'report-blocked' | 'tag' | 'wait-ci' | 'none' + action: 'open-pr' | 'enqueue' | 'report-blocked' | 'wait-ci' | 'none' reason: string pr?: number headSha?: string - tag?: string - sha?: string version?: string failing?: string[] branch?: string diff --git a/scripts/lib/release-drive.mjs b/scripts/lib/release-drive.mjs index 144fecf5..3488be1e 100644 --- a/scripts/lib/release-drive.mjs +++ b/scripts/lib/release-drive.mjs @@ -1,7 +1,7 @@ // Decide what the daily release run does, from the state the workflow collected. // -// Pure: the workflow gathers the state (tags, merged PRs, the open release PR, the -// latest ci-ok on main) and this function names exactly one action, so the night's +// Pure: the workflow gathers the state (tags, the open release PR, the latest +// ci-ok on main) and this function names exactly one action, so the night's // behaviour is testable without GitHub, a token or a clock. // // Actions: @@ -11,23 +11,24 @@ // mechanical shape: report and stop. An orphan `release/v` // branch is the same action with a different reason: it names // the branch and its sha, and the workflow turns it red (#333). -// tag a merged release PR has no tag yet: tag its squash commit // wait-ci the rule is met but `ci-ok` on main has not concluded yet: the // caller re-reads it on a bounded schedule and decides again // none no release tonight; the counts go to the summary // +// There is deliberately no `tag` action: the tag job is the only tag writer, and +// it repairs a merged release PR without a tag on its own push and schedule runs +// (#866). The action used to exist here but the release job never fed it the +// merged list, so it could neither execute nor be reported. +// // A dry run mutates nothing: `workflow_dispatch` defaults `dry_run: true`, so a // dry run that returned `enqueue` would set auto-merge on the default manual -// dispatch, and one that returned `tag` would publish. Every mutating action is -// reduced to `none` with the action it would have taken. +// dispatch. Every mutating action is reduced to `none` with the action it would +// have taken. // // Everything ambiguous returns an action with a reason rather than a guess. import { mechanicalRelease } from './mechanical-release.mjs' -const RELEASE_PR_TITLE = /^release: v(\d+\.\d+\.\d+)$/ -const RELEASE_PR_BRANCH = /^release\/v(\d+\.\d+\.\d+)$/ - // A release PR is only the release PR when it is the mechanical one. A PR whose // title merely starts with `release: v` — a docs-only `release: v9.9.9` — must // never be auto-merged as if the release routine had written it. @@ -66,9 +67,7 @@ function failingChecks(checks) { } function decide(state) { - const { plan, openReleasePr, tags, ciOk } = state ?? {} - - const tagList = Array.isArray(tags) ? tags : [] + const { plan, openReleasePr, ciOk } = state ?? {} if (openReleasePr !== null && openReleasePr !== undefined) { const number = Number(openReleasePr.number ?? 0) @@ -107,42 +106,6 @@ function decide(state) { return { action: 'enqueue', reason: `enqueue the open release PR #${String(number)}`, pr: number, headSha } } - // Every merged release PR that has no tag yet, newest first: the last merged PR - // is not necessarily the release PR — one unrelated merge after it used to mean - // the tag was silently never created. - const mergedList = Array.isArray(state?.mergedPrs) ? state.mergedPrs : [] - const pending = mergedList - .filter((pr) => RELEASE_PR_TITLE.test(String(pr?.title ?? ''))) - .map((pr) => { - const version = RELEASE_PR_TITLE.exec(String(pr?.title ?? ''))?.[1] ?? '' - return { - version, - tag: `v${version}`, - branch: String(pr?.headRef ?? ''), - number: Number(pr?.number ?? 0), - sha: String(pr?.mergeCommitSha ?? ''), - } - }) - .filter((candidate) => !tagList.includes(candidate.tag)) - .sort((left, right) => right.number - left.number) - if (pending.length > 0) { - const candidate = pending[0] - const branchMatch = RELEASE_PR_BRANCH.exec(candidate.branch) - if (branchMatch === null || branchMatch[1] !== candidate.version) { - return { action: 'none', reason: `the merged release PR ${candidate.tag} has no readable release branch; not tagging on a guess` } - } - if (candidate.sha === '') { - return { action: 'none', reason: `the merged release PR ${candidate.tag} has no merge commit sha; not tagging HEAD on a guess`, tag: candidate.tag, version: candidate.version } - } - return { - action: 'tag', - reason: `tag ${candidate.tag} on the squash commit ${candidate.sha} of the merged release PR #${String(candidate.number)}`, - tag: candidate.tag, - version: candidate.version, - sha: candidate.sha, - } - } - // A branch the routine itself pushed and then could not open a pull request for // is not a "different content" conflict to retry: nothing in the run can clear // it, and every later night would die in the push step with a message that does @@ -197,10 +160,10 @@ function decide(state) { // A dry run reports, it does not act. `workflow_dispatch` defaults `dry_run` to // true, so this is the default path for a manual dispatch: returning `enqueue` -// or `tag` from it would set auto-merge or publish on the first click. A dry run -// does not wait either: sitting on a runner for ten minutes to report a fact it -// already holds would only delay the summary. -const MUTATING = new Set(['open-pr', 'enqueue', 'tag']) +// from it would set auto-merge on the first click. A dry run does not wait +// either: sitting on a runner for ten minutes to report a fact it already holds +// would only delay the summary. +const MUTATING = new Set(['open-pr', 'enqueue']) export function decideDrive(state) { const decision = decide(state) @@ -221,9 +184,7 @@ export function decideDrive(state) { dryRun: true, wouldHave: String(decision.action), ...(decision.pr === undefined ? {} : { pr: decision.pr }), - ...(decision.tag === undefined ? {} : { tag: decision.tag }), ...(decision.version === undefined ? {} : { version: decision.version }), - ...(decision.sha === undefined ? {} : { sha: decision.sha }), } } return { ...decision, dryRun: true } diff --git a/test/mechanicalRelease.test.ts b/test/mechanicalRelease.test.ts index 90fce7b9..1a914572 100644 --- a/test/mechanicalRelease.test.ts +++ b/test/mechanicalRelease.test.ts @@ -10,7 +10,6 @@ import { isMechanicalPath, mechanicalRelease, releaseIdentity } from '../scripts const ROOT = fileURLToPath(new URL('..', import.meta.url)) const PLAN_OK = { shouldRelease: true, nextVersion: '0.3.0', reason: 'ok' } -const PLAIN_MERGE = { number: 7, title: 'feat: something', headRef: 'dev2/something', mergeCommitSha: 'f'.repeat(40) } const MECH_FILES = ['CHANGELOG.md', 'changelog.d/1.added.md', 'package.json', 'package-lock.json', 'docker-compose.yml'] const OPEN_RELEASE = { number: 141, @@ -142,19 +141,6 @@ test('a dry run never enqueues the open release PR', () => { assert.equal(decision.dryRun, true) }) -test('a dry run never tags the merged release PR', () => { - const decision = decideDrive({ - plan: { shouldRelease: false, nextVersion: '0.3.0', reason: 'open-release-pr' }, - mergedPrs: [{ number: 141, title: 'release: v0.3.0', headRef: 'release/v0.3.0', mergeCommitSha: 'c'.repeat(40) }], - tags: ['v0.2.4'], - ciOk: 'success', - dryRun: true, - }) - assert.equal(decision.action, 'none') - assert.equal(decision.wouldHave, 'tag') - assert.equal(decision.tag, 'v0.3.0') -}) - test('an open release PR is enqueued, never duplicated', () => { const decision = decideDrive({ plan: PLAN_OK, openReleasePr: OPEN_RELEASE, tags: [], ciOk: 'success' }) assert.equal(decision.action, 'enqueue') @@ -231,68 +217,19 @@ test('a mechanical-shaped open PR with a dependency change is not enqueued', () assert.match(decision.reason, /outside the mechanical set/) }) -test('a merged release PR whose tag is missing is tagged on its squash commit', () => { - const decision = decideDrive({ - plan: { shouldRelease: false, nextVersion: '0.3.0', reason: 'open-release-pr' }, - openReleasePr: null, - mergedPrs: [{ number: 141, title: 'release: v0.3.0', headRef: 'release/v0.3.0', mergeCommitSha: 'c'.repeat(40) }], - tags: ['v0.2.4'], - ciOk: 'success', - }) - assert.equal(decision.action, 'tag') - assert.equal(decision.tag, 'v0.3.0') - assert.equal(decision.sha, 'c'.repeat(40), 'the tag must name the merge commit, never HEAD') -}) - -test('an untagged release PR is found even when a later merge is the last PR', () => { - // #146 finding 4: scanning only the last merged PR meant one unrelated merge in - // between silently lost the tag. - const decision = decideDrive({ - plan: { shouldRelease: false, nextVersion: '0.3.0', reason: 'open-release-pr' }, - openReleasePr: null, - mergedPrs: [ - { number: 141, title: 'release: v0.3.0', headRef: 'release/v0.3.0', mergeCommitSha: 'c'.repeat(40) }, - PLAIN_MERGE, - ], - tags: ['v0.2.4'], - ciOk: 'success', - }) - assert.equal(decision.action, 'tag') - assert.equal(decision.tag, 'v0.3.0') - assert.equal(decision.sha, 'c'.repeat(40)) -}) - -test('a merged release PR that is already tagged does nothing', () => { - const decision = decideDrive({ +test('the release drive never decides a tag: the tag job is the only tag writer (#866)', () => { + // The drive's `tag` action was unreachable: the release job passes no merged + // PRs into it, so the action could neither execute nor be reported while + // docs/deploy.md said it was. The tag job owns every merged release PR without + // a tag, so the drive stays out of tagging even when a caller still supplies + // the merged list. + const state = { plan: { shouldRelease: false, nextVersion: '0.3.0', reason: 'tag-exists' }, openReleasePr: null, mergedPrs: [{ number: 141, title: 'release: v0.3.0', headRef: 'release/v0.3.0', mergeCommitSha: 'c'.repeat(40) }], - tags: ['v0.2.4', 'v0.3.0'], - ciOk: 'success', - }) - assert.equal(decision.action, 'none') -}) - -test('a release-looking merge without its release branch is never tagged on a guess', () => { - const decision = decideDrive({ - plan: { shouldRelease: false, nextVersion: '0.3.0', reason: 'tag-exists' }, - openReleasePr: null, - mergedPrs: [{ number: 141, title: 'release: v0.3.0', headRef: 'dev2/somewhere-else', mergeCommitSha: 'c'.repeat(40) }], tags: ['v0.2.4'], ciOk: 'success', - }) - assert.equal(decision.action, 'none') - assert.match(decision.reason, /no readable release branch/) -}) - -test('a merged release PR without a merge commit sha is not tagged on HEAD', () => { - const decision = decideDrive({ - plan: { shouldRelease: false, nextVersion: '0.3.0', reason: 'tag-exists' }, - openReleasePr: null, - mergedPrs: [{ number: 141, title: 'release: v0.3.0', headRef: 'release/v0.3.0' }], - tags: ['v0.2.4'], - ciOk: 'success', - }) - assert.equal(decision.action, 'none') - assert.match(decision.reason, /no merge commit sha/) + } as Parameters[0] + const decision = decideDrive(state) + assert.equal(decision.action, 'none', 'tagging belongs to the tag job, not the release drive') }) diff --git a/test/releaseState.test.ts b/test/releaseState.test.ts index a9840e92..bdf54808 100644 --- a/test/releaseState.test.ts +++ b/test/releaseState.test.ts @@ -200,7 +200,6 @@ test('a foreign release-shaped PR alone leaves the night releasable', () => { const decision = decideDrive({ plan: { shouldRelease: plan.shouldRelease, nextVersion: plan.nextVersion, reason: plan.reason }, openReleasePr: null, - mergedPrs: [], tags: state.tags, ciOk: state.ciOk, dryRun: false, @@ -230,7 +229,6 @@ test('a newer foreign PR cannot shadow this repository\'s own release PR', () => checks: [{ name: 'ci-ok', conclusion: 'success' }], sameRepo: true, }, - mergedPrs: [], tags: state.tags, ciOk: 'success', dryRun: false, @@ -278,7 +276,6 @@ function driveOrphan(state: ReturnType) { return decideDrive({ plan: PLAN_0302, openReleasePr: null, - mergedPrs: [], tags: state.tags, orphanBranches: state.orphanBranches, ciOk: state.ciOk, @@ -329,7 +326,6 @@ test('an orphan blocks the night even when the release rule is not met', () => { const decision = decideDrive({ plan: { shouldRelease: false, nextVersion: '0.3.2', reason: 'only 9 merged PRs, need 10' }, openReleasePr: null, - mergedPrs: [], tags: state.tags, orphanBranches: state.orphanBranches, ciOk: state.ciOk, @@ -380,17 +376,16 @@ test('the existing reasons are unchanged when the branch is not an orphan', () = merge_commit_sha: 'b'.repeat(40), }]], }) - const tagDecision = decideDrive({ + const mergedDecision = decideDrive({ plan: PLAN_0302, openReleasePr: null, - mergedPrs: [{ number: 208, title: 'release: v0.3.2', headRef: 'release/v0.3.2', mergeCommitSha: 'b'.repeat(40) }], tags: merged.tags, orphanBranches: merged.orphanBranches, ciOk: merged.ciOk, dryRun: false, }) - assert.equal(tagDecision.action, 'tag', 'a merged release PR without its tag is still tagged') - assert.doesNotMatch(tagDecision.reason, /orphan-branch/) + assert.equal(mergedDecision.action, 'open-pr', 'a merged release PR clears the orphan; the tag job owns its tag') + assert.doesNotMatch(mergedDecision.reason, /orphan-branch/) }) test('nothing is reported about branches when there is no release branch at all', () => {