Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ jobs:
restore-keys: |
${{ runner.os }}-bitcoinkernel-

- name: Clean stale CMake cache
run: |
if [ -f bitcoinkernel/bitcoin/build/CMakeCache.txt ]; then
rm -f bitcoinkernel/bitcoin/build/CMakeCache.txt
fi

- name: Build bitcoinkernel
run: |
cd bitcoinkernel/bitcoin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,11 @@ runs:
using: 'composite'
steps:
- name: Check inputs
shell: bash
shell: python
run: |
# We expect only gha or cirrus as inputs to cache-provider
case "${{ inputs.cache-provider }}" in
gha|cirrus)
;;
*)
echo "::warning title=Unknown input to configure docker action::Provided value was ${{ inputs.cache-provider }}"
;;
esac
if "${{ inputs.cache-provider }}" not in ("gha", "cirrus"):
print("::warning title=Unknown input to configure docker action::Provided value was ${{ inputs.cache-provider }}")

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand Down
55 changes: 55 additions & 0 deletions bitcoinkernel/bitcoin/.github/ci-lint-exec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env python3
# Copyright (c) The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit.

import os
import shlex
import subprocess
import sys
import time


def run(cmd, **kwargs):
print("+ " + shlex.join(cmd), flush=True)
kwargs.setdefault("check", True)
try:
return subprocess.run(cmd, **kwargs)
except Exception as e:
sys.exit(e)


def main():
CONTAINER_NAME = os.environ["CONTAINER_NAME"]

build_cmd = [
"docker", "buildx", "build",
f"--tag={CONTAINER_NAME}",
*shlex.split(os.getenv("DOCKER_BUILD_CACHE_ARG", "")),
"--file=./ci/lint_imagefile",
"."
]

if run(build_cmd, check=False).returncode != 0:
print("Retry building image tag after failure")
time.sleep(3)
run(build_cmd)

extra_env = []
if os.environ["GITHUB_EVENT_NAME"] == "pull_request":
extra_env = ["--env", "LINT_CI_IS_PR=1"]
if os.environ["GITHUB_EVENT_NAME"] != "pull_request" and os.environ["GITHUB_REPOSITORY"] == "bitcoin/bitcoin":
extra_env = ["--env", "LINT_CI_SANITY_CHECK_COMMIT_SIG=1"]

run([
"docker",
"run",
"--rm",
*extra_env,
f"--volume={os.getcwd()}:/bitcoin",
CONTAINER_NAME,
])


if __name__ == "__main__":
main()
65 changes: 41 additions & 24 deletions bitcoinkernel/bitcoin/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ jobs:
outputs:
provider: ${{ steps.runners.outputs.provider }}
steps:
- name: Annotate with pull request number
- &ANNOTATION_PR_NUMBER
name: Annotate with pull request number
# This annotation is machine-readable and can be used to assign a check
# run to its corresponding pull request. Running in one check run is
# sufficient for each check suite.
# run to its corresponding pull request. Running in all check runs is
# required, because check re-runs discard the annotations of other
# tasks in the test suite.
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "::notice title=debug_pull_request_number_str::${{ github.event.number }}"
Expand All @@ -63,6 +65,7 @@ jobs:
steps:
- name: Determine fetch depth
run: echo "FETCH_DEPTH=$((${{ github.event.pull_request.commits }} + 2))" >> "$GITHUB_ENV"
- *ANNOTATION_PR_NUMBER
- uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.head.sha }}
Expand Down Expand Up @@ -131,16 +134,18 @@ jobs:
include:
- job-type: standard
file-env: './ci/test/00_setup_env_mac_native.sh'
job-name: 'macOS native, no depends, sqlite only, gui'
job-name: 'macOS native'
- job-type: fuzz
file-env: './ci/test/00_setup_env_mac_native_fuzz.sh'
job-name: 'macOS native, fuzz'

env:
DANGER_RUN_CI_ON_HOST: 1
BASE_ROOT_DIR: ${{ github.workspace }}
BASE_ROOT_DIR: ${{ github.workspace }}/repo_archive

steps:
- *ANNOTATION_PR_NUMBER

- &CHECKOUT
name: Checkout
uses: actions/checkout@v5
Expand Down Expand Up @@ -176,14 +181,22 @@ jobs:
key: ${{ github.job }}-${{ matrix.job-type }}-ccache-${{ github.run_id }}
restore-keys: ${{ github.job }}-${{ matrix.job-type }}-ccache-

- name: Create git archive
run: |
git log -1
git archive --format=tar --prefix=repo_archive/ --output=repo.tar HEAD
tar -xf repo.tar

- name: CI script
run: ./ci/test_run_all.sh
run: |
cd repo_archive
./ci/test_run_all.sh
env:
FILE_ENV: ${{ matrix.file-env }}

- name: Save Ccache cache
uses: actions/cache/save@v4
if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true'
if: github.event_name != 'pull_request' && github.ref_name == github.event.repository.default_branch && 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
Expand Down Expand Up @@ -212,6 +225,8 @@ jobs:
job-name: 'Windows native, fuzz, VS 2022'

steps:
- *ANNOTATION_PR_NUMBER

- *CHECKOUT

- &SET_UP_VS
Expand Down Expand Up @@ -261,7 +276,7 @@ jobs:

- name: Save vcpkg binary cache
uses: actions/cache/save@v4
if: github.event_name != 'pull_request' && steps.vcpkg-binary-cache.outputs.cache-hit != 'true' && matrix.job-type == 'standard'
if: github.event_name != 'pull_request' && github.ref_name == github.event.repository.default_branch && steps.vcpkg-binary-cache.outputs.cache-hit != 'true' && matrix.job-type == 'standard'
with:
path: ~/AppData/Local/vcpkg/archives
key: ${{ github.job }}-vcpkg-binary-${{ hashFiles('cmake_version', 'msbuild_version', 'toolset_version', 'vcpkg.json') }}
Expand Down Expand Up @@ -329,7 +344,7 @@ jobs:
py -3 test/fuzz/test_runner.py --par $NUMBER_OF_PROCESSORS --loglevel DEBUG "${RUNNER_TEMP}/qa-assets/fuzz_corpora"

windows-cross:
name: 'Linux->Windows cross, no tests'
name: 'Windows-cross to x86_64'
needs: runners
runs-on: ${{ needs.runners.outputs.provider == 'cirrus' && 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-sm' || 'ubuntu-24.04' }}
if: ${{ vars.SKIP_BRANCH_PUSH != 'true' || github.event_name == 'pull_request' }}
Expand All @@ -339,6 +354,8 @@ jobs:
DANGER_CI_ON_HOST_FOLDERS: 1

steps:
- *ANNOTATION_PR_NUMBER

- *CHECKOUT

- name: Configure environment
Expand All @@ -364,6 +381,7 @@ jobs:
with:
name: x86_64-w64-mingw32-executables-${{ github.run_id }}
path: |
${{ env.BASE_BUILD_DIR }}/bin/*.dll
${{ env.BASE_BUILD_DIR }}/bin/*.exe
${{ env.BASE_BUILD_DIR }}/src/secp256k1/bin/*.exe
${{ env.BASE_BUILD_DIR }}/src/univalue/*.exe
Expand All @@ -379,6 +397,8 @@ jobs:
TEST_RUNNER_TIMEOUT_FACTOR: 40

steps:
- *ANNOTATION_PR_NUMBER

- *CHECKOUT

- name: Download built executables
Expand Down Expand Up @@ -459,7 +479,7 @@ jobs:
fail-fast: false
matrix:
include:
- name: '32 bit ARM, unit tests, no functional tests'
- name: '32 bit ARM'
cirrus-runner: 'ubuntu-24.04-arm' # Cirrus' Arm runners are Apple (with virtual Linux aarch64), which doesn't support 32-bit mode
fallback-runner: 'ubuntu-24.04-arm'
timeout-minutes: 120
Expand All @@ -484,13 +504,13 @@ jobs:
timeout-minutes: 120
file-env: './ci/test/00_setup_env_mac_cross_intel.sh'

- name: 'No wallet, libbitcoinkernel'
- name: 'No wallet'
cirrus-runner: 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-sm'
fallback-runner: 'ubuntu-24.04'
timeout-minutes: 120
file-env: './ci/test/00_setup_env_native_nowallet_libbitcoinkernel.sh'
file-env: './ci/test/00_setup_env_native_nowallet.sh'

- name: 'no IPC, i686, DEBUG'
- name: 'i686, no IPC'
cirrus-runner: 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-md'
fallback-runner: 'ubuntu-24.04'
timeout-minutes: 120
Expand All @@ -514,7 +534,7 @@ jobs:
timeout-minutes: 120
file-env: './ci/test/00_setup_env_native_previous_releases.sh'

- name: 'Alpine (musl), depends, gui'
- name: 'Alpine (musl)'
cirrus-runner: 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-md'
fallback-runner: 'ubuntu-24.04'
timeout-minutes: 120
Expand All @@ -526,7 +546,7 @@ jobs:
timeout-minutes: 120
file-env: './ci/test/00_setup_env_native_tidy.sh'

- name: 'TSan, depends, no gui'
- name: 'TSan'
cirrus-runner: 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-md'
fallback-runner: 'ubuntu-24.04'
timeout-minutes: 120
Expand All @@ -538,13 +558,15 @@ jobs:
timeout-minutes: 150
file-env: './ci/test/00_setup_env_native_fuzz_with_msan.sh'

- name: 'MSan, depends'
- name: 'MSan'
cirrus-runner: 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-lg'
fallback-runner: 'ubuntu-24.04'
timeout-minutes: 120
file-env: './ci/test/00_setup_env_native_msan.sh'

steps:
- *ANNOTATION_PR_NUMBER

- *CHECKOUT

- name: Configure environment
Expand Down Expand Up @@ -585,6 +607,8 @@ jobs:
env:
CONTAINER_NAME: "bitcoin-linter"
steps:
- *ANNOTATION_PR_NUMBER

- name: Checkout
uses: actions/checkout@v5
with:
Expand All @@ -597,11 +621,4 @@ jobs:
cache-provider: ${{ needs.runners.outputs.provider }}

- name: CI script
run: |
set -o xtrace
docker buildx build -t "$CONTAINER_NAME" $DOCKER_BUILD_CACHE_ARG --file "./ci/lint_imagefile" .
CIRRUS_PR_FLAG=""
if [ "${{ github.event_name }}" = "pull_request" ]; then
CIRRUS_PR_FLAG="-e CIRRUS_PR=1"
fi
docker run --rm $CIRRUS_PR_FLAG -v "$(pwd)":/bitcoin "$CONTAINER_NAME"
run: python .github/ci-lint-exec.py
13 changes: 0 additions & 13 deletions bitcoinkernel/bitcoin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -623,26 +623,13 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.29)
set(CMAKE_SKIP_TEST_ALL_DEPENDENCY FALSE)
endif()

# TODO: The `CMAKE_SKIP_BUILD_RPATH` variable setting can be deleted
# in the future after reordering Guix script commands to
# perform binary checks after the installation step.
# Relevant discussions:
# - https://github.com/hebasto/bitcoin/pull/236#issuecomment-2183120953
# - https://github.com/bitcoin/bitcoin/pull/30312#issuecomment-2191235833
# NetBSD always requires runtime paths to be set for executables.
if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
else()
set(CMAKE_SKIP_BUILD_RPATH TRUE)
endif()
add_subdirectory(test)
add_subdirectory(doc)

add_subdirectory(src)

include(Maintenance)
setup_split_debug_script()
add_maintenance_targets()
add_windows_deploy_target()
add_macos_deploy_target()

Expand Down
15 changes: 13 additions & 2 deletions bitcoinkernel/bitcoin/ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,19 @@ the CI locally you may need to reduce that entropy by running:
sudo sysctl -w vm.mmap_rnd_bits=28
```

It is recommended to run the ci system in a clean env. To run the test stage
with a specific configuration,
To run a test that requires emulating a CPU architecture different from the
host, we may rely on the container environment recognizing foreign executables
and automatically running them using `qemu`. The following sets us up to do so
(also works for `podman`):

```
docker run --rm --privileged docker.io/multiarch/qemu-user-static --reset -p yes
```

It is recommended to run the CI system in a clean environment. The `env -i`
command below ensures that *only* specified environment variables are propagated
into the local CI.
To run the test stage with a specific configuration:

```
env -i HOME="$HOME" PATH="$PATH" USER="$USER" bash -c 'FILE_ENV="./ci/test/00_setup_env_arm.sh" ./ci/test_run_all.sh'
Expand Down
8 changes: 4 additions & 4 deletions bitcoinkernel/bitcoin/ci/lint/06_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@

export LC_ALL=C

set -ex
set -o errexit -o pipefail -o xtrace

if [ -n "$CIRRUS_PR" ]; then
if [ -n "${LINT_CI_IS_PR}" ]; then
export COMMIT_RANGE="HEAD~..HEAD"
if [ "$(git rev-list -1 HEAD)" != "$(git rev-list -1 --merges HEAD)" ]; then
echo "Error: The top commit must be a merge commit, usually the remote 'pull/${PR_NUMBER}/merge' branch."
echo "Error: The top commit must be a merge commit, usually the remote 'pull/<PR_NUMBER>/merge' branch."
false
fi
fi

RUST_BACKTRACE=1 cargo run --manifest-path "./test/lint/test_runner/Cargo.toml"

if [ "$CIRRUS_REPO_FULL_NAME" = "bitcoin/bitcoin" ] && [ "$CIRRUS_PR" = "" ] ; then
if [ "${LINT_CI_SANITY_CHECK_COMMIT_SIG}" = "1" ] ; then
# Sanity check only the last few commits to get notified of missing sigs,
# missing keys, or expired keys. Usually there is only one new merge commit
# per push on the master branch and a few commits on release branches, so
Expand Down
1 change: 1 addition & 0 deletions bitcoinkernel/bitcoin/ci/test/00_setup_env_arm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export CI_LIMIT_STACK_SIZE=1
# -Wno-psabi is to disable ABI warnings: "note: parameter passing for argument of type ... changed in GCC 7.1"
# This could be removed once the ABI change warning does not show up by default
export BITCOIN_CONFIG=" \
--preset=dev-mode \
-DREDUCE_EXPORTS=ON \
-DCMAKE_CXX_FLAGS='-Wno-psabi -Wno-error=maybe-uninitialized' \
"
2 changes: 2 additions & 0 deletions bitcoinkernel/bitcoin/ci/test/00_setup_env_i686_no_ipc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export GOAL="install"
export CI_LIMIT_STACK_SIZE=1
export TEST_RUNNER_EXTRA="--v2transport --usecli"
export BITCOIN_CONFIG="\
--preset=dev-mode \
-DENABLE_IPC=OFF \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER='clang;-m32' \
-DCMAKE_CXX_COMPILER='clang++;-m32' \
Expand Down
6 changes: 5 additions & 1 deletion bitcoinkernel/bitcoin/ci/test/00_setup_env_mac_cross.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ export XCODE_BUILD_ID=15A240d
export RUN_UNIT_TESTS=false
export RUN_FUNCTIONAL_TESTS=false
export GOAL="deploy"
export BITCOIN_CONFIG="-DBUILD_GUI=ON -DBUILD_KERNEL_LIB=ON -DREDUCE_EXPORTS=ON"
export BITCOIN_CONFIG="\
--preset=dev-mode \
-DWITH_USDT=OFF \
-DREDUCE_EXPORTS=ON \
"
Loading
Loading