aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernd Schubert <bernd@bsbernd.com>2025-01-29 10:46:18 +0100
committerBernd Schubert <bernd@bsbernd.com>2025-02-10 16:56:45 +0100
commit1d373c61aef0bf514f7259710812410ccae2fe74 (patch)
tree817f6fa4982dbbb1649ac4613432d36f3bc6b873
parentd953462c77b569763dc68f6486a898b1a6658b9d (diff)
downloadlibfuse-1d373c61aef0bf514f7259710812410ccae2fe74.tar.gz
github actions: Add an include-what-you-need check
Probably lots of issues right now, so let's fix it step by step by only checking modified files - new PRs should fix their modified files. Signed-off-by: Bernd Schubert <bernd@bsbernd.com>
-rw-r--r--.github/workflows/iwyi-check.yml51
1 files changed, 51 insertions, 0 deletions
diff --git a/.github/workflows/iwyi-check.yml b/.github/workflows/iwyi-check.yml
new file mode 100644
index 0000000..3751f35
--- /dev/null
+++ b/.github/workflows/iwyi-check.yml
@@ -0,0 +1,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