Skip to content

Commit

Permalink
Add GitHub action for IWYU
Browse files Browse the repository at this point in the history
  • Loading branch information
SuhashiniNaik committed Dec 19, 2024
1 parent ec25295 commit 65bbe3c
Show file tree
Hide file tree
Showing 4 changed files with 614 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .github/problem-matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"problemMatcher": [
{
"owner": "iwyu-matcher",
"pattern": [
{
"regexp": "^(.*):(\\d+):(\\d+):\\s*(.*)$",
"file": 1,
"line": 2,
"column": 3,
"message": 4
}
]
}
]
}
5 changes: 4 additions & 1 deletion .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ jobs:
ctest --test-dir cmake-build-unit-tests -j4
- name: Install lcov
run: sudo apt install lcov
run: |
sudo apt-get update
sudo apt-get install -y lcov
# no-external command excludes the system libraries in the root directory
- name: Capture code coverage
run: |
echo "Capturing code coverage..."
lcov --no-external --capture --directory . \
--output-file cmake-build-unit-tests/coverage_unfiltered.info
geninfo --ignore-errors mismatch
- name: Filter out 3rd party and mock files
run: |
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/iwyu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
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
Loading

0 comments on commit 65bbe3c

Please sign in to comment.