|
| 1 | +name: format |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened, labeled, unlabeled] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + security-events: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + analyze: |
| 13 | + name: Check code formatting |
| 14 | + runs-on: ubuntu-latest |
| 15 | + if: ${{ !contains(github.event.pull_request.labels.*.name, 'ci-skip-format') }} |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Setup environment |
| 21 | + uses: ./.github/actions/setup-env |
| 22 | + |
| 23 | + - name: Run linters |
| 24 | + run: | |
| 25 | + echo "Running clang-format" |
| 26 | + buildscripts/clang_format.py format |
| 27 | + echo "Running python formatters" |
| 28 | + buildscripts/pylinters.py fix |
| 29 | + echo "Running python scons formatter" |
| 30 | + buildscripts/pylinters.py fix-scons |
| 31 | + echo "Running javascript formatters" |
| 32 | + buildscripts/eslint.py fix |
| 33 | +
|
| 34 | + - name: Verify formatting |
| 35 | + run: | |
| 36 | + if ! git diff --quiet; then |
| 37 | + echo "::error::Formatting issues detected." |
| 38 | + echo "" |
| 39 | + echo "Your PR is not properly formatted." |
| 40 | + echo "" |
| 41 | + echo "To fix the problem locally, run:" |
| 42 | + echo "" |
| 43 | + echo " buildscripts/clang_format.py format" |
| 44 | + echo " buildscripts/pylinters.py fix" |
| 45 | + echo " buildscripts/pylinters.py fix-scons" |
| 46 | + echo " buildscripts/eslint.py fix" |
| 47 | + echo "" |
| 48 | + echo "and commit the resulting changes." |
| 49 | + echo "" |
| 50 | + echo "Affected files:" |
| 51 | + git diff --stat |
| 52 | + echo "Diff:" |
| 53 | + git diff | head -n 1000 |
| 54 | + exit 1 |
| 55 | + fi |
0 commit comments