Skip to content

Commit 9c834d8

Browse files
kompreclaude
andcommitted
Fix workflow race conditions and test triggering
Issue 1: Multiple label additions triggered duplicate version-bump runs Solution: Add concurrency control to cancel in-progress runs per PR Issue 2: Test workflow never ran after version bump (GITHUB_TOKEN commits don't trigger workflows), blocking auto-merge Solution: Add workflow_run trigger to test.yml to run after version-bump completes successfully Changes: - version-bump.yml: Add concurrency group by PR number with cancel-in-progress - version-bump.yml: Remove [skip ci] (not needed, doesn't work anyway) - test.yml: Add workflow_run trigger from Version Bump workflow - test.yml: Remove skip ci checking logic (not needed) - test.yml: Checkout correct SHA for both pull_request and workflow_run events Now: Version bump → test runs automatically → auto-merge proceeds 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ce5ba20 commit 9c834d8

2 files changed

Lines changed: 29 additions & 19 deletions

File tree

.github/workflows/test.yml

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,60 @@ name: Run Tests
33
on:
44
pull_request:
55
branches: [ main ]
6+
workflow_run:
7+
workflows: ["Version Bump"]
8+
types: [completed]
69

710
permissions:
811
contents: read
912

1013
jobs:
1114
test:
15+
# Only run on PRs or successful version bump completions
16+
if: |
17+
github.event_name == 'pull_request' ||
18+
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
1219
runs-on: ubuntu-latest
1320

1421
steps:
15-
- uses: actions/checkout@v4
16-
with:
17-
fetch-depth: 2
18-
19-
- name: Check for skip ci
20-
id: check-skip
22+
- name: Get PR details
23+
if: github.event_name == 'workflow_run'
24+
id: pr
25+
env:
26+
GH_TOKEN: ${{ github.token }}
2127
run: |
22-
COMMIT_MSG=$(git log -1 --pretty=%B)
23-
if echo "$COMMIT_MSG" | grep -q "\[skip ci\]"; then
24-
echo "skip=true" >> $GITHUB_OUTPUT
25-
echo "Skipping tests due to [skip ci] in commit message"
26-
else
27-
echo "skip=false" >> $GITHUB_OUTPUT
28-
fi
28+
# Get PR number from the workflow run
29+
PR_NUMBER=$(gh api repos/${{ github.repository }}/pulls \
30+
--jq ".[] | select(.head.sha == \"${{ github.event.workflow_run.head_sha }}\") | .number" \
31+
| head -1)
32+
33+
echo "number=$PR_NUMBER" >> $GITHUB_OUTPUT
34+
echo "PR number: $PR_NUMBER"
35+
36+
- name: Checkout PR branch
37+
uses: actions/checkout@v4
38+
with:
39+
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.event.pull_request.head.sha }}
2940

3041
- name: Set up Python
31-
if: steps.check-skip.outputs.skip != 'true'
3242
uses: actions/setup-python@v5
3343
with:
3444
python-version-file: ".python-version"
3545

3646
- name: Install uv
37-
if: steps.check-skip.outputs.skip != 'true'
3847
uses: astral-sh/setup-uv@v6
3948
with:
4049
version: "latest"
4150
enable-cache: true
4251
cache-dependency-glob: "uv.lock"
4352

4453
- name: Install Quarto
45-
if: steps.check-skip.outputs.skip != 'true'
4654
uses: quarto-dev/quarto-actions/setup@v2
4755
with:
4856
version: 1.8.25
4957

5058
- name: Install dependencies
51-
if: steps.check-skip.outputs.skip != 'true'
5259
run: uv sync --locked --all-extras --dev
5360

5461
- name: Run tests
55-
if: steps.check-skip.outputs.skip != 'true'
5662
run: uv run pytest tests -v

.github/workflows/version-bump.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
types: [labeled]
66
branches: [main]
77

8+
concurrency:
9+
group: version-bump-${{ github.event.pull_request.number }}
10+
cancel-in-progress: true
11+
812
jobs:
913
bump-version:
1014
# Only run if PR has at least one bump: label
@@ -98,7 +102,7 @@ jobs:
98102
if git diff --staged --quiet; then
99103
echo "No changes to commit"
100104
else
101-
git commit -m "Bump version to ${{ steps.bump.outputs.new_version }} [skip ci]"
105+
git commit -m "Bump version to ${{ steps.bump.outputs.new_version }}"
102106
103107
# Pull with rebase in case another workflow pushed
104108
git pull --rebase origin ${{ github.head_ref }}

0 commit comments

Comments
 (0)