Skip to content

Commit fab24f8

Browse files
author
MarcoFalke
committed
ci: Add clang-tidy task
1 parent 0da559e commit fab24f8

File tree

6 files changed

+45
-1
lines changed

6 files changed

+45
-1
lines changed

.cirrus.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@ task:
7272
env:
7373
<< : *CIRRUS_EPHEMERAL_WORKER_TEMPLATE_ENV
7474

75+
task:
76+
name: 'tidy [jammy]'
77+
<< : *GLOBAL_TASK_TEMPLATE
78+
container:
79+
image: ubuntu:jammy
80+
cpu: 2
81+
memory: 5G
82+
# For faster CI feedback, immediately schedule the linters
83+
<< : *CREDITS_TEMPLATE
84+
env:
85+
<< : *CIRRUS_EPHEMERAL_WORKER_TEMPLATE_ENV
86+
FILE_ENV: "./ci/test/00_setup_env_native_tidy.sh"
87+
7588
task:
7689
name: "Win64 native [msvc]"
7790
<< : *FILTER_TEMPLATE

ci/test/00_setup_env.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export USE_BUSY_BOX=${USE_BUSY_BOX:-false}
3737

3838
export RUN_UNIT_TESTS=${RUN_UNIT_TESTS:-true}
3939
export RUN_FUNCTIONAL_TESTS=${RUN_FUNCTIONAL_TESTS:-true}
40+
export RUN_TIDY=${RUN_TIDY:-false}
4041
export RUN_SECURITY_TESTS=${RUN_SECURITY_TESTS:-false}
4142
# By how much to scale the test_runner timeouts (option --timeout-factor).
4243
# This is needed because some ci machines have slow CPU or disk, so sanitizers

ci/test/00_setup_env_native_tidy.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2022 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
7+
export LC_ALL=C.UTF-8
8+
9+
export DOCKER_NAME_TAG="ubuntu:22.04"
10+
export CONTAINER_NAME=ci_native_tidy
11+
export PACKAGES="clang llvm clang-tidy bear libevent-dev libboost-dev"
12+
export NO_DEPENDS=1
13+
export RUN_UNIT_TESTS=false
14+
export RUN_FUNCTIONAL_TESTS=false
15+
export RUN_FUZZ_TESTS=false
16+
export RUN_TIDY=true
17+
export GOAL="install"
18+
export BITCOIN_CONFIG="CC=clang CXX=clang++ --disable-hardening CFLAGS='-O0 -g0' CXXFLAGS='-O0 -g0'"
19+
export CCACHE_SIZE=200M

ci/test/06_script_a.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ if [[ ${USE_MEMORY_SANITIZER} == "true" ]]; then
4848
CI_EXEC 'grep -v HAVE_SYS_GETRANDOM src/config/bitcoin-config.h > src/config/bitcoin-config.h.tmp && mv src/config/bitcoin-config.h.tmp src/config/bitcoin-config.h'
4949
fi
5050

51-
CI_EXEC make "$MAKEJOBS" "$GOAL" || ( echo "Build failure. Verbose build follows." && CI_EXEC make "$GOAL" V=1 ; false )
51+
if [[ "${RUN_TIDY}" == "true" ]]; then
52+
MAYBE_BEAR="bear"
53+
MAYBE_TOKEN="--"
54+
fi
55+
56+
CI_EXEC "${MAYBE_BEAR}" "${MAYBE_TOKEN}" make "$MAKEJOBS" "$GOAL" || ( echo "Build failure. Verbose build follows." && CI_EXEC make "$GOAL" V=1 ; false )
5257

5358
CI_EXEC "ccache --version | head -n 1 && ccache --show-stats"
5459
CI_EXEC du -sh "${DEPENDS_DIR}"/*/

ci/test/06_script_b.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ if [ "$RUN_FUNCTIONAL_TESTS" = "true" ]; then
3434
CI_EXEC LD_LIBRARY_PATH="${DEPENDS_DIR}/${HOST}/lib" "${TEST_RUNNER_ENV}" test/functional/test_runner.py --ci "$MAKEJOBS" --tmpdirprefix "${BASE_SCRATCH_DIR}/test_runner/" --ansi --combinedlogslen=4000 --timeout-factor="${TEST_RUNNER_TIMEOUT_FACTOR}" "${TEST_RUNNER_EXTRA}" --quiet --failfast
3535
fi
3636

37+
if [ "${RUN_TIDY}" = "true" ]; then
38+
export P_CI_DIR="${BASE_BUILD_DIR}/bitcoin-$HOST/src/"
39+
CI_EXEC run-clang-tidy "${MAKEJOBS}"
40+
fi
41+
3742
if [ "$RUN_SECURITY_TESTS" = "true" ]; then
3843
CI_EXEC make test-security-check
3944
fi

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,6 +1926,7 @@ AC_CONFIG_LINKS([contrib/devtools/test-security-check.py:contrib/devtools/test-s
19261926
AC_CONFIG_LINKS([contrib/devtools/test-symbol-check.py:contrib/devtools/test-symbol-check.py])
19271927
AC_CONFIG_LINKS([contrib/filter-lcov.py:contrib/filter-lcov.py])
19281928
AC_CONFIG_LINKS([contrib/macdeploy/background.tiff:contrib/macdeploy/background.tiff])
1929+
AC_CONFIG_LINKS([src/.clang-tidy:src/.clang-tidy])
19291930
AC_CONFIG_LINKS([test/functional/test_runner.py:test/functional/test_runner.py])
19301931
AC_CONFIG_LINKS([test/fuzz/test_runner.py:test/fuzz/test_runner.py])
19311932
AC_CONFIG_LINKS([test/util/test_runner.py:test/util/test_runner.py])

0 commit comments

Comments
 (0)