Merge bitcoin/bitcoin#33810: ci: Add IWYU job
56750c4f87iwyu, clang-format: Sort includes (Hennadii Stepanov)2c78814e0eci: Add IWYU job (Hennadii Stepanov)94e4f04d7ccmake: Fix target name (Hennadii Stepanov)0f81e00519cmake: Make `codegen` target dependent on `generate_build_info` (Hennadii Stepanov)73f7844cdbiwyu: Add patch to prefer C++ headers over C counterparts (Hennadii Stepanov)7a65437e23iwyu: Add patch to prefer angled brackets over quotes for includes (Hennadii Stepanov) Pull request description: This PR separates the IWYU checks into its own CI job to provide faster feedback to developers. No other changes are made to the treatment of IWYU warnings. The existing “tidy” CI job will no longer run IWYU. See also the discussion of https://github.com/bitcoin/bitcoin/pull/33779, specifically this [comment](https://github.com/bitcoin/bitcoin/pull/33779#issuecomment-3491515263): > Maybe a better approach would be to run the enforced sections in a separate, faster job? Some of the linters are already a bit annoying to invoke locally, so I usually just run the lint job. Doing the same for the includes seems fine to me. Based on ideas from https://github.com/bitcoin/bitcoin/pull/32953. ACKs for top commit: maflcko: review ACK56750c4f87🌄 sedited: ACK56750c4f87Tree-SHA512: af15326b6d0c5d1e11346ac64939644936c65eb9466cd1a17ab5da347d39aef10f7ab33b39fbca31ad291b0b4b54639b147b24410f4f86197e4a776049882694
This commit is contained in:
12 files changed
+653
-12
No files matched your search
@@ -44,10 +44,10 @@ echo "=== BEGIN env ==="
|
||||
env
|
||||
echo "=== END env ==="
|
||||
|
||||
# Don't apply patches in the tidy job, because it relies on the `git diff`
|
||||
# command to detect IWYU errors. It is safe to skip this patch in the tidy job
|
||||
# Don't apply patches in the iwyu job, because it relies on the `git diff`
|
||||
# command to detect IWYU errors. It is safe to skip this patch in the iwyu job
|
||||
# because it doesn't run a UB detector.
|
||||
if [ "$RUN_TIDY" != "true" ]; then
|
||||
if [[ "${RUN_IWYU}" != true ]]; then
|
||||
# compact->outputs[i].file_size is uninitialized memory, so reading it is UB.
|
||||
# The statistic bytes_written is only used for logging, which is disabled in
|
||||
# CI, so as a temporary minimal fix to work around UB and CI failures, leave
|
||||
@@ -123,7 +123,7 @@ BASE_BUILD_DIR=${BASE_BUILD_DIR:-$BASE_SCRATCH_DIR/build-$HOST}
|
||||
|
||||
BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DCMAKE_INSTALL_PREFIX=$BASE_OUTDIR -Werror=dev"
|
||||
|
||||
if [[ "${RUN_TIDY}" == "true" ]]; then
|
||||
if [[ "${RUN_IWYU}" == true || "${RUN_TIDY}" == true ]]; then
|
||||
BITCOIN_CONFIG_ALL="$BITCOIN_CONFIG_ALL -DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
|
||||
fi
|
||||
|
||||
@@ -135,11 +135,15 @@ cmake -S "$BASE_ROOT_DIR" -B "$BASE_BUILD_DIR" "${CMAKE_ARGS[@]}" || (
|
||||
false
|
||||
)
|
||||
|
||||
if [[ "${GOAL}" != all && "${GOAL}" != codegen ]]; then
|
||||
GOAL="all ${GOAL}"
|
||||
fi
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
cmake --build "${BASE_BUILD_DIR}" "$MAKEJOBS" --target all $GOAL || (
|
||||
cmake --build "${BASE_BUILD_DIR}" "$MAKEJOBS" --target $GOAL || (
|
||||
echo "Build failure. Verbose build follows."
|
||||
# shellcheck disable=SC2086
|
||||
cmake --build "${BASE_BUILD_DIR}" -j1 --target all $GOAL --verbose
|
||||
cmake --build "${BASE_BUILD_DIR}" -j1 --target $GOAL --verbose
|
||||
false
|
||||
)
|
||||
|
||||
@@ -207,7 +211,9 @@ if [ "${RUN_TIDY}" = "true" ]; then
|
||||
echo "^^^ ⚠️ Failure generated from clang-tidy"
|
||||
false
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${RUN_IWYU}" == true ]]; then
|
||||
# TODO: Consider enforcing IWYU across the entire codebase.
|
||||
FILES_WITH_ENFORCED_IWYU="/src/((crypto|index)/.*\\.cpp|node/blockstorage.cpp|node/utxo_snapshot.cpp|core_read.cpp|signet.cpp|kernel/chain.cpp)"
|
||||
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"
|
||||
@@ -223,6 +229,7 @@ if [ "${RUN_TIDY}" = "true" ]; then
|
||||
-Xiwyu --max_line_length=160 \
|
||||
2>&1 | tee /tmp/iwyu_ci.out
|
||||
python3 "/include-what-you-use/fix_includes.py" --nosafe_headers < /tmp/iwyu_ci.out
|
||||
git diff -U0 | ./contrib/devtools/clang-format-diff.py -binary="clang-format-${TIDY_LLVM_V}" -p1 -i -v
|
||||
}
|
||||
|
||||
run_iwyu "compile_commands_iwyu_errors.json"
|
||||
|
||||
Reference in new issue
Block a user