blob: 3751f35dee88253ad3fc709563906c6cec0c9e29 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# check for uneeded header includes of modified files
# False positives can be avoided with
# #include "some_include.h" // IWYU pragma: keep
name: IWYU Check
on:
pull_request:
branches: [ main ]
paths:
- '**.cpp'
- '**.hpp'
- '**.c'
- '**.h'
jobs:
iwyu-check:
name: Include What You Use Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Install IWYU
run: |
sudo apt-get update
sudo apt-get install -y iwyu
- name: Get changed files
id: changed-files
run: |
git fetch origin ${{ github.base_ref }}
base_commit=$(git merge-base FETCH_HEAD ${{ github.event.pull_request.head.sha }})
changed_files=$(git diff --name-only $base_commit HEAD | grep -E '\.(cpp|hpp|c|h)$' || true)
echo "files=$changed_files" >> $GITHUB_OUTPUT
- name: Run IWYU checks on changed files
if: steps.changed-files.outputs.files != ''
run: |
echo "${{ steps.changed-files.outputs.files }}" | while read -r file; do
if [ -f "$file" ]; then
echo "Checking $file..."
iwyu -Xiwyu --mapping_file=iwyu.imp "$file" 2>&1 || true
fi
done | tee iwyu_output.txt
if grep -q "should add these lines:" iwyu_output.txt || \
grep -q "should remove these lines:" iwyu_output.txt; then
echo "IWYU checks failed. Please fix the includes in the affected files."
exit 1
fi
|