Skip to content

Commit bc4872d

Browse files
committed
CI: add per-commit workflow triggered by ci:per-commit label
When a PR with the ci:per-commit label is merged, every commit pushed to main runs the full CI matrix. This makes it easy to identify which commit broke the build and revert it. Closes #59
1 parent cf08936 commit bc4872d

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: CI per commit (labeled PRs)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
check-label:
10+
name: Check for ci:per-commit label
11+
runs-on: ubuntu-latest
12+
outputs:
13+
has_label: ${{ steps.check.outputs.has_label }}
14+
steps:
15+
- name: Find associated PR and check label
16+
id: check
17+
env:
18+
GH_TOKEN: ${{ github.token }}
19+
run: |
20+
PRS=$(gh api \
21+
"repos/${{ github.repository }}/commits/${{ github.sha }}/pulls" \
22+
--jq '.[].number')
23+
HAS_LABEL="false"
24+
for pr in $PRS; do
25+
LABELS=$(gh api \
26+
"repos/${{ github.repository }}/pulls/${pr}" \
27+
--jq '.labels[].name')
28+
if echo "$LABELS" | grep -q "^ci:per-commit$"; then
29+
HAS_LABEL="true"
30+
break
31+
fi
32+
done
33+
echo "has_label=${HAS_LABEL}" >> "$GITHUB_OUTPUT"
34+
35+
ci:
36+
name: CI
37+
needs: check-label
38+
if: needs.check-label.outputs.has_label == 'true'
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
python-version: ["3.11", "3.12", "3.13"]
43+
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
44+
runs-on: ${{ matrix.os }}
45+
steps:
46+
- uses: actions/checkout@v6
47+
- name: Install uv
48+
uses: astral-sh/setup-uv@v6
49+
with:
50+
python-version: ${{ matrix.python-version }}
51+
- name: Install dependencies
52+
run: uv sync
53+
- name: lint
54+
run: uv run ruff check .
55+
- name: format check
56+
run: uv run black --check .
57+
- name: sort-check
58+
run: uv run isort --check-only .
59+
- name: typecheck
60+
run: uv run mypy l9format
61+
- name: test
62+
run: uv run pytest
63+
- name: security-audit
64+
run: uv run pip-audit

0 commit comments

Comments
 (0)