clang_tidy.yaml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. name: 'Clang Tidy'
  5. on:
  6. push:
  7. branches: [trunk, action-test]
  8. pull_request:
  9. merge_group:
  10. permissions:
  11. contents: read # For actions/checkout.
  12. pull-requests: read # For dorny/paths-filter to read pull requests.
  13. # Cancel previous workflows on the PR when there are multiple fast commits.
  14. # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
  15. concurrency:
  16. group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
  17. cancel-in-progress: true
  18. jobs:
  19. clang-tidy:
  20. runs-on: ubuntu-22.04
  21. steps:
  22. - name: Harden Runner
  23. uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
  24. with:
  25. egress-policy: block
  26. # When adding endpoints, see README.md.
  27. # prettier-ignore
  28. allowed-endpoints: >
  29. *.dl.sourceforge.net:443
  30. api.github.com:443
  31. bcr.bazel.build:443
  32. downloads.sourceforge.net:443
  33. github.com:443
  34. mirrors.kernel.org:443
  35. nodejs.org:443
  36. oauth2.googleapis.com:443
  37. objects.githubusercontent.com:443
  38. pypi.org:443
  39. releases.bazel.build:443
  40. sourceforge.net:443
  41. storage.googleapis.com:443
  42. - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  43. - id: test-setup
  44. uses: ./.github/actions/test-setup
  45. with:
  46. matrix_runner: 'ubuntu-22.04'
  47. base_sha:
  48. ${{ github.event_name == 'pull_request' &&
  49. github.event.pull_request.base.sha ||
  50. github.event.merge_group.base_sha }}
  51. remote_cache_key: ${{ secrets.CARBON_BUILDS_GITHUB }}
  52. targets_file: ${{ runner.temp }}/targets
  53. use_direct_targets: true
  54. # Run in the clang-tidy config. This is done as part of tests so that we
  55. # aren't duplicating bazel/llvm setup.
  56. #
  57. # The `-k` flag is used to print all clang-tidy errors.
  58. - name: clang-tidy
  59. if: steps.test-setup.outputs.has_code == 'true'
  60. env:
  61. TARGETS_FILE: ${{ runner.temp }}/targets
  62. run: |
  63. ./scripts/run_bazel.py \
  64. --attempts=5 \
  65. build --config=clang-tidy -k \
  66. --target_pattern_file=$TARGETS_FILE
  67. # See "Disk space before build" in `test-setup`.
  68. - name: Disk space after build
  69. if: steps.test-setup.outputs.has_code == 'true'
  70. run: df -h