Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[workflows] Add post-commit job that periodically runs the clang static analyzer #94106

Merged
merged 14 commits into from
Jun 8, 2024
Merged
4 changes: 4 additions & 0 deletions .github/workflows/ci-post-commit-analyzer-launcher.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
ccache "$@"
"$@" --analyze --analyzer-output html -o analyzer-results \
-Xclang -analyzer-config -Xclang max-nodes=75000
94 changes: 94 additions & 0 deletions .github/workflows/ci-post-commit-analyzer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Post-Commit Static Analyzer

permissions:
contents: read

on:
push:
branches:
- 'release/**'
paths:
- 'llvm/**'
haoNoQ marked this conversation as resolved.
Show resolved Hide resolved
- '.github/workflows/ci-post-commit-analyzer.yml'
pull_request:
types:
- opened
- synchronize
- reopened
- closed
paths:
- '.github/workflows/ci-post-commit-analyzer.yml'
schedule:
- cron: '30 0 * * *'

concurrency:
group: >-
llvm-project-${{ github.workflow }}-${{ github.event_name == 'pull_request' &&
( github.event.pull_request.number || github.ref) }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
post-commit-analyzer:
if: >-
github.repository_owner == 'llvm' &&
github.event.action != 'closed'
runs-on: ubuntu-22.04
container:
image: 'ghcr.io/llvm/ci-ubuntu-22.04:latest'
env:
LLVM_VERSION: 18
steps:
- name: Checkout Source
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Install Dependencies
env:
DEBIAN_FRONTEND: noninteractive
run: |
apt-get update
apt-get -y install \
cmake \
boomanaiden154 marked this conversation as resolved.
Show resolved Hide resolved
ninja-build \
perl \
clang-tools
boomanaiden154 marked this conversation as resolved.
Show resolved Hide resolved

- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1
with:
# A full build of llvm, clang, lld, and lldb takes about 250MB
# of ccache space. There's not much reason to have more than this,
# because we usually won't need to save cache entries from older
# builds. Also, there is an overall 10GB cache limit, and each
# run creates a new cache entry so we want to ensure that we have
# enough cache space for all the tests to run at once and still
# fit under the 10 GB limit.
# Default to 2G to workaround: https://github.com/hendrikmuhs/ccache-action/issues/174
max-size: 2G
key: post-commit-analyzer
variant: ccache

- name: Configure
run: |
cmake -B build -S llvm -G Ninja \
haoNoQ marked this conversation as resolved.
Show resolved Hide resolved
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_PROJECTS=clang \
-DLLVM_BUILD_LLVM_DYLIB=ON \
-DLLVM_LINK_LLVM_DYLIB=ON \
boomanaiden154 marked this conversation as resolved.
Show resolved Hide resolved
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER_LAUNCHER=`pwd`/.github/workflows/ci-post-commit-analyzer-launcher.sh \
-DCMAKE_C_COMPILER_LAUNCHER=`pwd`/.github/workflows/ci-post-commit-analyzer-launcher.sh \
-DCMAKE_BUILD_TYPE=Release

- name: Build
run: |
ninja -v -C build
scan-build --generate-index-only build/analyzer-results

- name: Upload Results
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
if: always()
with:
name: analyzer-results
path: 'build/analyzer-results/**/*'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure but I suspect that you should remove the /** part now. Because now that you removed scan-build nobody is creating that subdirectory with today's date anymore. All the HTML files go straight into analyzer-results now.


Loading