Skip to content

Commit a8514e0

Browse files
committed
Add include-what-you-use as GitHub action
This is to make sure that future pull requests do not introduce unnecessary includes (or remove ones that are no longer necessary).
1 parent 7ba2bd4 commit a8514e0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

.github/workflows/pull-request-checks.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,33 @@ jobs:
785785
- name: Smoke test goto-analyzer
786786
run: docker run -v ${PWD}/.github/workflows/smoke_test_assets:/mnt/smoke -t cbmc goto-analyzer /mnt/smoke/test.goto --unreachable-functions
787787

788+
include-what-you-use:
789+
runs-on: ubuntu-22.04
790+
steps:
791+
- uses: actions/checkout@v3
792+
with:
793+
submodules: recursive
794+
- name: Fetch dependencies
795+
env:
796+
# This is needed in addition to -yq to prevent apt-get from asking for
797+
# user input
798+
DEBIAN_FRONTEND: noninteractive
799+
run: |
800+
sudo apt-get update
801+
sudo apt-get install --no-install-recommends -yq cmake ninja-build gcc gdb g++ maven flex bison iwyu
802+
- name: Configure using CMake
803+
run: |
804+
mkdir build
805+
cd build
806+
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++
807+
- name: Run include-what-you-use
808+
run: |
809+
iwyu_tool -p build/compile_commands.json -j2 | tee includes.txt
810+
if sed '/minisat2-src/,/^--$/d' includes.txt | grep '^- ' -B1 ; then
811+
echo "Unnecessary includes found. Use '// IWYU pragma: keep' to override this."
812+
exit 1
813+
fi
814+
788815
codecov-coverage-report:
789816
runs-on: ubuntu-20.04
790817
steps:

0 commit comments

Comments
 (0)