clangd_tidy.yaml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. 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. clangd-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: filter
  44. uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
  45. with:
  46. filters: |
  47. has_cpp:
  48. - added|modified: '{**/*.cpp,**/*.h}'
  49. list-files: 'shell'
  50. - uses: ./.github/actions/build-setup-common
  51. if: steps.filter.outputs.has_cpp == 'true'
  52. with:
  53. matrix_runner: 'ubuntu-22.04'
  54. remote_cache_upload: '--remote_upload_local_results=false'
  55. - name: Create compile commands
  56. if: steps.filter.outputs.has_cpp == 'true'
  57. run: ./scripts/create_compdb.py
  58. - name: Build deps for clangd-tidy
  59. if: steps.filter.outputs.has_cpp == 'true'
  60. run: ./scripts/run_bazel.py build //scripts:deps_for_clangd_tidy
  61. - name: Install clangd-tidy
  62. if: steps.filter.outputs.has_cpp == 'true'
  63. run: pip install clangd-tidy==1.1.0.post2
  64. - name: Run clangd-tidy
  65. if: steps.filter.outputs.has_cpp == 'true'
  66. env:
  67. FILTER_FILES: ${{ steps.filter.outputs.has_cpp_files }}
  68. run: |
  69. clangd-tidy -p . -j 10 $FILTER_FILES