Skip to content

Commit 3a49500

Browse files
committed
ci: split PR linting into separate workflow
- pr-title.yml runs on pull_request_target and checks the PR title - ci.yml::commitlint runs on push to main only and expects commits to be squashed - ci.yml::[lint,test] run on push + pull_request for all
1 parent 46e9493 commit 3a49500

2 files changed

Lines changed: 39 additions & 26 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,30 @@ on:
88

99
permissions:
1010
contents: read
11-
pull-requests: read
1211

1312
jobs:
14-
# For PRs, validate the PR title (which becomes the squash commit message).
15-
# This avoids burdening external contributors with conventional commit enforcement
16-
# on every individual commit. See: https://www.conventionalcommits.org/en/v1.0.0/
17-
#
18-
# For pushes to main, validate the final commit message (the squash merge commit)
19-
# using commitizen as a safety net.
13+
# Validate the squash merge commit message on pushes to main.
14+
# PR title validation is handled separately in pr-title.yml.
2015
commitlint:
16+
if: github.event_name == 'push'
2117
runs-on: ubuntu-latest
2218
steps:
23-
# PR: validate PR title follows conventional commit format
24-
- name: Validate PR title
25-
if: github.event_name == 'pull_request'
26-
uses: amannn/action-semantic-pull-request@v5
27-
env:
28-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29-
with:
30-
# For work-in-progress PRs you can typically use draft pull requests from GitHub.
31-
# This action allows us to use the special "[WIP]" prefix to indicate a draft state
32-
# without actually flagging the PR as a draft.
33-
# Example:
34-
# `[WIP] feat: Add support for Node.js 18` <--- will not be validated!
35-
wip: true
36-
37-
# Push to main: validate the squash merge commit message directly
3819
- name: Checkout
39-
if: github.event_name == 'push'
4020
uses: actions/checkout@v6
4121
with:
4222
fetch-depth: 2
4323

4424
- name: Install uv
45-
if: github.event_name == 'push'
4625
uses: astral-sh/setup-uv@v7
4726
with:
4827
version: "latest"
4928

5029
- name: Install Python and dependencies
51-
if: github.event_name == 'push'
5230
run: |
5331
uv python install 3.11
5432
uv sync --all-extras
5533
5634
- name: Validate commit message
57-
if: github.event_name == 'push'
5835
run: uv run cz check --rev-range HEAD~1..HEAD
5936

6037
lint:

.github/workflows/pr-title.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: PR Title
2+
3+
# Validate that PR titles follow Conventional Commits format.
4+
# Since we squash merge PRs, the PR title becomes the merge commit message,
5+
# which Python Semantic Release uses to determine version bumps.
6+
#
7+
# This avoids burdening external contributors with conventional commit enforcement
8+
# on every individual commit. See: https://www.conventionalcommits.org/en/v1.0.0/
9+
#
10+
# NOTE: pull_request_target is used instead of pull_request because it runs in the
11+
# context of the base branch and has reliable access to the GITHUB_TOKEN for reading
12+
# PR metadata.
13+
14+
on:
15+
pull_request_target:
16+
types: [opened, edited, synchronize, reopened]
17+
branches: [main]
18+
19+
permissions:
20+
pull-requests: read
21+
22+
jobs:
23+
validate:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Validate PR title
27+
uses: amannn/action-semantic-pull-request@v5
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
with:
31+
# For work-in-progress PRs you can typically use draft pull requests from GitHub.
32+
# This action allows us to use the special "[WIP]" prefix to indicate a draft state
33+
# without actually flagging the PR as a draft.
34+
# Example:
35+
# `[WIP] feat: Add support for Node.js 18` <--- will not be validated!
36+
wip: true

0 commit comments

Comments
 (0)