Skip to content

Commit 2137cac

Browse files
add workflow run check
1 parent 7c443d9 commit 2137cac

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

.github/workflows/release.yml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,52 @@ on:
55
tags: [ 'v*' ] # Trigger release only on version tags
66

77
jobs:
8-
# Release job - publishes to crates.io when pushing version tags
8+
# Verify tests passed before release
9+
verify-tests:
10+
name: Verify tests passed
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check latest workflow run
14+
uses: actions/github-script@v7
15+
with:
16+
script: |
17+
// Get the commit SHA for the tag
18+
const tagRef = context.ref;
19+
const tagSha = context.sha;
20+
21+
console.log(`Checking tests for tag ${tagRef} (${tagSha})`);
22+
23+
// Get recent workflow runs for the test workflow
24+
const { data: workflows } = await github.rest.actions.listWorkflowRuns({
25+
owner: context.repo.owner,
26+
repo: context.repo.repo,
27+
workflow_id: 'test.yml',
28+
head_sha: tagSha,
29+
per_page: 1
30+
});
31+
32+
if (workflows.total_count === 0) {
33+
console.log('⚠️ No test workflow found for this commit');
34+
console.log('This might be expected if this is the first run after adding the tag trigger');
35+
return;
36+
}
37+
38+
const latestRun = workflows.workflow_runs[0];
39+
console.log(`Latest test run: ${latestRun.status} (${latestRun.conclusion})`);
40+
41+
if (latestRun.conclusion !== 'success') {
42+
console.log('❌ Tests did not pass - release cannot proceed');
43+
process.exit(1);
44+
}
45+
46+
console.log('✅ Tests passed - release can proceed');
47+
48+
# Release job - publishes to crates.io when version tags are pushed
949
release:
1050
name: Release to crates.io
1151
runs-on: ubuntu-latest
12-
# Use GitHub environment for enhanced security (optional but recommended)
52+
needs: verify-tests
53+
# Use GitHub environment for enhanced security and manual approval if desired
1354
environment: release
1455
permissions:
1556
id-token: write # Required for OIDC token exchange with crates.io

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Test SpacetimeDSL
33
on:
44
push:
55
branches: [ main, develop ]
6+
tags: [ 'v*' ] # Also run tests when version tags are pushed
67
pull_request:
78
branches: [ main, develop ]
89

0 commit comments

Comments
 (0)