Skip to content

Commit c22cea8

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 176a95e commit c22cea8

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
@@ -787,6 +787,33 @@ jobs:
787787
- name: Smoke test goto-analyzer
788788
run: docker run -v ${PWD}/.github/workflows/smoke_test_assets:/mnt/smoke -t cbmc goto-analyzer /mnt/smoke/test.goto --unreachable-functions
789789

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

0 commit comments

Comments
 (0)