PSMDB-1884: fix clang-tidy workflow #37
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 | |
| security-events: write | |
| 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 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup environment | |
| uses: ./.github/actions/setup-env | |
| - name: Run bazel format | |
| run: | | |
| # The --include_autogenerated_targets=True is needed to create the autogenerated targets. | |
| # Without it, bazel wrapper hook scripts append some additional args that break the formatting check. | |
| bazel run format --include_autogenerated_targets=True -- --origin-branch=origin/${{ github.base_ref }} | |
| - 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 " bazel run format" | |
| echo "" | |
| echo "and commit the resulting changes." | |
| echo "" | |
| echo "Affected files:" | |
| git diff --stat | |
| echo "Diff:" | |
| git diff | head -n 1000 | |
| exit 1 | |
| fi |