2023-08-09 10:59:43 +01:00
# Copyright (c) 2023 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
name : CI
on :
# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request.
pull_request :
# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push.
push :
branches :
- '**'
tags-ignore :
- '**'
2023-08-17 11:49:14 +01:00
concurrency :
2023-08-22 11:26:01 +01:00
group : ${{ github.event_name != 'pull_request' && github.run_id || github.ref }}
cancel-in-progress : true
2023-08-17 11:49:14 +01:00
2023-08-09 10:59:43 +01:00
env :
2023-08-16 14:50:16 +02:00
CI_FAILFAST_TEST_LEAVE_DANGLING : 1 # GHA does not care about dangling processes and setting this variable avoids killing the CI script itself on error
MAKEJOBS : '-j10'
2023-08-09 10:59:43 +01:00
jobs :
2023-09-19 09:36:53 +01:00
test-each-commit :
name : 'test each commit'
2024-05-08 11:24:55 +02:00
runs-on : ubuntu-24.04
2023-09-19 09:36:53 +01:00
if : github.event_name == 'pull_request' && github.event.pull_request.commits != 1
timeout-minutes : 360 # Use maximum time, see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes. Assuming a worst case time of 1 hour per commit, this leads to a --max-count=6 below.
env :
MAX_COUNT : 6
steps :
2023-10-03 08:43:16 -04:00
- name : Determine fetch depth
run : echo "FETCH_DEPTH=$((${{ github.event.pull_request.commits }} + 2))" >> "$GITHUB_ENV"
2023-09-19 09:36:53 +01:00
- uses : actions/checkout@v4
with :
ref : ${{ github.event.pull_request.head.sha }}
fetch-depth : ${{ env.FETCH_DEPTH }}
2023-10-03 08:43:16 -04:00
- name : Determine commit range
run : |
# Checkout HEAD~ and find the test base commit
# Checkout HEAD~ because it would be wasteful to rerun tests on the PR
# head commit that are already run by other jobs.
2023-09-19 09:36:53 +01:00
git checkout HEAD~
2023-10-03 08:43:16 -04:00
# Figure out test base commit by listing ancestors of HEAD, excluding
# ancestors of the most recent merge commit, limiting the list to the
# newest MAX_COUNT ancestors, ordering it from oldest to newest, and
# taking the first one.
#
# If the branch contains up to MAX_COUNT ancestor commits after the
# most recent merge commit, all of those commits will be tested. If it
# contains more, only the most recent MAX_COUNT commits will be
# tested.
#
# In the command below, the ^@ suffix is used to refer to all parents
# of the merge commit as described in:
# https://git-scm.com/docs/git-rev-parse#_other_rev_parent_shorthand_notations
# and the ^ prefix is used to exclude these parents and all their
# ancestors from the rev-list output as described in:
# https://git-scm.com/docs/git-rev-list
2024-06-25 14:42:20 +02:00
MERGE_BASE=$(git rev-list -n1 --merges HEAD)
EXCLUDE_MERGE_BASE_ANCESTORS=
# MERGE_BASE can be empty due to limited fetch-depth
if test -n "$MERGE_BASE"; then
EXCLUDE_MERGE_BASE_ANCESTORS=^${MERGE_BASE}^@
fi
echo "TEST_BASE=$(git rev-list -n$((${{ env.MAX_COUNT }} + 1)) --reverse HEAD $EXCLUDE_MERGE_BASE_ANCESTORS | head -1)" >> "$GITHUB_ENV"
2023-11-22 10:01:19 +00:00
- run : |
sudo apt-get update
2024-10-22 00:31:47 +02:00
sudo apt-get install clang ccache build-essential cmake pkg-config python3-zmq libevent-dev libboost-dev libsqlite3-dev libdb++-dev systemtap-sdt-dev libzmq3-dev qtbase5-dev qttools5-dev qttools5-dev-tools qtwayland5 libqrencode-dev -y
2023-09-19 09:36:53 +01:00
- name : Compile and run tests
run : |
2023-10-03 08:43:16 -04:00
# Run tests on commits after the last merge commit and before the PR head commit
2023-09-19 09:36:53 +01:00
# Use clang++, because it is a bit faster and uses less memory than g++
2024-10-30 13:57:42 -04:00
git rebase --exec "echo Running test-one-commit on \$( git log -1 ) && CC=clang CXX=clang++ cmake -B build -DWERROR=ON -DWITH_ZMQ=ON -DBUILD_GUI=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DWITH_BDB=ON -DWITH_USDT=ON -DCMAKE_CXX_FLAGS='-Wno-error=unused-member-function' && cmake --build build -j $(nproc) && ctest --output-on-failure --test-dir build -j $(nproc) && ./build/test/functional/test_runner.py -j $(( $(nproc) * 2 ))" ${{ env.TEST_BASE }}
2023-09-19 09:36:53 +01:00
2024-09-16 11:43:42 +02:00
macos-native-arm64 :
name : 'macOS 14 native, arm64, no depends, sqlite only, gui'
2023-08-09 10:59:43 +01:00
# Use latest image, but hardcode version to avoid silent upgrades (and breaks).
# See: https://github.com/actions/runner-images#available-images.
2024-09-16 11:43:42 +02:00
runs-on : macos-14
2023-08-09 10:59:43 +01:00
# No need to run on the read-only mirror, unless it is a PR.
if : github.repository != 'bitcoin-core/gui' || github.event_name == 'pull_request'
timeout-minutes : 120
env :
2024-06-07 23:32:27 +01:00
DANGER_RUN_CI_ON_HOST : 1
2023-08-09 10:59:43 +01:00
FILE_ENV : './ci/test/00_setup_env_mac_native.sh'
2023-08-15 23:27:39 +02:00
BASE_ROOT_DIR : ${{ github.workspace }}
2023-08-09 10:59:43 +01:00
steps :
- name : Checkout
2023-09-04 15:25:41 +01:00
uses : actions/checkout@v4
2023-08-09 10:59:43 +01:00
- name : Clang version
2024-01-07 11:38:23 +00:00
run : |
sudo xcode-select --switch /Applications/Xcode_15.0.app
clang --version
2023-08-09 10:59:43 +01:00
- name : Install Homebrew packages
2023-12-14 12:18:53 +00:00
env :
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK : 1
2024-03-10 13:08:42 +00:00
run : |
# A workaround for "The `brew link` step did not complete successfully" error.
2024-08-05 17:14:33 +01:00
brew install --quiet python@3 || brew link --overwrite python@3
2024-10-22 00:31:47 +02:00
brew install --quiet coreutils ninja pkg-config gnu-getopt ccache boost libevent zeromq qt@5 qrencode
2023-08-09 10:59:43 +01:00
- name : Set Ccache directory
run : echo "CCACHE_DIR=${RUNNER_TEMP}/ccache_dir" >> "$GITHUB_ENV"
2023-08-21 11:26:11 +01:00
- name : Restore Ccache cache
2023-09-01 11:08:20 +01:00
id : ccache-cache
2024-01-25 11:55:57 +00:00
uses : actions/cache/restore@v4
2023-08-09 10:59:43 +01:00
with :
path : ${{ env.CCACHE_DIR }}
2023-08-21 11:26:11 +01:00
key : ${{ github.job }}-ccache-${{ github.run_id }}
restore-keys : ${{ github.job }}-ccache-
2023-08-09 10:59:43 +01:00
- name : CI script
run : ./ci/test_run_all.sh
2023-08-21 11:26:11 +01:00
- name : Save Ccache cache
2024-01-25 11:55:57 +00:00
uses : actions/cache/save@v4
2023-09-01 11:08:20 +01:00
if : github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true'
2023-08-21 11:26:11 +01:00
with :
path : ${{ env.CCACHE_DIR }}
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
key : ${{ github.job }}-ccache-${{ github.run_id }}
2023-08-25 13:50:04 +01:00
win64-native :
name : 'Win64 native, VS 2022'
# Use latest image, but hardcode version to avoid silent upgrades (and breaks).
# See: https://github.com/actions/runner-images#available-images.
runs-on : windows-2022
# No need to run on the read-only mirror, unless it is a PR.
if : github.repository != 'bitcoin-core/gui' || github.event_name == 'pull_request'
env :
PYTHONUTF8 : 1
TEST_RUNNER_TIMEOUT_FACTOR : 40
steps :
- name : Checkout
2023-09-04 15:25:41 +01:00
uses : actions/checkout@v4
2023-08-25 13:50:04 +01:00
- name : Configure Developer Command Prompt for Microsoft Visual C++
# Using microsoft/setup-msbuild is not enough.
uses : ilammy/msvc-dev-cmd@v1
with :
arch : x64
2024-02-28 13:40:08 +00:00
- name : Get tool information
2023-08-25 13:50:04 +01:00
run : |
2024-07-24 11:54:41 +01:00
cmake -version | Tee-Object -FilePath "cmake_version"
Write-Output "---"
2024-06-07 09:59:39 +01:00
msbuild -version | Tee-Object -FilePath "msbuild_version"
$env:VCToolsVersion | Tee-Object -FilePath "toolset_version"
2024-02-28 13:40:08 +00:00
py -3 --version
2024-03-06 15:27:26 +00:00
Write-Host "PowerShell version $($PSVersionTable.PSVersion.ToString())"
2023-08-25 13:50:04 +01:00
- name : Using vcpkg with MSBuild
run : |
Set-Location "$env:VCPKG_INSTALLATION_ROOT"
2024-07-24 11:54:41 +01:00
Add-Content -Path "triplets\x64-windows.cmake" -Value "set(VCPKG_BUILD_TYPE release)"
2023-08-25 13:50:04 +01:00
Add-Content -Path "triplets\x64-windows-static.cmake" -Value "set(VCPKG_BUILD_TYPE release)"
- name : vcpkg tools cache
2024-01-25 11:55:57 +00:00
uses : actions/cache@v4
2023-08-25 13:50:04 +01:00
with :
path : C:/vcpkg/downloads/tools
key : ${{ github.job }}-vcpkg-tools
2024-07-24 11:54:41 +01:00
- name : Restore vcpkg binary cache
uses : actions/cache/restore@v4
id : vcpkg-binary-cache
2023-08-25 13:50:04 +01:00
with :
path : ~/AppData/Local/vcpkg/archives
2024-07-24 11:54:41 +01:00
key : ${{ github.job }}-vcpkg-binary-${{ hashFiles('cmake_version', 'msbuild_version', 'toolset_version', 'vcpkg.json') }}
2023-08-25 13:50:04 +01:00
2024-07-24 11:54:41 +01:00
- name : Generate build system
2023-08-25 13:50:04 +01:00
run : |
2024-10-22 00:31:47 +02:00
cmake -B build --preset vs2022-static -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" -DBUILD_GUI=ON -DWITH_BDB=ON -DWITH_ZMQ=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DWERROR=ON
2023-08-25 13:50:04 +01:00
2024-07-24 11:54:41 +01:00
- name : Save vcpkg binary cache
2024-01-25 11:55:57 +00:00
uses : actions/cache/save@v4
2024-07-24 11:54:41 +01:00
if : github.event_name != 'pull_request' && steps.vcpkg-binary-cache.outputs.cache-hit != 'true'
2023-08-25 13:50:04 +01:00
with :
2024-07-24 11:54:41 +01:00
path : ~/AppData/Local/vcpkg/archives
key : ${{ github.job }}-vcpkg-binary-${{ hashFiles('cmake_version', 'msbuild_version', 'toolset_version', 'vcpkg.json') }}
2023-08-25 13:50:04 +01:00
2024-07-24 11:54:41 +01:00
- name : Build
working-directory : build
run : |
cmake --build . -j $env:NUMBER_OF_PROCESSORS --config Release
2023-08-25 13:50:04 +01:00
2024-07-24 11:54:41 +01:00
- name : Run test suite
working-directory : build
run : |
2024-10-24 10:36:02 -03:00
ctest --output-on-failure -j $env:NUMBER_OF_PROCESSORS -C Release
2023-08-25 13:50:04 +01:00
- name : Run functional tests
2024-07-24 11:54:41 +01:00
working-directory : build
2023-12-12 10:04:49 +00:00
env :
2024-07-24 11:54:41 +01:00
BITCOIND : '${{ github.workspace }}\build\src\Release\bitcoind.exe'
BITCOINCLI : '${{ github.workspace }}\build\src\Release\bitcoin-cli.exe'
BITCOINUTIL : '${{ github.workspace }}\build\src\Release\bitcoin-util.exe'
BITCOINWALLET : '${{ github.workspace }}\build\src\Release\bitcoin-wallet.exe'
2023-12-12 10:04:49 +00:00
TEST_RUNNER_EXTRA : ${{ github.event_name != 'pull_request' && '--extended' || '' }}
2024-03-02 00:44:33 +00:00
shell : cmd
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%
2024-04-18 10:27:34 +01:00
- name : Clone fuzz corpus
run : |
git clone --depth=1 https://github.com/bitcoin-core/qa-assets "$env:RUNNER_TEMP\qa-assets"
Set-Location "$env:RUNNER_TEMP\qa-assets"
Write-Host "Using qa-assets repo from commit ..."
git log -1
2024-04-18 10:27:55 +01:00
- name : Run fuzz binaries
2024-07-24 11:54:41 +01:00
working-directory : build
2024-04-18 10:27:55 +01:00
env :
2024-07-24 11:54:41 +01:00
BITCOINFUZZ : '${{ github.workspace }}\build\src\test\fuzz\Release\fuzz.exe'
2024-04-18 10:27:55 +01:00
shell : cmd
2024-09-03 20:37:46 +02:00
run : py -3 test\fuzz\test_runner.py --par %NUMBER_OF_PROCESSORS% --loglevel DEBUG %RUNNER_TEMP%\qa-assets\fuzz_corpora
2024-06-07 23:32:27 +01:00
asan-lsan-ubsan-integer-no-depends-usdt :
name : 'ASan + LSan + UBSan + integer, no depends, USDT'
runs-on : ubuntu-24.04 # has to match container in ci/test/00_setup_env_native_asan.sh for tracing tools
# No need to run on the read-only mirror, unless it is a PR.
if : github.repository != 'bitcoin-core/gui' || github.event_name == 'pull_request'
timeout-minutes : 120
env :
FILE_ENV : "./ci/test/00_setup_env_native_asan.sh"
2024-06-19 17:40:10 +01:00
DANGER_CI_ON_HOST_CACHE_FOLDERS : 1
2024-06-07 23:32:27 +01:00
steps :
- name : Checkout
uses : actions/checkout@v4
- name : Set Ccache directory
run : echo "CCACHE_DIR=${RUNNER_TEMP}/ccache_dir" >> "$GITHUB_ENV"
2024-06-19 17:40:10 +01:00
- name : Set base root directory
run : echo "BASE_ROOT_DIR=${RUNNER_TEMP}" >> "$GITHUB_ENV"
2024-06-07 23:32:27 +01:00
- name : Restore Ccache cache
id : ccache-cache
uses : actions/cache/restore@v4
with :
path : ${{ env.CCACHE_DIR }}
key : ${{ github.job }}-ccache-${{ github.run_id }}
restore-keys : ${{ github.job }}-ccache-
- name : Enable bpfcc script
# In the image build step, no external environment variables are available,
# so any settings will need to be written to the settings env file:
run : sed -i "s|\${INSTALL_BCC_TRACING_TOOLS}|true|g" ./ci/test/00_setup_env_native_asan.sh
- name : CI script
run : ./ci/test_run_all.sh
- name : Save Ccache cache
uses : actions/cache/save@v4
if : github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true'
with :
path : ${{ env.CCACHE_DIR }}
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
key : ${{ github.job }}-ccache-${{ github.run_id }}