|
| 1 | +name: Post-Commit Static Analyzer |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - 'release/**' |
| 10 | + paths: |
| 11 | + - 'clang/**' |
| 12 | + - 'llvm/**' |
| 13 | + - '.github/workflows/ci-post-commit-analyzer.yml' |
| 14 | + pull_request: |
| 15 | + types: |
| 16 | + - opened |
| 17 | + - synchronize |
| 18 | + - reopened |
| 19 | + - closed |
| 20 | + paths: |
| 21 | + - '.github/workflows/ci-post-commit-analyzer.yml' |
| 22 | + - '.github/workflows/ci-post-commit-analyzer-run.py' |
| 23 | + schedule: |
| 24 | + - cron: '30 0 * * *' |
| 25 | + |
| 26 | +concurrency: |
| 27 | + group: >- |
| 28 | + llvm-project-${{ github.workflow }}-${{ github.event_name == 'pull_request' && |
| 29 | + ( github.event.pull_request.number || github.ref) }} |
| 30 | + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} |
| 31 | + |
| 32 | +jobs: |
| 33 | + post-commit-analyzer: |
| 34 | + if: >- |
| 35 | + github.repository_owner == 'llvm' && |
| 36 | + github.event.action != 'closed' |
| 37 | + runs-on: ubuntu-22.04 |
| 38 | + container: |
| 39 | + image: 'ghcr.io/llvm/ci-ubuntu-22.04:latest' |
| 40 | + env: |
| 41 | + LLVM_VERSION: 18 |
| 42 | + steps: |
| 43 | + - name: Checkout Source |
| 44 | + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 |
| 45 | + |
| 46 | + - name: Setup ccache |
| 47 | + uses: hendrikmuhs/ccache-action@v1 |
| 48 | + with: |
| 49 | + # A full build of llvm, clang, lld, and lldb takes about 250MB |
| 50 | + # of ccache space. There's not much reason to have more than this, |
| 51 | + # because we usually won't need to save cache entries from older |
| 52 | + # builds. Also, there is an overall 10GB cache limit, and each |
| 53 | + # run creates a new cache entry so we want to ensure that we have |
| 54 | + # enough cache space for all the tests to run at once and still |
| 55 | + # fit under the 10 GB limit. |
| 56 | + # Default to 2G to workaround: https://github.com/hendrikmuhs/ccache-action/issues/174 |
| 57 | + max-size: 2G |
| 58 | + key: post-commit-analyzer |
| 59 | + variant: sccache |
| 60 | + |
| 61 | + - name: Configure |
| 62 | + run: | |
| 63 | + cmake -B build -S llvm -G Ninja \ |
| 64 | + -DLLVM_ENABLE_ASSERTIONS=ON \ |
| 65 | + -DLLVM_ENABLE_PROJECTS=clang \ |
| 66 | + -DLLVM_BUILD_LLVM_DYLIB=ON \ |
| 67 | + -DLLVM_LINK_LLVM_DYLIB=ON \ |
| 68 | + -DCMAKE_CXX_COMPILER=clang++ \ |
| 69 | + -DCMAKE_C_COMPILER=clang \ |
| 70 | + -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \ |
| 71 | + -DCMAKE_C_COMPILER_LAUNCHER=sccache \ |
| 72 | + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ |
| 73 | + -DLLVM_INCLUDE_TESTS=OFF \ |
| 74 | + -DCLANG_INCLUDE_TESTS=OFF \ |
| 75 | + -DCMAKE_BUILD_TYPE=Release |
| 76 | +
|
| 77 | + - name: Build |
| 78 | + run: | |
| 79 | + # FIXME: We need to build all the generated header files in order to be able to run |
| 80 | + # the analyzer on every file. Building libLLVM and libclang is probably overkill for |
| 81 | + # this, but it's better than building every target. |
| 82 | + ninja -v -C build libLLVM.so libclang.so |
| 83 | +
|
| 84 | + # Run the analyzer. |
| 85 | + python3 .github/workflows/ci-post-commit-analyzer-run.py build/compile_commands.json |
| 86 | +
|
| 87 | + scan-build --generate-index-only build/analyzer-results |
| 88 | +
|
| 89 | + - name: Upload Results |
| 90 | + uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0 |
| 91 | + if: always() |
| 92 | + with: |
| 93 | + name: analyzer-results |
| 94 | + path: 'build/analyzer-results/*' |
| 95 | + |
0 commit comments