clang.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. name: Clang
  2. on:
  3. push:
  4. branches: ["master"]
  5. tags: ["4.*"]
  6. pull_request:
  7. branches: ["master"]
  8. concurrency:
  9. group: ${{ github.workflow }}-${{ github.ref }}
  10. cancel-in-progress: true
  11. jobs:
  12. format:
  13. runs-on: ubuntu-latest
  14. steps:
  15. - uses: actions/checkout@v6
  16. - name: Install dependencies
  17. uses: ./.github/workflows/actions/ubuntu-build-deps
  18. with:
  19. SUDO: true
  20. - name: Install `clang-format-15`
  21. run: sudo apt install -y clang-format-15
  22. - name: Prepare `clang-format`
  23. run: |
  24. set -e
  25. if which clang-format-15 2>&1 >/dev/null
  26. then
  27. sudo cp $(which clang-format-15) $(which clang-format)
  28. fi
  29. clang-format --version
  30. - run: ./configure
  31. - run: make lint
  32. sanitize:
  33. runs-on: ubuntu-latest
  34. strategy:
  35. matrix:
  36. sanitizer:
  37. - address,pointer-compare,pointer-subtract
  38. - thread
  39. env:
  40. CFLAGS: -fno-omit-frame-pointer -fstack-protector-all -fsanitize=${{ matrix.sanitizer }},bounds,enum -fsanitize-address-use-after-scope -fsanitize-address-use-after-return=always -fsanitize-recover=address -fsanitize-memory-track-origins=2
  41. CC: clang
  42. ASAN_OPTIONS: strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:detect_leaks=0:detect_invalid_pointer_pairs=1:halt_on_error=0
  43. steps:
  44. - uses: actions/checkout@v6
  45. - name: Install dependencies
  46. uses: ./.github/workflows/actions/ubuntu-build-deps
  47. with:
  48. SUDO: true
  49. - run: ./configure
  50. - run: make -j $(nproc)
  51. - run: make check
  52. - run: ./run_tests.sh
  53. working-directory: examples/
  54. - run: ./run_tests_conf.sh
  55. working-directory: examples/
  56. - run: ./run_tests_prom.sh
  57. working-directory: examples/
  58. tidy:
  59. runs-on: ubuntu-latest
  60. strategy:
  61. matrix:
  62. config: ["Release"]
  63. steps:
  64. - uses: actions/checkout@v6
  65. - name: Install dependencies
  66. uses: ./.github/workflows/actions/ubuntu-build-deps
  67. with:
  68. SUDO: true
  69. - name: Configure
  70. run: cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }}
  71. -DCMAKE_EXPORT_COMPILE_COMMANDS=true
  72. - name: Compile
  73. run: cmake --build build --parallel --config ${{ matrix.config }}
  74. # Implicitly requires `build/compile_commands.json` to exist
  75. - name: Run `clang-tidy`
  76. run: |
  77. set -e
  78. wget https://raw.githubusercontent.com/llvm/llvm-project/llvmorg-14.0.6/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
  79. chmod +x run-clang-tidy.py
  80. ./run-clang-tidy.py -j $(nproc) -p build
  81. # Implicitly requires `build/compile_commands.json` to exist
  82. - name: Run IWYU
  83. run: |
  84. set -e
  85. wget https://raw.githubusercontent.com/include-what-you-use/include-what-you-use/clang_14/iwyu_tool.py
  86. chmod +x iwyu_tool.py
  87. # iwyu_tool.py returns non-zero if any executions returned nonzero. Which... happens to be useless unless the project is already IWYU clean.
  88. ./iwyu_tool.py -j $(nproc) -p build -- -Xiwyu --mapping_file=${GITHUB_WORKSPACE}/iwyu-ubuntu.imp | grep -v "has correct" | uniq || exit 0