Skip to content

Commit 5a88801

Browse files
committed
refactor(release): keep nightly scheduling in the release workflow
1 parent 3e57be3 commit 5a88801

5 files changed

Lines changed: 17 additions & 105 deletions

File tree

‎.github/scripts/check-nightly-release.cjs‎

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,7 @@
11
const MINIMUM_RELEASE_GAP_MS = 6 * 60 * 60 * 1000;
22

3-
// The scheduler checks active runs before dispatch. The release workflow checks
4-
// the gap again under its nightly concurrency lock, in case a manual run won it.
5-
async function shouldReleaseNightly({
6-
github,
7-
context,
8-
core,
9-
checkActiveRuns = false,
10-
now = Date.now(),
11-
}) {
12-
if (checkActiveRuns) {
13-
for (const status of ["in_progress", "queued", "waiting", "pending", "requested"]) {
14-
const { data } = await github.rest.actions.listWorkflowRuns({
15-
...context.repo,
16-
workflow_id: "release.yml",
17-
status,
18-
per_page: 1,
19-
});
20-
if (data.total_count > 0) {
21-
core.info(`A release is ${status}. Skipping this check.`);
22-
return false;
23-
}
24-
}
25-
}
26-
3+
// Runs after the workflow acquires the nightly concurrency lock.
4+
async function shouldReleaseNightly({ github, context, core, now = Date.now() }) {
275
const releases = await github.paginate(github.rest.repos.listReleases, {
286
...context.repo,
297
per_page: 100,

‎.github/scripts/check-nightly-release.test.cjs‎

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const nightly = (hoursAgo, overrides = {}) => ({
1111
...overrides,
1212
});
1313

14-
function fixture({ releases = [nightly(7)], comparisonStatus = "ahead", activeStatus } = {}) {
14+
function fixture({ releases = [nightly(7)], comparisonStatus = "ahead" } = {}) {
1515
const calls = [];
1616
return {
1717
calls,
@@ -21,12 +21,6 @@ function fixture({ releases = [nightly(7)], comparisonStatus = "ahead", activeSt
2121
core: { info() {} },
2222
github: {
2323
rest: {
24-
actions: {
25-
async listWorkflowRuns(params) {
26-
calls.push(params);
27-
return { data: { total_count: params.status === activeStatus ? 1 : 0 } };
28-
},
29-
},
3024
repos: {
3125
listReleases() {},
3226
async compareCommitsWithBasehead(params) {
@@ -91,27 +85,7 @@ test("compares against the published tag, including legacy nightly tags", async
9185
assert.equal(calls[0].basehead, `${tag}...new`);
9286
});
9387

94-
for (const status of ["in_progress", "queued", "waiting", "pending", "requested"]) {
95-
test(`skips dispatch when a release is ${status}`, async () => {
96-
const { options } = fixture({ activeStatus: status });
97-
options.github.paginate = async () => assert.fail("Must stop before checking releases");
98-
assert.equal(await shouldReleaseNightly({ ...options, checkActiveRuns: true }), false);
99-
});
100-
}
101-
102-
test("dispatches when no release is active and new commits are due", async () => {
103-
const { options } = fixture();
104-
assert.equal(await shouldReleaseNightly({ ...options, checkActiveRuns: true }), true);
105-
});
106-
107-
test("rechecks publication after a manual run finishes ahead of an automatic run", async () => {
108-
const { options } = fixture();
109-
assert.equal(await shouldReleaseNightly({ ...options, checkActiveRuns: true }), true);
110-
options.github.paginate = async () => [nightly(0)];
111-
assert.equal(await shouldReleaseNightly(options), false);
112-
});
113-
114-
test("fails instead of dispatching when GitHub cannot supply release state", async () => {
88+
test("fails instead of releasing when GitHub cannot supply release state", async () => {
11589
const { options } = fixture();
11690
options.github.paginate = async () => {
11791
throw new Error("GitHub unavailable");

‎.github/workflows/nightly-schedule.yml‎

Lines changed: 0 additions & 38 deletions
This file was deleted.

‎.github/workflows/release.yml‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
tags:
66
- "v*.*.*"
77
- "!v*-nightly.*"
8+
schedule:
9+
# Avoid minute zero, when GitHub scheduled jobs are busiest.
10+
- cron: "8,38 * * * *"
811
workflow_dispatch:
912
inputs:
1013
channel:
@@ -15,11 +18,6 @@ on:
1518
options:
1619
- stable
1720
- nightly
18-
automatic:
19-
description: "Apply scheduled nightly checks before releasing"
20-
required: false
21-
default: false
22-
type: boolean
2321
version:
2422
description: "Release version (for example 1.2.3 or v1.2.3)"
2523
required: false
@@ -32,7 +30,7 @@ on:
3230
# newest-wins single slot, so a queued stable tag can never be silently
3331
# dropped. Automatic nightlies recheck the release gap after leaving the queue.
3432
concurrency:
35-
group: release-${{ (inputs.channel == 'nightly') && 'nightly' || 'stable' }}
33+
group: release-${{ (github.event_name == 'schedule' || inputs.channel == 'nightly') && 'nightly' || 'stable' }}
3634
cancel-in-progress: false
3735
queue: max
3836

@@ -43,7 +41,7 @@ permissions:
4341
jobs:
4442
check_changes:
4543
name: Check automatic nightly release
46-
if: inputs.channel == 'nightly' && inputs.automatic
44+
if: github.event_name == 'schedule'
4745
runs-on: blacksmith-8vcpu-ubuntu-2404
4846
timeout-minutes: 5
4947
outputs:
@@ -67,7 +65,7 @@ jobs:
6765
needs: [check_changes]
6866
if: |
6967
!failure() && !cancelled() &&
70-
(!(inputs.channel == 'nightly' && inputs.automatic) || needs.check_changes.outputs.has_changes == 'true')
68+
(github.event_name != 'schedule' || needs.check_changes.outputs.has_changes == 'true')
7169
runs-on: blacksmith-8vcpu-ubuntu-2404
7270
timeout-minutes: 10
7371
outputs:
@@ -110,7 +108,7 @@ jobs:
110108
NIGHTLY_SHA: ${{ github.sha }}
111109
NIGHTLY_RUN_NUMBER: ${{ github.run_number }}
112110
run: |
113-
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" && "${DISPATCH_CHANNEL:-stable}" == "nightly" ]]; then
111+
if [[ "${GITHUB_EVENT_NAME}" == "schedule" || ( "${GITHUB_EVENT_NAME}" == "workflow_dispatch" && "${DISPATCH_CHANNEL:-stable}" == "nightly" ) ]]; then
114112
nightly_date="$(date -u -d "$NIGHTLY_DATE" +%Y%m%d)"
115113
116114
node scripts/resolve-nightly-release.ts \
@@ -219,7 +217,7 @@ jobs:
219217
needs: [check_changes]
220218
if: |
221219
!failure() && !cancelled() &&
222-
(!(inputs.channel == 'nightly' && inputs.automatic) || needs.check_changes.outputs.has_changes == 'true')
220+
(github.event_name != 'schedule' || needs.check_changes.outputs.has_changes == 'true')
223221
runs-on: blacksmith-8vcpu-ubuntu-2404
224222
timeout-minutes: 5
225223
environment:
@@ -319,7 +317,7 @@ jobs:
319317
needs: [check_changes]
320318
if: |
321319
!failure() && !cancelled() &&
322-
(!(inputs.channel == 'nightly' && inputs.automatic) || needs.check_changes.outputs.has_changes == 'true')
320+
(github.event_name != 'schedule' || needs.check_changes.outputs.has_changes == 'true')
323321
runs-on: blacksmith-8vcpu-ubuntu-2404
324322
timeout-minutes: 15
325323
steps:

‎docs/operations/release.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This document covers the unified release workflow for stable and nightly desktop
99
- Workflow: `.github/workflows/release.yml`
1010
- Triggers:
1111
- push tag matching `v*.*.*` for stable releases
12-
- scheduled nightly check every 30 minutes via `.github/workflows/nightly-schedule.yml`
12+
- scheduled nightly check every 30 minutes
1313
- manual `workflow_dispatch` for either channel
1414
- Runs lint, typecheck, and tests alongside artifact builds. Publishing waits for every check.
1515
- Reads the shared production T3 Connect relay URL and Clerk client configuration before packaging clients.
@@ -158,10 +158,10 @@ One-time Vercel dashboard setup:
158158

159159
- Workflow: `.github/workflows/release.yml`
160160
- Triggers:
161-
- scheduled check every 30 minutes via `.github/workflows/nightly-schedule.yml`
161+
- scheduled check every 30 minutes
162162
- manual `workflow_dispatch` with `channel=nightly`
163-
- Automatic nightlies require new commits and at least six hours since the last nightly was published, including manual nightlies. The scheduled check skips if a release is active or queued.
164-
- Manual nightlies bypass the time and change checks. Nightly runs remain serialized, and automatic runs recheck after leaving the queue.
163+
- Automatic nightlies require new commits and at least six hours since the last nightly was published, including manual nightlies.
164+
- Manual nightlies bypass the time and change checks. Nightly runs remain serialized. Scheduled runs wait for an active nightly to finish, then check the publication gap before building.
165165
- Runs the same desktop quality gates and artifact matrix as the tagged release flow.
166166
- Publishes a GitHub prerelease only:
167167
- current tag format: `vX.Y.Z-nightly.YYYYMMDD.<run_number>`

0 commit comments

Comments
 (0)