From 71a232a0f2ec5acf1e32deb3cd43a51089056828 Mon Sep 17 00:00:00 2001 From: Harshit Singh Bhandari Date: Sat, 4 Jul 2026 04:30:06 +0530 Subject: [PATCH] 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 --- .github/workflows/prettier.yml | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 5dbea5388..1ffb2954d 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -1,17 +1,13 @@ name: Prettier # Check-only: reports formatting issues without modifying the branch. -# The job fails (and annotates unformatted files) when `prettier --check` -# finds files that are not formatted, but it never writes, commits, or -# pushes anything back to the PR. Developers run `npx prettier@3 --write .` +# Runs on pull_request (so fork PRs are checked too) and only checks the +# files the PR actually changed, so a PR can never go red for unformatted +# files it did not touch. Developers run `npx prettier@3 --write ` # locally to fix the reported files. on: - push: - branches-ignore: - - main - - "entire/**" - - "worktree-**" + pull_request: jobs: format: @@ -20,6 +16,12 @@ jobs: contents: read steps: - 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 - run: npx --yes prettier@3 --check . + - name: Check formatting of changed files with Prettier + 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