mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-08-04 06:52:47 +00:00
🎨 ci: Check Prettier Formatting Drift on Package Changes (#13282)
Some checks are pending
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Waiting to run
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Waiting to run
GitNexus Index / index (push) Waiting to run
GitNexus Index / post-index (push) Blocked by required conditions
Some checks are pending
Docker Dev Branch Images Build / build (Dockerfile, lc-dev, node) (push) Waiting to run
Docker Dev Branch Images Build / build (Dockerfile.multi, lc-dev-api, api-build) (push) Waiting to run
GitNexus Index / index (push) Waiting to run
GitNexus Index / post-index (push) Blocked by required conditions
Adds a `Run Prettier --check on changed files` step to the existing `eslint-ci.yml` workflow. Same path filter (api/**, client/**, packages/**), same changed-files detection, runs after the ESLint step. ## Why Today there is no `prettier --check` in CI — only the local `lint-staged` pre-commit hook runs `prettier --write`. When a PR is merged with the hook bypassed (e.g. GitHub UI edit-and-merge, or `git commit --no-verify`), a file can land in a non-prettier-canonical state and nobody notices. The next contributor who stages an unrelated change in that file then ends up with a "drive-by" prettier diff in their PR. `packages/api/src` had 14 such files accumulated; #13281 fixes the existing drift. This PR closes the gap so it doesn't regrow. ## What the step does - Detects changed JS/TS files under `api/**`, `client/**`, or `packages/**` against the PR base. - Runs `npx prettier --check $CHANGED_FILES`. - On failure, prints a `::error::` annotation telling the contributor how to fix it locally (`npx prettier --write <files>`). Same one-step shape as the existing ESLint check — no extra workflow file, no extra `npm ci`, no extra checkout. ## Ordering note #13281 (`chore: prettier --write packages/api/src`) should land first so the existing drift is cleared. After both PRs merge, the pre-commit hook + this CI check together prevent drift from re-accumulating. ## Test plan - [x] `npx js-yaml .github/workflows/eslint-ci.yml` validates. - [ ] CI green on this PR itself (touches only `.github/workflows/`, which the path filter includes, so the workflow runs on itself). - [ ] After merge: a synthetic PR introducing prettier drift should fail the new step with the diagnostic message.
This commit is contained in:
parent
83c7d637c3
commit
9799f7e698
1 changed files with 27 additions and 0 deletions
27
.github/workflows/eslint-ci.yml
vendored
27
.github/workflows/eslint-ci.yml
vendored
|
|
@ -61,3 +61,30 @@ jobs:
|
|||
--config eslint.config.mjs \
|
||||
--max-warnings=0 \
|
||||
$CHANGED_FILES
|
||||
|
||||
# Run Prettier --check on the same set of changed files to catch
|
||||
# formatting drift in PRs that bypassed the local pre-commit hook
|
||||
# (e.g. GitHub UI edit-and-merge, `git commit --no-verify`).
|
||||
- name: Run Prettier --check on changed files
|
||||
run: |
|
||||
BASE_SHA=$(jq --raw-output .pull_request.base.sha "$GITHUB_EVENT_PATH")
|
||||
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB "$BASE_SHA" HEAD | grep -E '^(api|client|packages)/.*\.(js|jsx|ts|tsx)$' || true)
|
||||
|
||||
if [[ -z "$CHANGED_FILES" ]]; then
|
||||
echo "No matching files changed. Skipping Prettier."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Files to check:"
|
||||
echo "$CHANGED_FILES"
|
||||
|
||||
# `prettier --check` exits non-zero if any file would be reformatted.
|
||||
# Suggest the local fix in the failure message so contributors aren't
|
||||
# left guessing how to resolve.
|
||||
if ! npx prettier --check --no-error-on-unmatched-pattern $CHANGED_FILES; then
|
||||
echo ""
|
||||
echo "::error::Prettier formatting drift detected. Fix locally with:"
|
||||
echo "::error:: npx prettier --write <files>"
|
||||
echo "::error::Or rely on the lint-staged pre-commit hook (do not bypass with --no-verify)."
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue