Skip to content

Commit

Permalink
Consolidate formatting check and fix script to one
Browse files Browse the repository at this point in the history
Summary:
To reduce discrepandcies of ruff format checking and fixing, we want to use the same script to do both

The script can be used in both CI and locally.

```
sh scripts/run_ruff.sh
sh scripts/run_ruff.sh --fix
sh scripts/run_ruff.sh --check
```

Test Plan:
1. fix
sh scripts/run_ruff.sh
sh scripts/run_ruff.sh --fix

All checks passed!
All checks passed!
All checks passed!
142 files left unchanged

2. check

sh scripts/run_ruff.sh --check
All checks passed!
All checks passed!
All checks passed!
142 files already formatted

3. unknown
sh scripts/run_ruff.sh --unknown

Usage: scripts/run_ruff.sh [options]
Options:
  --fix      Fix format (default)
  --check    Check for formatting issues
Reviewers:

Subscribers:

Tasks:

Tags:
  • Loading branch information
jerryzh168 committed Dec 19, 2024
1 parent 1beb6d0 commit 6ee5d8e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 17 deletions.
13 changes: 2 additions & 11 deletions .github/workflows/ruff_linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,7 @@ jobs:
- name: Regular lint check
if: github.event_name != 'workflow_dispatch'
run: |
ruff check .
# --isolated is used to skip the allowlist at all so this applies to all files
# please be careful when using this large changes means everyone needs to rebase
ruff check --isolated --select F821,F823,W191
ruff check --select F,I
ruff format --check || {
echo "Ruff check failed, please try again after running 'ruff format'."
exit 1
}
sh scripts/run_ruff.sh --check
- name: Apply fixes to PR
if: github.event_name == 'workflow_dispatch'
Expand All @@ -82,8 +74,7 @@ jobs:
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
# Apply fixes
ruff check --select F,I --fix
ruff format .
sh scripts/run_ruff.sh
# Commit and push if there are changes
if [[ -n "$(git status --porcelain)" ]]; then
Expand Down
6 changes: 0 additions & 6 deletions scripts/run_ruff_fix.sh

This file was deleted.

0 comments on commit 6ee5d8e

Please sign in to comment.