Add GitHub action for IWYU #17
Workflow file for this run
This file contains 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 Analysis | |
on: [push, pull_request, workflow_dispatch] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup cmake | |
uses: jwlawson/actions-setup-cmake@v2 | |
with: | |
cmake-version: '3.22.x' | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
- name: Install iwyu | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y iwyu | |
- name: Register problem matcher | |
run: echo "::add-matcher::./.github/problem-matcher.json" | |
- name: Export CXXFLAGS | |
#Since Clang 17 is installed in usr/bin, it will search for built-ins in /usr/lib/clang/17/include. | |
#The purpose of this step is to help the clang toolchain used by IWYU to locate the correct system | |
#header directories. | |
run: | | |
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON executables/referenceApp | |
export CXXFLAGS="-isystem /usr/lib/llvm-17/lib/clang/17/include/" | |
echo "done exporting" | |
python3 iwyu_tool.py -p compile_commands.json 2>&1 > iwyu_output.txt | tee iwyu_output.txt | |
echo "Output in iwyu_output.txt" | |
- name: Print IWYU output | |
run: cat iwyu_output.txt | |
- name: Unregister problem matcher | |
if: always() | |
run: echo "::remove-matcher owner=iwyu-matcher::" | |
- name: Upload IWYU output | |
uses: actions/upload-artifact@v4 | |
with: | |
name: iwyu_output | |
path: iwyu_output.txt |