Skip to content

Commit 95e1d79

Browse files
committed
ci: fix critical workflow issues and improve performance
**Critical Fixes:** - flake8.yml: Fix YAML syntax error (pull_request indentation) - release.yaml: Replace broken base_ref gate with git branch verification - test.yml: Add full-tests-with-coverage to test-summary dependencies **Performance Improvements:** - Add concurrency groups to prevent race conditions and save CI resources - Add pip caching to all workflows (20-30s speedup per run) - Restrict workflow triggers to master/main + PRs (reduce wasteful runs) **Code Quality:** - release.yaml: Remove redundant startsWith condition - Standardize trigger patterns across all workflows File-level changes: - .github/workflows/flake8.yml: Fix syntax, add concurrency, caching, restrict triggers - .github/workflows/release.yaml: Fix security gate, add branch verification, concurrency, caching - .github/workflows/test.yml: Add coverage to summary, concurrency, restrict triggers - .github/workflows/install.yml: Add concurrency, caching, restrict triggers - .github/workflows/cwa.yml: Add concurrency, caching, restrict triggers
1 parent 8354c82 commit 95e1d79

5 files changed

Lines changed: 64 additions & 8 deletions

File tree

.github/workflows/cwa.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ name: cwa
33
on:
44
push:
55
branches:
6-
- '**'
6+
- master
7+
- main
78
pull_request:
89

10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
13+
914
jobs:
1015
cwa:
1116

@@ -28,6 +33,7 @@ jobs:
2833
uses: actions/setup-python@v5
2934
with:
3035
python-version: ${{ matrix.python-version }}
36+
cache: 'pip'
3137

3238
- name: Setup java
3339
uses: actions/setup-java@v4

.github/workflows/flake8.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ name: flake8
55
on:
66
push:
77
branches:
8-
- '**'
9-
pull_request:
8+
- master
9+
- main
10+
pull_request:
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
1015

1116
jobs:
1217
flake8:
@@ -19,6 +24,7 @@ jobs:
1924
uses: actions/setup-python@v5
2025
with:
2126
python-version: "3.10"
27+
cache: 'pip'
2228

2329
- name: Install linter
2430
run: |

.github/workflows/install.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ name: install
55
on:
66
push:
77
branches:
8-
- '**'
8+
- master
9+
- main
910
pull_request:
1011

12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
15+
1116
jobs:
1217
install:
1318
runs-on: ${{matrix.os}}
@@ -42,6 +47,7 @@ jobs:
4247
uses: actions/setup-python@v5
4348
with:
4449
python-version: ${{ matrix.python-version }}
50+
cache: 'pip'
4551

4652
- name: Pip install
4753
run: |

.github/workflows/release.yaml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ on:
88
permissions:
99
contents: write
1010

11+
concurrency:
12+
group: release-${{ github.ref }}
13+
cancel-in-progress: false
14+
1115
jobs:
1216
build-n-publish:
13-
if: github.event.base_ref == 'refs/heads/main' || github.event.base_ref == 'refs/heads/master'
1417
name: Publish to PyPI
1518
runs-on: ubuntu-latest
1619

@@ -25,6 +28,32 @@ jobs:
2528
# https://github.com/actions/checkout/issues/338
2629
fetch-depth: 0
2730

31+
- name: Verify tag is from master branch
32+
run: |
33+
echo "Verifying that tag ${{ github.ref_name }} was created from main/master branch..."
34+
35+
# Get all remote branches containing this commit
36+
BRANCHES=$(git branch -r --contains ${{ github.sha }} | sed 's/^[[:space:]]*//')
37+
38+
echo "Branches containing commit ${{ github.sha }}:"
39+
echo "$BRANCHES"
40+
41+
# Check if main or master is in the list
42+
if ! echo "$BRANCHES" | grep -qE 'origin/(main|master)$'; then
43+
echo ""
44+
echo "❌ ERROR: Tag ${{ github.ref_name }} was not created from main/master branch"
45+
echo "This is a security measure to prevent releases from feature branches."
46+
echo ""
47+
echo "To fix this:"
48+
echo "1. Checkout main/master branch: git checkout master"
49+
echo "2. Create tag from main/master: git tag ${{ github.ref_name }}"
50+
echo "3. Delete the incorrect tag: git push --delete origin ${{ github.ref_name }}"
51+
echo "4. Push the correct tag: git push origin ${{ github.ref_name }}"
52+
exit 1
53+
fi
54+
55+
echo "✅ Verified: Tag was created from main/master branch"
56+
2857
- name: Setup Java
2958
uses: actions/setup-java@v4
3059
with:
@@ -40,6 +69,7 @@ jobs:
4069
uses: actions/setup-python@v5
4170
with:
4271
python-version: "3.10"
72+
cache: 'pip'
4373

4474
- name: Install dependencies and package
4575
run: |
@@ -68,7 +98,6 @@ jobs:
6898
repository-url: https://test.pypi.org/legacy/
6999

70100
- name: Publish distribution 📦 to PyPI
71-
if: startsWith(github.ref, 'refs/tags')
72101
uses: pypa/gh-action-pypi-publish@release/v1
73102
with:
74103
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/test.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ name: test
66
on:
77
push:
88
branches:
9-
- '**'
9+
- master
10+
- main
1011
pull_request:
1112

13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
16+
1217
jobs:
1318
# Fast unit tests - run on every push
1419
unit-tests:
@@ -172,7 +177,7 @@ jobs:
172177
# Test summary - all jobs must pass
173178
test-summary:
174179
runs-on: ubuntu-latest
175-
needs: [unit-tests, regression-tests, integration-tests]
180+
needs: [unit-tests, regression-tests, integration-tests, full-tests-with-coverage]
176181
if: always() && !cancelled()
177182

178183
steps:
@@ -190,4 +195,8 @@ jobs:
190195
echo "❌ Integration tests failed"
191196
exit 1
192197
fi
198+
if [ "${{ needs.full-tests-with-coverage.result }}" != "success" ] && [ "${{ needs.full-tests-with-coverage.result }}" != "skipped" ]; then
199+
echo "❌ Full tests with coverage failed"
200+
exit 1
201+
fi
193202
echo "✅ All required tests passed!"

0 commit comments

Comments
 (0)