IWYU CI #57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: IWYU CI | |
| on: | |
| push: | |
| pull_request: | |
| schedule: | |
| # Run build of master at 03:38 every day | |
| - cron: '38 3 * * *' | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| build: | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| fail-fast: false | |
| env: | |
| LLVM_TAG: | |
| steps: | |
| - name: Install prerequisites | |
| run: | | |
| wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - | |
| sudo add-apt-repository "deb http://apt.llvm.org/noble/ llvm-toolchain-noble$LLVM_TAG main" | |
| sudo apt update | |
| # Remove any base dist LLVM/Clang installations | |
| sudo apt remove -y \ | |
| "libclang*" \ | |
| "clang*" \ | |
| "llvm*" | |
| # Reinstall tagged versions | |
| sudo apt install -y \ | |
| ninja-build \ | |
| llvm$LLVM_TAG-dev \ | |
| libclang$LLVM_TAG-dev \ | |
| clang$LLVM_TAG | |
| - name: Capture LLVM major version and install prefix | |
| run: | | |
| LLVM_MAJOR=$(ls -1d /usr/lib/llvm-* | sort -n | tail -n1 | sed 's/.*llvm-//') | |
| LLVM_PREFIX=$(llvm-config-$LLVM_MAJOR --prefix) | |
| echo "LLVM_MAJOR=${LLVM_MAJOR}" >> $GITHUB_ENV | |
| echo "LLVM_PREFIX=${LLVM_PREFIX}" >> $GITHUB_ENV | |
| - name: Check out branch | |
| uses: actions/checkout@v4 | |
| - name: Work around broken packaging | |
| run: | | |
| # Disable CMake target checks. | |
| # sudo ./iwyu-fixup-llvm-target-checks.bash "$LLVM_PREFIX" | |
| - name: Build include-what-you-use | |
| run: | | |
| mkdir build | |
| cd ./build | |
| cmake -G Ninja \ | |
| -DCMAKE_EXPORT_COMPILE_COMMANDS=on \ | |
| -DCMAKE_C_COMPILER=clang$LLVM_TAG \ | |
| -DCMAKE_CXX_COMPILER=clang++$LLVM_TAG \ | |
| -DCMAKE_INSTALL_PREFIX=./ \ | |
| -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=on \ | |
| ../ | |
| ninja | |
| - name: Test include-what-you-use | |
| run: | | |
| cd ./build | |
| CTEST_OUTPUT_ON_FAILURE=1 ctest -j 6 | |
| - name: Check if any known bugs were fixed | |
| run: | | |
| ./run_iwyu_tests.py --extra-suite=bugs bugs -- ./build/bin/include-what-you-use | |
| - name: Test install | |
| run: | | |
| cd ./build | |
| cmake --install . | |
| - name: Check license headers | |
| run: | | |
| git ls-tree --full-tree --name-only -r HEAD | \ | |
| xargs ./iwyu-check-license-header.py | |
| - name: IWYU dogfood | |
| run: | | |
| ./iwyu-dogfood.bash ./build | |
| # Write to step summary primarily for scheduled builds. | |
| cat ./iwyu-dogfood.md >> $GITHUB_STEP_SUMMARY | |
| # Hand over payloads for PR comments to separate workflow via artifact. | |
| - name: Prepare PR comment payload | |
| if: github.event_name == 'pull_request' | |
| env: | |
| PR_API_URL: ${{ github.event.pull_request.comments_url }} | |
| run: | | |
| mkdir ./pr-comments | |
| echo "$PR_API_URL" > ./pr-comments/api-url | |
| cp ./iwyu-dogfood.md ./pr-comments/ | |
| - name: Upload PR comment payload | |
| if: github.event_name == 'pull_request' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pr-comments | |
| path: ./pr-comments | |
| retention-days: 1 | |
| if-no-files-found: error |