Skip to content

Commit 9730288

Browse files
committed
ci: Migrate CI scripts to CMake
1 parent c360837 commit 9730288

21 files changed

+123
-175
lines changed

.github/workflows/ci.yml

Lines changed: 34 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ jobs:
6767
echo "TEST_BASE=$(git rev-list -n$((${{ env.MAX_COUNT }} + 1)) --reverse HEAD $EXCLUDE_MERGE_BASE_ANCESTORS | head -1)" >> "$GITHUB_ENV"
6868
- run: |
6969
sudo apt-get update
70-
sudo apt-get install clang ccache build-essential libtool autotools-dev automake pkg-config bsdmainutils python3-zmq libevent-dev libboost-dev libsqlite3-dev libdb++-dev systemtap-sdt-dev libminiupnpc-dev libnatpmp-dev qtbase5-dev qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev -y
70+
sudo apt-get install clang ccache build-essential cmake pkg-config bsdmainutils python3-zmq libevent-dev libboost-dev libsqlite3-dev libdb++-dev systemtap-sdt-dev libminiupnpc-dev libnatpmp-dev qtbase5-dev qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev -y
7171
- name: Compile and run tests
7272
run: |
7373
# Run tests on commits after the last merge commit and before the PR head commit
7474
# Use clang++, because it is a bit faster and uses less memory than g++
75-
git rebase --exec "echo Running test-one-commit on \$( git log -1 ) && ./autogen.sh && CC=clang CXX=clang++ ./configure --with-incompatible-bdb && make clean && make -j $(nproc) check && ./test/functional/test_runner.py -j $(( $(nproc) * 2 ))" ${{ env.TEST_BASE }}
75+
git rebase --exec "echo Running test-one-commit on \$( git log -1 ) && CC=clang CXX=clang++ cmake -B build -DBUILD_GUI=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DWITH_BDB=ON -DWITH_NATPMP=ON -DWITH_MINIUPNPC=ON -DWITH_USDT=ON && cmake --build build -j $(nproc) && ctest --test-dir build -j $(nproc) && ./build/test/functional/test_runner.py -j $(( $(nproc) * 2 ))" ${{ env.TEST_BASE }}
7676
7777
macos-native-x86_64:
7878
name: 'macOS 13 native, x86_64, no depends, sqlite only, gui'
@@ -139,18 +139,17 @@ jobs:
139139
if: github.repository != 'bitcoin-core/gui' || github.event_name == 'pull_request'
140140

141141
env:
142-
CCACHE_MAXSIZE: '200M'
143-
CI_CCACHE_VERSION: '4.7.5'
144-
CI_QT_CONF: '-release -silent -opensource -confirm-license -opengl desktop -static -static-runtime -mp -qt-zlib -qt-pcre -qt-libpng -nomake examples -nomake tests -nomake tools -no-angle -no-dbus -no-gif -no-gtk -no-ico -no-icu -no-libjpeg -no-libudev -no-sql-sqlite -no-sql-odbc -no-sqlite -no-vulkan -skip qt3d -skip qtactiveqt -skip qtandroidextras -skip qtcharts -skip qtconnectivity -skip qtdatavis3d -skip qtdeclarative -skip doc -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtlottie -skip qtmacextras -skip qtmultimedia -skip qtnetworkauth -skip qtpurchasing -skip qtquick3d -skip qtquickcontrols -skip qtquickcontrols2 -skip qtquicktimeline -skip qtremoteobjects -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qtsvg -skip qtvirtualkeyboard -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebglplugin -skip qtwebsockets -skip qtwebview -skip qtx11extras -skip qtxmlpatterns -no-openssl -no-feature-bearermanagement -no-feature-printdialog -no-feature-printer -no-feature-printpreviewdialog -no-feature-printpreviewwidget -no-feature-sql -no-feature-sqlmodel -no-feature-textbrowser -no-feature-textmarkdownwriter -no-feature-textodfwriter -no-feature-xml'
145-
CI_QT_DIR: 'qt-everywhere-src-5.15.11'
146-
CI_QT_URL: 'https://download.qt.io/official_releases/qt/5.15/5.15.11/single/qt-everywhere-opensource-src-5.15.11.zip'
147142
PYTHONUTF8: 1
148143
TEST_RUNNER_TIMEOUT_FACTOR: 40
149144

150145
steps:
151146
- name: Checkout
152147
uses: actions/checkout@v4
153148

149+
- name: Remove non-MSVC tool installations
150+
run: |
151+
Remove-Item -Path "$env:ProgramFiles/CMake" -Recurse -Force
152+
154153
- name: Configure Developer Command Prompt for Microsoft Visual C++
155154
# Using microsoft/setup-msbuild is not enough.
156155
uses: ilammy/msvc-dev-cmd@v1
@@ -159,141 +158,60 @@ jobs:
159158

160159
- name: Get tool information
161160
run: |
161+
cmake -version | Tee-Object -FilePath "cmake_version"
162+
Write-Output "---"
162163
msbuild -version | Tee-Object -FilePath "msbuild_version"
163164
$env:VCToolsVersion | Tee-Object -FilePath "toolset_version"
164-
$env:CI_QT_URL | Out-File -FilePath "qt_url"
165-
$env:CI_QT_CONF | Out-File -FilePath "qt_conf"
166165
py -3 --version
167166
Write-Host "PowerShell version $($PSVersionTable.PSVersion.ToString())"
168167
169-
- name: Restore static Qt cache
170-
id: static-qt-cache
171-
uses: actions/cache/restore@v4
172-
with:
173-
path: C:\Qt_static
174-
key: ${{ github.job }}-static-qt-${{ hashFiles('msbuild_version', 'qt_url', 'qt_conf') }}
175-
176-
- name: Build static Qt. Download
177-
if: steps.static-qt-cache.outputs.cache-hit != 'true'
178-
shell: cmd
179-
run: |
180-
curl --location --output C:\qt-src.zip %CI_QT_URL%
181-
choco install --yes --no-progress jom
182-
183-
- name: Build static Qt. Expand source archive
184-
if: steps.static-qt-cache.outputs.cache-hit != 'true'
185-
shell: cmd
186-
run: tar -xf C:\qt-src.zip -C C:\
187-
188-
- name: Build static Qt. Create build directory
189-
if: steps.static-qt-cache.outputs.cache-hit != 'true'
190-
run: |
191-
Rename-Item -Path "C:\$env:CI_QT_DIR" -NewName "C:\qt-src"
192-
New-Item -ItemType Directory -Path "C:\qt-src\build"
193-
194-
- name: Build static Qt. Configure
195-
if: steps.static-qt-cache.outputs.cache-hit != 'true'
196-
working-directory: C:\qt-src\build
197-
shell: cmd
198-
run: ..\configure %CI_QT_CONF% -prefix C:\Qt_static
199-
200-
- name: Build static Qt. Build
201-
if: steps.static-qt-cache.outputs.cache-hit != 'true'
202-
working-directory: C:\qt-src\build
203-
shell: cmd
204-
run: jom
205-
206-
- name: Build static Qt. Install
207-
if: steps.static-qt-cache.outputs.cache-hit != 'true'
208-
working-directory: C:\qt-src\build
209-
shell: cmd
210-
run: jom install
211-
212-
- name: Save static Qt cache
213-
if: steps.static-qt-cache.outputs.cache-hit != 'true'
214-
uses: actions/cache/save@v4
215-
with:
216-
path: C:\Qt_static
217-
key: ${{ github.job }}-static-qt-${{ hashFiles('msbuild_version', 'qt_url', 'qt_conf') }}
218-
219-
- name: Ccache installation cache
220-
id: ccache-installation-cache
221-
uses: actions/cache@v4
222-
with:
223-
path: |
224-
C:\ProgramData\chocolatey\lib\ccache
225-
C:\ProgramData\chocolatey\bin\ccache.exe
226-
C:\ccache\cl.exe
227-
key: ${{ github.job }}-ccache-installation-${{ env.CI_CCACHE_VERSION }}
228-
229-
- name: Install Ccache
230-
if: steps.ccache-installation-cache.outputs.cache-hit != 'true'
231-
run: |
232-
choco install --yes --no-progress ccache --version=$env:CI_CCACHE_VERSION
233-
New-Item -ItemType Directory -Path "C:\ccache"
234-
Copy-Item -Path "$env:ChocolateyInstall\lib\ccache\tools\ccache-$env:CI_CCACHE_VERSION-windows-x86_64\ccache.exe" -Destination "C:\ccache\cl.exe"
235-
236-
- name: Restore Ccache cache
237-
id: ccache-cache
238-
uses: actions/cache/restore@v4
239-
with:
240-
path: ~/AppData/Local/ccache
241-
key: ${{ github.job }}-ccache-${{ github.run_id }}
242-
restore-keys: ${{ github.job }}-ccache-
243-
244168
- name: Using vcpkg with MSBuild
245169
run: |
246170
Set-Location "$env:VCPKG_INSTALLATION_ROOT"
171+
Add-Content -Path "triplets\x64-windows.cmake" -Value "set(VCPKG_BUILD_TYPE release)"
247172
Add-Content -Path "triplets\x64-windows-static.cmake" -Value "set(VCPKG_BUILD_TYPE release)"
248-
.\vcpkg.exe --vcpkg-root "$env:VCPKG_INSTALLATION_ROOT" integrate install
249-
git rev-parse HEAD | Tee-Object -FilePath "$env:GITHUB_WORKSPACE\vcpkg_commit"
250173
251174
- name: vcpkg tools cache
252175
uses: actions/cache@v4
253176
with:
254177
path: C:/vcpkg/downloads/tools
255178
key: ${{ github.job }}-vcpkg-tools
256179

257-
- name: vcpkg binary cache
258-
uses: actions/cache@v4
180+
- name: Restore vcpkg binary cache
181+
uses: actions/cache/restore@v4
182+
id: vcpkg-binary-cache
259183
with:
260184
path: ~/AppData/Local/vcpkg/archives
261-
key: ${{ github.job }}-vcpkg-binary-${{ hashFiles('vcpkg_commit', 'msbuild_version', 'toolset_version', 'build_msvc/vcpkg.json') }}
262-
263-
- name: Generate project files
264-
run: py -3 build_msvc\msvc-autogen.py
185+
key: ${{ github.job }}-vcpkg-binary-${{ hashFiles('cmake_version', 'msbuild_version', 'toolset_version', 'vcpkg.json') }}
265186

266-
- name: Build
267-
shell: cmd
187+
- name: Generate build system
268188
run: |
269-
ccache --zero-stats
270-
msbuild build_msvc\bitcoin.sln -property:CLToolPath=C:\ccache;CLToolExe=cl.exe;UseMultiToolTask=true;Configuration=Release -maxCpuCount -verbosity:minimal -noLogo
271-
272-
- name: Ccache stats
273-
run: ccache --show-stats
189+
cmake -B build --preset vs2022-static -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DWERROR=ON
274190
275-
- name: Save Ccache cache
191+
- name: Save vcpkg binary cache
276192
uses: actions/cache/save@v4
277-
if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true'
193+
if: github.event_name != 'pull_request' && steps.vcpkg-binary-cache.outputs.cache-hit != 'true'
278194
with:
279-
path: ~/AppData/Local/ccache
280-
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
281-
key: ${{ github.job }}-ccache-${{ github.run_id }}
282-
283-
- name: Run unit tests
284-
run: src\test_bitcoin.exe -l test_suite
285-
286-
- name: Run benchmarks
287-
run: src\bench_bitcoin.exe -sanity-check
195+
path: ~/AppData/Local/vcpkg/archives
196+
key: ${{ github.job }}-vcpkg-binary-${{ hashFiles('cmake_version', 'msbuild_version', 'toolset_version', 'vcpkg.json') }}
288197

289-
- name: Run util tests
290-
run: py -3 test\util\test_runner.py
198+
- name: Build
199+
working-directory: build
200+
run: |
201+
cmake --build . -j $env:NUMBER_OF_PROCESSORS --config Release
291202
292-
- name: Run rpcauth test
293-
run: py -3 test\util\rpcauth-test.py
203+
- name: Run test suite
204+
working-directory: build
205+
run: |
206+
ctest -j $env:NUMBER_OF_PROCESSORS -C Release
294207
295208
- name: Run functional tests
209+
working-directory: build
296210
env:
211+
BITCOIND: '${{ github.workspace }}\build\src\Release\bitcoind.exe'
212+
BITCOINCLI: '${{ github.workspace }}\build\src\Release\bitcoin-cli.exe'
213+
BITCOINUTIL: '${{ github.workspace }}\build\src\Release\bitcoin-util.exe'
214+
BITCOINWALLET: '${{ github.workspace }}\build\src\Release\bitcoin-wallet.exe'
297215
TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }}
298216
shell: cmd
299217
run: py -3 test\functional\test_runner.py --jobs %NUMBER_OF_PROCESSORS% --ci --quiet --tmpdirprefix=%RUNNER_TEMP% --combinedlogslen=99999999 --timeout-factor=%TEST_RUNNER_TIMEOUT_FACTOR% %TEST_RUNNER_EXTRA%
@@ -306,8 +224,9 @@ jobs:
306224
git log -1
307225
308226
- name: Run fuzz binaries
227+
working-directory: build
309228
env:
310-
BITCOINFUZZ: "${{ github.workspace}}\\src\\fuzz.exe"
229+
BITCOINFUZZ: '${{ github.workspace }}\build\src\test\fuzz\Release\fuzz.exe'
311230
shell: cmd
312231
run: py -3 test\fuzz\test_runner.py --par %NUMBER_OF_PROCESSORS% --loglevel DEBUG %RUNNER_TEMP%\qa-assets\fuzz_seed_corpus
313232

ci/test/00_setup_env.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ export CCACHE_COMPRESS=${CCACHE_COMPRESS:-1}
6161
export CCACHE_DIR=${CCACHE_DIR:-$BASE_SCRATCH_DIR/.ccache}
6262
# Folder where the build result is put (bin and lib).
6363
export BASE_OUTDIR=${BASE_OUTDIR:-$BASE_SCRATCH_DIR/out}
64-
# Folder where the build is done (dist and out-of-tree build).
65-
export BASE_BUILD_DIR=${BASE_BUILD_DIR:-$BASE_SCRATCH_DIR/build}
6664
# The folder for previous release binaries.
6765
# This folder exists only on the ci guest, and on the ci host as a volume.
6866
export PREVIOUS_RELEASES_DIR=${PREVIOUS_RELEASES_DIR:-$BASE_ROOT_DIR/prev_releases}

ci/test/00_setup_env_arm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ export RUN_FUNCTIONAL_TESTS=false
1717
export GOAL="install"
1818
# -Wno-psabi is to disable ABI warnings: "note: parameter passing for argument of type ... changed in GCC 7.1"
1919
# This could be removed once the ABI change warning does not show up by default
20-
export BITCOIN_CONFIG="--enable-reduce-exports CXXFLAGS='-Wno-psabi -Wno-error=maybe-uninitialized'"
20+
export BITCOIN_CONFIG="-DREDUCE_EXPORTS=ON -DCMAKE_CXX_FLAGS='-Wno-psabi -Wno-error=maybe-uninitialized'"

ci/test/00_setup_env_i686_centos.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ export CI_BASE_PACKAGES="gcc-c++ glibc-devel.x86_64 libstdc++-devel.x86_64 glibc
1313
export PIP_PACKAGES="pyzmq"
1414
export GOAL="install"
1515
export NO_WERROR=1 # Suppress error: #warning _FORTIFY_SOURCE > 2 is treated like 2 on this platform [-Werror=cpp]
16-
export BITCOIN_CONFIG="--enable-zmq --with-gui=qt5 --enable-reduce-exports"
16+
export BITCOIN_CONFIG="-DWITH_ZMQ=ON -DBUILD_GUI=ON -DREDUCE_EXPORTS=ON"
1717
export CONFIG_SHELL="/bin/dash"

ci/test/00_setup_env_i686_multiprocess.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ export PACKAGES="llvm clang g++-multilib"
1313
export DEP_OPTS="DEBUG=1 MULTIPROCESS=1"
1414
export GOAL="install"
1515
export TEST_RUNNER_EXTRA="--v2transport"
16-
export BITCOIN_CONFIG="--enable-debug CC='clang -m32' CXX='clang++ -m32' \
17-
CPPFLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE' CXXFLAGS='-Wno-error=documentation'"
16+
export BITCOIN_CONFIG="\
17+
-DCMAKE_BUILD_TYPE=Debug \
18+
-DCMAKE_C_COMPILER='clang;-m32' \
19+
-DCMAKE_CXX_COMPILER='clang++;-m32' \
20+
-DCMAKE_CXX_FLAGS='-Wno-error=documentation' \
21+
-DAPPEND_CPPFLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE' \
22+
"
1823
export BITCOIND=bitcoin-node # Used in functional tests

ci/test/00_setup_env_mac_cross.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ export XCODE_BUILD_ID=15A240d
1717
export RUN_UNIT_TESTS=false
1818
export RUN_FUNCTIONAL_TESTS=false
1919
export GOAL="deploy"
20-
export BITCOIN_CONFIG="--with-gui --enable-reduce-exports"
20+
export BITCOIN_CONFIG="-DBUILD_GUI=ON -DREDUCE_EXPORTS=ON"

ci/test/00_setup_env_mac_native.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export HOST=x86_64-apple-darwin
1111
# Therefore, `--break-system-packages` is needed.
1212
export PIP_PACKAGES="--break-system-packages zmq"
1313
export GOAL="install"
14-
export BITCOIN_CONFIG="--with-gui --with-miniupnpc --with-natpmp --enable-reduce-exports"
14+
export BITCOIN_CONFIG="-DBUILD_GUI=ON -DWITH_MINIUPNPC=ON -DWITH_NATPMP=ON -DREDUCE_EXPORTS=ON"
1515
export CI_OS_NAME="macos"
1616
export NO_DEPENDS=1
1717
export OSX_SDK=""

ci/test/00_setup_env_native_asan.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ export CONTAINER_NAME=ci_native_asan
2222
export PACKAGES="systemtap-sdt-dev clang-18 llvm-18 libclang-rt-18-dev python3-zmq qtbase5-dev qttools5-dev qttools5-dev-tools libevent-dev libboost-dev libdb5.3++-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev libqrencode-dev libsqlite3-dev ${BPFCC_PACKAGE}"
2323
export NO_DEPENDS=1
2424
export GOAL="install"
25-
export BITCOIN_CONFIG="--enable-usdt --enable-zmq --with-incompatible-bdb --with-gui=qt5 \
26-
CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKORDER' \
27-
--with-sanitizers=address,float-divide-by-zero,integer,undefined \
28-
CC='clang-18 -ftrivial-auto-var-init=pattern' CXX='clang++-18 -ftrivial-auto-var-init=pattern'"
25+
export BITCOIN_CONFIG="\
26+
-DWITH_USDT=ON -DWITH_ZMQ=ON -DWARN_INCOMPATIBLE_BDB=OFF -DBUILD_GUI=ON \
27+
-DSANITIZERS=address,float-divide-by-zero,integer,undefined \
28+
-DCMAKE_C_COMPILER=clang-18 \
29+
-DCMAKE_CXX_COMPILER=clang++-18 \
30+
-DCMAKE_C_FLAGS='-ftrivial-auto-var-init=pattern' \
31+
-DCMAKE_CXX_FLAGS='-ftrivial-auto-var-init=pattern' \
32+
-DAPPEND_CPPFLAGS='-DARENA_DEBUG -DDEBUG_LOCKORDER' \
33+
"
2934
export CCACHE_MAXSIZE=300M

ci/test/00_setup_env_native_fuzz.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ export RUN_FUNCTIONAL_TESTS=false
1515
export RUN_FUZZ_TESTS=true
1616
export GOAL="install"
1717
export CI_CONTAINER_CAP="--cap-add SYS_PTRACE" # If run with (ASan + LSan), the container needs access to ptrace (https://github.com/google/sanitizers/issues/764)
18-
export BITCOIN_CONFIG="--enable-fuzz --with-sanitizers=fuzzer,address,undefined,float-divide-by-zero,integer \
19-
CC='clang-18 -ftrivial-auto-var-init=pattern' CXX='clang++-18 -ftrivial-auto-var-init=pattern'"
18+
export BITCOIN_CONFIG="\
19+
-DBUILD_FOR_FUZZING=ON \
20+
-DSANITIZERS=fuzzer,address,undefined,float-divide-by-zero,integer \
21+
-DCMAKE_C_COMPILER=clang-18 \
22+
-DCMAKE_CXX_COMPILER=clang++-18 \
23+
-DCMAKE_C_FLAGS='-ftrivial-auto-var-init=pattern' \
24+
-DCMAKE_CXX_FLAGS='-ftrivial-auto-var-init=pattern' \
25+
"
2026
export CCACHE_MAXSIZE=200M
2127
export LLVM_SYMBOLIZER_PATH="/usr/bin/llvm-symbolizer-18"

ci/test/00_setup_env_native_fuzz_with_msan.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ export PACKAGES="ninja-build"
1818
export DEP_OPTS="DEBUG=1 NO_BDB=1 NO_QT=1 CC=clang CXX=clang++ CFLAGS='${MSAN_FLAGS}' CXXFLAGS='${MSAN_AND_LIBCXX_FLAGS}'"
1919
export GOAL="install"
2020
# _FORTIFY_SOURCE is not compatible with MSAN.
21-
export BITCOIN_CONFIG="--enable-fuzz --with-sanitizers=fuzzer,memory CPPFLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE -U_FORTIFY_SOURCE'"
21+
export BITCOIN_CONFIG="\
22+
-DBUILD_FOR_FUZZING=ON \
23+
-DSANITIZERS=fuzzer,memory \
24+
-DAPPEND_CPPFLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE -U_FORTIFY_SOURCE' \
25+
"
2226
export USE_MEMORY_SANITIZER="true"
2327
export RUN_UNIT_TESTS="false"
2428
export RUN_FUNCTIONAL_TESTS="false"

0 commit comments

Comments
 (0)