ci(prettier): run on pull_request and check only changed files
The push-only trigger skipped fork PRs entirely (e.g. #2378, which merged the unformatted nightly workflow with no format check run), and the whole-repo check made every open PR go red for files it never touched once one bad file landed on main. Trigger on pull_request so every PR is checked regardless of origin, and diff against the merge base so a PR is only ever red for its own files. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
983e0de1ef
commit
71a232a0f2
|
|
@ -1,17 +1,13 @@
|
||||||
name: Prettier
|
name: Prettier
|
||||||
|
|
||||||
# Check-only: reports formatting issues without modifying the branch.
|
# Check-only: reports formatting issues without modifying the branch.
|
||||||
# The job fails (and annotates unformatted files) when `prettier --check`
|
# Runs on pull_request (so fork PRs are checked too) and only checks the
|
||||||
# finds files that are not formatted, but it never writes, commits, or
|
# files the PR actually changed, so a PR can never go red for unformatted
|
||||||
# pushes anything back to the PR. Developers run `npx prettier@3 --write .`
|
# files it did not touch. Developers run `npx prettier@3 --write <files>`
|
||||||
# locally to fix the reported files.
|
# locally to fix the reported files.
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
pull_request:
|
||||||
branches-ignore:
|
|
||||||
- main
|
|
||||||
- "entire/**"
|
|
||||||
- "worktree-**"
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
format:
|
format:
|
||||||
|
|
@ -20,6 +16,12 @@ jobs:
|
||||||
contents: read
|
contents: read
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
# Full history so the merge-base with the PR base branch exists.
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Check formatting with Prettier
|
- name: Check formatting of changed files with Prettier
|
||||||
run: npx --yes prettier@3 --check .
|
run: |
|
||||||
|
git diff --name-only -z --diff-filter=d \
|
||||||
|
"origin/${{ github.base_ref }}...HEAD" \
|
||||||
|
| xargs -0 --no-run-if-empty npx --yes prettier@3 --check --ignore-unknown
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue