44 push :
55 branches :
66 - main
7+ pull_request :
8+ types : [labeled]
9+ branches :
10+ - main
711
812jobs :
913 check-label :
@@ -12,53 +16,48 @@ jobs:
1216 outputs :
1317 has_label : ${{ steps.check.outputs.has_label }}
1418 steps :
15- - name : Find associated PR and check label
19+ - uses : actions/checkout@v6
20+ - name : Check for label
1621 id : check
1722 env :
1823 GH_TOKEN : ${{ github.token }}
1924 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"
25+ .github/scripts/check-ci-per-commit-label.sh \
26+ "${{ github.event_name }}" \
27+ "${{ github.repository }}" \
28+ "${{ github.sha }}" \
29+ '${{ toJSON(github.event.pull_request.labels.*.name) }}' \
30+ >> "$GITHUB_OUTPUT"
3431
35- ci :
36- name : CI
32+ ci-per-commit :
33+ name : CI per commit
3734 needs : check-label
3835 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 }}
36+ runs-on : ubuntu-latest
4537 steps :
4638 - uses : actions/checkout@v6
39+ with :
40+ fetch-depth : 0
4741 - name : Install uv
4842 uses : astral-sh/setup-uv@v6
4943 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
44+ python-version : " 3.13"
45+ - name : Determine commit range
46+ id : range
47+ env :
48+ GH_TOKEN : ${{ github.token }}
49+ run : |
50+ if [ "${{ github.event_name }}" = "pull_request" ]; then
51+ BASE="${{ github.event.pull_request.base.sha }}"
52+ HEAD="${{ github.event.pull_request.head.sha }}"
53+ else
54+ BASE="${{ github.event.before }}"
55+ HEAD="${{ github.sha }}"
56+ fi
57+ echo "base=${BASE}" >> "$GITHUB_OUTPUT"
58+ echo "head=${HEAD}" >> "$GITHUB_OUTPUT"
59+ - name : Run CI on each commit
60+ run : |
61+ .github/scripts/run-ci-per-commit.sh \
62+ "${{ steps.range.outputs.base }}" \
63+ "${{ steps.range.outputs.head }}"
0 commit comments