PSMDB-1786: add github workflow for format check (v7.0) #22
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: format | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened, labeled, unlabeled] | |
| permissions: | |
| contents: read | |
| jobs: | |
| analyze: | |
| name: Check code formatting | |
| runs-on: ubuntu-latest | |
| if: ${{ !contains(github.event.pull_request.labels.*.name, 'ci-skip-format') }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup environment | |
| uses: ./.github/actions/setup-env | |
| - name: Run linters | |
| run: | | |
| echo "Running clang-format" | |
| buildscripts/clang_format.py format | |
| echo "Running python formatters" | |
| buildscripts/pylinters.py fix | |
| echo "Running python scons formatter" | |
| buildscripts/pylinters.py fix-scons | |
| echo "Running javascript formatters" | |
| buildscripts/eslint.py fix | |
| - name: Verify formatting | |
| run: | | |
| if ! git diff --quiet; then | |
| echo "::error::Formatting issues detected." | |
| echo "" | |
| echo "Your PR is not properly formatted." | |
| echo "" | |
| echo "To fix the problem locally, run:" | |
| echo "" | |
| echo " buildscripts/clang_format.py format" | |
| echo " buildscripts/pylinters.py fix" | |
| echo " buildscripts/pylinters.py fix-scons" | |
| echo " buildscripts/eslint.py fix" | |
| echo "" | |
| echo "and commit the resulting changes." | |
| echo "" | |
| echo "Affected files:" | |
| git diff --stat | |
| echo "Diff:" | |
| git diff | head -n 1000 | |
| exit 1 | |
| fi |