Skip to content

Commit 40104b2

Browse files
committed
ci: make release workflow depend on test workflow success
- Use workflow_run trigger to only run release after tests pass - Update Node.js version to 22 in release workflow - Fix job name to correctly show Node 22 in test workflow - Remove manual wait-for-tests logic since workflow_run handles it
1 parent 659730d commit 40104b2

2 files changed

Lines changed: 11 additions & 56 deletions

File tree

.github/workflows/release.yml

Lines changed: 9 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
name: Release
22

33
on:
4-
push:
4+
workflow_run:
5+
workflows: ["Test"]
6+
types:
7+
- completed
58
branches:
69
- main
710
workflow_dispatch:
@@ -29,60 +32,12 @@ jobs:
2932
name: Release
3033
runs-on: ubuntu-latest
3134
needs: [authorize]
32-
if: always() && (needs.authorize.result == 'success' || needs.authorize.result == 'skipped')
35+
if: |
36+
always() &&
37+
(needs.authorize.result == 'success' || needs.authorize.result == 'skipped') &&
38+
(github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success')
3339
3440
steps:
35-
# Wait for tests to complete successfully before releasing
36-
- name: Wait for Test workflow to succeed
37-
if: github.event_name == 'push'
38-
uses: actions/github-script@v7
39-
with:
40-
script: |
41-
const owner = context.repo.owner;
42-
const repo = context.repo.repo;
43-
const sha = context.sha;
44-
45-
// Wait for test workflow checks to complete
46-
let attempts = 0;
47-
const maxAttempts = 60; // 10 minutes max wait
48-
49-
while (attempts < maxAttempts) {
50-
const { data: checks } = await github.rest.checks.listForRef({
51-
owner,
52-
repo,
53-
ref: sha,
54-
});
55-
56-
const testChecks = checks.check_runs.filter(check =>
57-
check.name.startsWith('Test (Node 20, ESLint')
58-
);
59-
60-
if (testChecks.length === 0) {
61-
console.log('No test checks found yet, waiting...');
62-
} else {
63-
const allCompleted = testChecks.every(check => check.status === 'completed');
64-
const allSucceeded = testChecks.every(check => check.conclusion === 'success');
65-
66-
if (allCompleted) {
67-
if (allSucceeded) {
68-
console.log('All tests passed successfully!');
69-
break;
70-
} else {
71-
core.setFailed('Tests failed - cannot proceed with release');
72-
return;
73-
}
74-
}
75-
console.log(`Waiting for tests to complete... (${testChecks.filter(c => c.status === 'completed').length}/${testChecks.length})`);
76-
}
77-
78-
await new Promise(resolve => setTimeout(resolve, 10000)); // Wait 10 seconds
79-
attempts++;
80-
}
81-
82-
if (attempts >= maxAttempts) {
83-
core.setFailed('Timeout waiting for tests to complete');
84-
}
85-
8641
- name: Checkout
8742
uses: actions/checkout@v4
8843
with:
@@ -92,7 +47,7 @@ jobs:
9247
- name: Setup Node.js
9348
uses: actions/setup-node@v4
9449
with:
95-
node-version: 20
50+
node-version: 22
9651
cache: npm
9752

9853
- name: Install dependencies

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ jobs:
77
matrix:
88
os: [macos-latest, ubuntu-latest, windows-latest]
99
eslint-version: [8, 9]
10-
name: Test (Node 20, ESLint ${{ matrix.eslint-version }}, ${{ matrix.os }})
10+
name: Test (Node 22, ESLint ${{ matrix.eslint-version }}, ${{ matrix.os }})
1111
steps:
1212
- name: Check out Git repository
1313
uses: actions/checkout@v4
1414
- name: Setup Node.js
1515
uses: actions/setup-node@v4
1616
with:
17-
node-version: 20
17+
node-version: 22
1818
cache: npm
1919
- name: Install dependencies
2020
run: npm ci

0 commit comments

Comments
 (0)