clangd_tidy.yaml 2.5 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 (clangd)'
  5. on:
  6. push:
  7. branches: [trunk, action-test]
  8. pull_request:
  9. # TODO: Don't run in merge_group until we're ready to replace clang-tidy.
  10. # merge_group:
  11. permissions:
  12. contents: read # For actions/checkout.
  13. pull-requests: read # For dorny/paths-filter to read pull requests.
  14. # Cancel previous workflows on the PR when there are multiple fast commits.
  15. # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
  16. concurrency:
  17. group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
  18. cancel-in-progress: true
  19. jobs:
  20. clangd-tidy:
  21. runs-on: ubuntu-22.04
  22. steps:
  23. - name: Harden Runner
  24. uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
  25. with:
  26. egress-policy: block
  27. # When adding endpoints, see README.md.
  28. # prettier-ignore
  29. allowed-endpoints: >
  30. *.dl.sourceforge.net:443
  31. api.github.com:443
  32. bcr.bazel.build:443
  33. downloads.sourceforge.net:443
  34. github.com:443
  35. mirrors.kernel.org:443
  36. nodejs.org:443
  37. oauth2.googleapis.com:443
  38. objects.githubusercontent.com:443
  39. pypi.org:443
  40. releases.bazel.build:443
  41. sourceforge.net:443
  42. storage.googleapis.com:443
  43. - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
  44. - id: filter
  45. uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
  46. with:
  47. filters: |
  48. has_cpp:
  49. - added|modified: '{**/*.cpp,**/*.h}'
  50. list-files: 'shell'
  51. - uses: ./.github/actions/build-setup-common
  52. if: steps.filter.outputs.has_cpp == 'true'
  53. with:
  54. matrix_runner: 'ubuntu-22.04'
  55. remote_cache_upload: '--remote_upload_local_results=false'
  56. - name: Create compile commands
  57. if: steps.filter.outputs.has_cpp == 'true'
  58. run: ./scripts/create_compdb.py
  59. - name: Install clangd-tidy
  60. if: steps.filter.outputs.has_cpp == 'true'
  61. run: pip install clangd-tidy==1.1.0.post2
  62. - name: Run clangd-tidy
  63. if: steps.filter.outputs.has_cpp == 'true'
  64. env:
  65. FILTER_FILES: ${{ steps.filter.outputs.has_cpp_files }}
  66. run: |
  67. clangd-tidy -p . -j 10 $FILTER_FILES