Skip to content

Commit 55eee14

Browse files
committed
CI: use Makefile targets in Windows job and add per-commit testing
Use Makefile targets in the Windows CI job instead of raw poetry commands. Add per-commit CI workflow triggered by the ci:per-commit label, with helper scripts for label checking and sequential commit testing.
1 parent d8100be commit 55eee14

4 files changed

Lines changed: 156 additions & 5 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
# Check if the ci:per-commit label is present.
3+
#
4+
# For pull_request events, checks labels from the event payload.
5+
# For push events, looks up the originating PR via the GitHub API.
6+
#
7+
# Usage:
8+
# check-ci-per-commit-label.sh <event_name> <repository> <sha> [labels_json]
9+
#
10+
# Arguments:
11+
# event_name - "pull_request" or "push"
12+
# repository - e.g. "owner/repo"
13+
# sha - commit SHA
14+
# labels_json - JSON array of label names (required for pull_request)
15+
#
16+
# Output:
17+
# Prints has_label=true or has_label=false (for GITHUB_OUTPUT)
18+
set -euo pipefail
19+
20+
event_name="${1:?Usage: check-ci-per-commit-label.sh <event_name> <repository> <sha> [labels_json]}"
21+
repository="${2:?Missing repository}"
22+
sha="${3:?Missing sha}"
23+
labels_json="${4:-}"
24+
25+
HAS_LABEL="false"
26+
27+
if [ "$event_name" = "pull_request" ]; then
28+
if echo "$labels_json" | grep -q "ci:per-commit"; then
29+
HAS_LABEL="true"
30+
fi
31+
else
32+
PRS=$(gh api \
33+
"repos/${repository}/commits/${sha}/pulls" \
34+
--jq '.[].number')
35+
for pr in $PRS; do
36+
LABELS=$(gh api \
37+
"repos/${repository}/pulls/${pr}" \
38+
--jq '.labels[].name')
39+
if echo "$LABELS" | grep -q "^ci:per-commit$"; then
40+
HAS_LABEL="true"
41+
break
42+
fi
43+
done
44+
fi
45+
46+
echo "has_label=${HAS_LABEL}"
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
# Run the full CI checks on each commit in the given range, sequentially.
3+
# Stops at the first commit that fails.
4+
#
5+
# Usage:
6+
# run-ci-per-commit.sh <base_sha> <head_sha>
7+
#
8+
# Arguments:
9+
# base_sha - the base commit (exclusive)
10+
# head_sha - the head commit (inclusive)
11+
set -euo pipefail
12+
13+
base="${1:?Usage: run-ci-per-commit.sh <base_sha> <head_sha>}"
14+
head="${2:?Missing head_sha}"
15+
16+
commits=$(git rev-list --reverse "${base}..${head}")
17+
total=$(echo "$commits" | wc -l | tr -d ' ')
18+
current=0
19+
20+
for commit in $commits; do
21+
current=$((current + 1))
22+
short=$(git rev-parse --short "$commit")
23+
subject=$(git log -1 --format=%s "$commit")
24+
echo ""
25+
echo "=== [$current/$total] Testing ${short}: ${subject} ==="
26+
echo ""
27+
28+
git checkout --quiet "$commit"
29+
make install
30+
make lint
31+
make check-format
32+
make test
33+
34+
echo ""
35+
echo "=== [$current/$total] PASSED: ${short} ==="
36+
done
37+
38+
echo ""
39+
echo "All ${total} commit(s) passed CI checks."

.github/workflows/actions.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ jobs:
4646
- name: Install poetry
4747
run: pip install poetry==${{ matrix.poetry-version}}
4848
- name: Install deps
49-
run: poetry install
49+
run: make install
5050
- name: Run tests
51-
run: poetry run pytest tests
51+
run: make test
5252
- name: Check formatting
53-
run: poetry run ruff format --check leakix/ tests/ example/ executable/
53+
run: make check-format
5454
- name: Run linter
55-
run: poetry run ruff check leakix/ tests/ example/ executable/
55+
run: make lint
5656
- name: Security audit
57-
run: poetry run pip-audit
57+
run: make audit
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: CI per commit
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
types: [labeled]
8+
branches:
9+
- main
10+
11+
jobs:
12+
check-label:
13+
name: Check for ci:per-commit label
14+
runs-on: ubuntu-latest
15+
outputs:
16+
has_label: ${{ steps.check.outputs.has_label }}
17+
steps:
18+
- uses: actions/checkout@v6
19+
- name: Check for label
20+
id: check
21+
env:
22+
GH_TOKEN: ${{ github.token }}
23+
run: |
24+
.github/scripts/check-ci-per-commit-label.sh \
25+
"${{ github.event_name }}" \
26+
"${{ github.repository }}" \
27+
"${{ github.sha }}" \
28+
'${{ toJSON(github.event.pull_request.labels.*.name) }}' \
29+
>> "$GITHUB_OUTPUT"
30+
31+
ci-per-commit:
32+
name: CI per commit
33+
needs: check-label
34+
if: needs.check-label.outputs.has_label == 'true'
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v6
38+
with:
39+
fetch-depth: 0
40+
- uses: actions/setup-python@v6
41+
with:
42+
python-version: "3.13"
43+
- name: Install GNU sed (macOS)
44+
if: runner.os == 'macOS'
45+
run: brew install gnu-sed
46+
- name: Install poetry
47+
run: pip install poetry==2.3.1
48+
- name: Determine commit range
49+
id: range
50+
env:
51+
GH_TOKEN: ${{ github.token }}
52+
run: |
53+
if [ "${{ github.event_name }}" = "pull_request" ]; then
54+
BASE="${{ github.event.pull_request.base.sha }}"
55+
HEAD="${{ github.event.pull_request.head.sha }}"
56+
else
57+
BASE="${{ github.event.before }}"
58+
HEAD="${{ github.sha }}"
59+
fi
60+
echo "base=${BASE}" >> "$GITHUB_OUTPUT"
61+
echo "head=${HEAD}" >> "$GITHUB_OUTPUT"
62+
- name: Run CI on each commit
63+
run: |
64+
.github/scripts/run-ci-per-commit.sh \
65+
"${{ steps.range.outputs.base }}" \
66+
"${{ steps.range.outputs.head }}"

0 commit comments

Comments
 (0)