Skip to content

Commit 02d2b5a

Browse files
committed
ci, iwyu: Treat warnings as errors for specific directories
Currently, this applies only to the `crypto` and `index` directories.
1 parent 57a3eac commit 02d2b5a

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

ci/test/03_test_script.sh

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,30 @@ if [ "${RUN_TIDY}" = "true" ]; then
213213
false
214214
fi
215215

216+
# TODO: Consider enforcing IWYU across the entire codebase.
217+
FILES_WITH_ENFORCED_IWYU="/src/(crypto|index)/.*\\.cpp"
218+
jq --arg patterns "$FILES_WITH_ENFORCED_IWYU" 'map(select(.file | test($patterns)))' "${BASE_BUILD_DIR}/compile_commands.json" > "${BASE_BUILD_DIR}/compile_commands_iwyu_errors.json"
219+
jq --arg patterns "$FILES_WITH_ENFORCED_IWYU" 'map(select(.file | test($patterns) | not))' "${BASE_BUILD_DIR}/compile_commands.json" > "${BASE_BUILD_DIR}/compile_commands_iwyu_warnings.json"
220+
216221
cd "${BASE_ROOT_DIR}"
217-
python3 "/include-what-you-use/iwyu_tool.py" \
218-
-p "${BASE_BUILD_DIR}" "${MAKEJOBS}" \
219-
-- -Xiwyu --cxx17ns -Xiwyu --mapping_file="${BASE_ROOT_DIR}/contrib/devtools/iwyu/bitcoin.core.imp" \
220-
-Xiwyu --max_line_length=160 \
221-
2>&1 | tee /tmp/iwyu_ci.out
222-
cd "${BASE_ROOT_DIR}/src"
223-
python3 "/include-what-you-use/fix_includes.py" --nosafe_headers < /tmp/iwyu_ci.out
222+
223+
run_iwyu() {
224+
mv "${BASE_BUILD_DIR}/$1" "${BASE_BUILD_DIR}/compile_commands.json"
225+
python3 "/include-what-you-use/iwyu_tool.py" \
226+
-p "${BASE_BUILD_DIR}" "${MAKEJOBS}" \
227+
-- -Xiwyu --cxx17ns -Xiwyu --mapping_file="${BASE_ROOT_DIR}/contrib/devtools/iwyu/bitcoin.core.imp" \
228+
-Xiwyu --max_line_length=160 \
229+
2>&1 | tee /tmp/iwyu_ci.out
230+
python3 "/include-what-you-use/fix_includes.py" --nosafe_headers < /tmp/iwyu_ci.out
231+
}
232+
233+
run_iwyu "compile_commands_iwyu_errors.json"
234+
if ! ( git --no-pager diff --exit-code ); then
235+
echo "^^^ ⚠️ Failure generated from IWYU"
236+
false
237+
fi
238+
239+
run_iwyu "compile_commands_iwyu_warnings.json"
224240
git --no-pager diff
225241
fi
226242

0 commit comments

Comments
 (0)