clang_tidy.yaml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. # Run in the clang-tidy config. This is done as part of tests so that we
  54. # aren't duplicating bazel/llvm setup.
  55. #
  56. # The `-k` flag is used to print all clang-tidy errors.
  57. - name: clang-tidy
  58. if: steps.test-setup.outputs.has_code == 'true'
  59. env:
  60. TARGETS_FILE: ${{ runner.temp }}/targets
  61. run: |
  62. ./scripts/run_bazel.py \
  63. --attempts=5 \
  64. build --config=clang-tidy -k \
  65. --target_pattern_file=$TARGETS_FILE
  66. # See "Disk space before build" in `test-setup`.
  67. - name: Disk space after build
  68. if: steps.test-setup.outputs.has_code == 'true'
  69. run: df -h