static_checks.yml 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. name: 📊 Static Checks
  2. on: [push, pull_request]
  3. concurrency:
  4. group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-static
  5. cancel-in-progress: true
  6. jobs:
  7. static-checks:
  8. name: Format (clang-format, ruff format, file format)
  9. runs-on: ubuntu-22.04
  10. steps:
  11. - name: Checkout
  12. uses: actions/checkout@v4
  13. with:
  14. fetch-depth: 2
  15. - name: Get changed files
  16. env:
  17. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  18. run: |
  19. if [ "${{ github.event_name }}" == "pull_request" ]; then
  20. files=$(git diff-tree --no-commit-id --name-only -r HEAD^1..HEAD 2> /dev/null || true)
  21. elif [ "${{ github.event_name }}" == "push" -a "${{ github.event.forced }}" == "false" -a "${{ github.event.created }}" == "false" ]; then
  22. files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }}..${{ github.event.after }} 2> /dev/null || true)
  23. fi
  24. files=$(echo "$files" | grep -v 'thirdparty' | xargs -I {} sh -c 'echo "\"./{}\""' | tr '\n' ' ')
  25. echo "CHANGED_FILES=$files" >> $GITHUB_ENV
  26. - name: Style checks via pre-commit
  27. uses: pre-commit/[email protected]
  28. with:
  29. extra_args: --verbose --hook-stage manual --files ${{ env.CHANGED_FILES }}