Merge bitcoin/bitcoin#31176: ci: Test cross-built Windows executables on Windows natively

25b56fd9b4 ci: Test cross-built Windows executables on Windows natively (Hennadii Stepanov)
3501bca8c7 ci: Move "Windows cross" job from Cirrus CI to GHA CI (Hennadii Stepanov)
f8619196ce ci: Use `bash` by default for all platforms (Hennadii Stepanov)

Pull request description:

  This PR enables on the CI tests of cross-compiled Windows binaries on Windows.

  It is important to have such tests in CI because the release binaries for Windows are also cross-compiled.

  Two functional tests, `wallet_migration.py` and `wallet_multiwallet.py`, are temporarily disabled. They require fixes, such as https://github.com/bitcoin/bitcoin/pull/31410, and adjustments for error message handling. Re-enabling these tests will be addressed in follow-up PRs.

  Resolves https://github.com/bitcoin/bitcoin/issues/31071.

ACKs for top commit:
  davidgumberg:
    tested reACK 25b56fd9b4
  hodlinator:
    re-ACK 25b56fd9b4
  willcl-ark:
    utACK 25b56fd9b4
  maflcko:
    review-only ACK 25b56fd9b4 🍎

Tree-SHA512: fb9150807b7ebb248e8f4fe7b16e5179251e7be9336459287787f27e542583d73d937e6969667fd836378b676bb9be7f66756dc1abca8a01364bc9ee3e3720a5
This commit is contained in:
merge-script 2025-03-31 21:57:34 +08:00
commit 3358b1d105
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1
5 changed files with 130 additions and 54 deletions

View file

@ -124,15 +124,6 @@ task:
env: env:
FILE_ENV: "./ci/test/00_setup_env_arm.sh" FILE_ENV: "./ci/test/00_setup_env_arm.sh"
task:
name: 'Win64-cross'
<< : *GLOBAL_TASK_TEMPLATE
persistent_worker:
labels:
type: small
env:
FILE_ENV: "./ci/test/00_setup_env_win64.sh"
task: task:
name: 'CentOS, depends, gui' name: 'CentOS, depends, gui'
<< : *GLOBAL_TASK_TEMPLATE << : *GLOBAL_TASK_TEMPLATE

View file

@ -21,6 +21,12 @@ env:
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 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' MAKEJOBS: '-j10'
defaults:
run:
# Enforce fail-fast behavior for all platforms.
# See: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
shell: bash
jobs: jobs:
test-each-commit: test-each-commit:
name: 'test each commit' name: 'test each commit'
@ -150,7 +156,7 @@ jobs:
# https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache # https://github.com/actions/cache/blob/main/tips-and-workarounds.md#update-a-cache
key: ${{ github.job }}-${{ matrix.job-type }}-ccache-${{ github.run_id }} key: ${{ github.job }}-${{ matrix.job-type }}-ccache-${{ github.run_id }}
win64-native: windows-native:
name: ${{ matrix.job-name }} name: ${{ matrix.job-name }}
# Use latest image, but hardcode version to avoid silent upgrades (and breaks). # Use latest image, but hardcode version to avoid silent upgrades (and breaks).
# See: https://github.com/actions/runner-images#available-images. # See: https://github.com/actions/runner-images#available-images.
@ -169,10 +175,10 @@ jobs:
include: include:
- job-type: standard - job-type: standard
generate-options: '-DBUILD_GUI=ON -DWITH_BDB=ON -DWITH_ZMQ=ON -DBUILD_BENCH=ON -DWERROR=ON' generate-options: '-DBUILD_GUI=ON -DWITH_BDB=ON -DWITH_ZMQ=ON -DBUILD_BENCH=ON -DWERROR=ON'
job-name: 'Win64 native, VS 2022' job-name: 'Windows native, VS 2022'
- job-type: fuzz - job-type: fuzz
generate-options: '-DVCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON -DVCPKG_MANIFEST_FEATURES="wallet" -DBUILD_GUI=OFF -DBUILD_FOR_FUZZING=ON -DWERROR=ON' generate-options: '-DVCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON -DVCPKG_MANIFEST_FEATURES="wallet" -DBUILD_GUI=OFF -DBUILD_FOR_FUZZING=ON -DWERROR=ON'
job-name: 'Win64 native fuzz, VS 2022' job-name: 'Windows native, fuzz, VS 2022'
steps: steps:
- name: Checkout - name: Checkout
@ -185,6 +191,7 @@ jobs:
arch: x64 arch: x64
- name: Get tool information - name: Get tool information
shell: pwsh
run: | run: |
cmake -version | Tee-Object -FilePath "cmake_version" cmake -version | Tee-Object -FilePath "cmake_version"
Write-Output "---" Write-Output "---"
@ -192,12 +199,12 @@ jobs:
$env:VCToolsVersion | Tee-Object -FilePath "toolset_version" $env:VCToolsVersion | Tee-Object -FilePath "toolset_version"
py -3 --version py -3 --version
Write-Host "PowerShell version $($PSVersionTable.PSVersion.ToString())" Write-Host "PowerShell version $($PSVersionTable.PSVersion.ToString())"
bash --version
- name: Using vcpkg with MSBuild - name: Using vcpkg with MSBuild
run: | run: |
Set-Location "$env:VCPKG_INSTALLATION_ROOT" echo "set(VCPKG_BUILD_TYPE release)" >> "${VCPKG_INSTALLATION_ROOT}/triplets/x64-windows.cmake"
Add-Content -Path "triplets\x64-windows.cmake" -Value "set(VCPKG_BUILD_TYPE release)" echo "set(VCPKG_BUILD_TYPE release)" >> "${VCPKG_INSTALLATION_ROOT}/triplets/x64-windows-static.cmake"
Add-Content -Path "triplets\x64-windows-static.cmake" -Value "set(VCPKG_BUILD_TYPE release)"
- name: vcpkg tools cache - name: vcpkg tools cache
uses: actions/cache@v4 uses: actions/cache@v4
@ -214,7 +221,7 @@ jobs:
- name: Generate build system - name: Generate build system
run: | run: |
cmake -B build --preset vs2022-static -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" ${{ matrix.generate-options }} cmake -B build --preset vs2022-static -DCMAKE_TOOLCHAIN_FILE="${VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" ${{ matrix.generate-options }}
- name: Save vcpkg binary cache - name: Save vcpkg binary cache
uses: actions/cache/save@v4 uses: actions/cache/save@v4
@ -226,13 +233,13 @@ jobs:
- name: Build - name: Build
working-directory: build working-directory: build
run: | run: |
cmake --build . -j $env:NUMBER_OF_PROCESSORS --config Release cmake --build . -j $NUMBER_OF_PROCESSORS --config Release
- name: Run test suite - name: Run test suite
if: matrix.job-type == 'standard' if: matrix.job-type == 'standard'
working-directory: build working-directory: build
run: | run: |
ctest --output-on-failure --stop-on-failure -j $env:NUMBER_OF_PROCESSORS -C Release ctest --output-on-failure --stop-on-failure -j $NUMBER_OF_PROCESSORS -C Release
- name: Run functional tests - name: Run functional tests
if: matrix.job-type == 'standard' if: matrix.job-type == 'standard'
@ -243,15 +250,14 @@ jobs:
BITCOINUTIL: '${{ github.workspace }}\build\bin\Release\bitcoin-util.exe' BITCOINUTIL: '${{ github.workspace }}\build\bin\Release\bitcoin-util.exe'
BITCOINWALLET: '${{ github.workspace }}\build\bin\Release\bitcoin-wallet.exe' BITCOINWALLET: '${{ github.workspace }}\build\bin\Release\bitcoin-wallet.exe'
TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }} TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }}
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}
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%
- name: Clone corpora - name: Clone corpora
if: matrix.job-type == 'fuzz' if: matrix.job-type == 'fuzz'
run: | run: |
git clone --depth=1 https://github.com/bitcoin-core/qa-assets "$env:RUNNER_TEMP\qa-assets" git clone --depth=1 https://github.com/bitcoin-core/qa-assets "${RUNNER_TEMP}/qa-assets"
Set-Location "$env:RUNNER_TEMP\qa-assets" cd "${RUNNER_TEMP}/qa-assets"
Write-Host "Using qa-assets repo from commit ..." echo "Using qa-assets repo from commit ..."
git log -1 git log -1
- name: Run fuzz tests - name: Run fuzz tests
@ -259,9 +265,115 @@ jobs:
working-directory: build working-directory: build
env: env:
BITCOINFUZZ: '${{ github.workspace }}\build\bin\Release\fuzz.exe' BITCOINFUZZ: '${{ github.workspace }}\build\bin\Release\fuzz.exe'
shell: cmd
run: | run: |
py -3 test\fuzz\test_runner.py --par %NUMBER_OF_PROCESSORS% --loglevel DEBUG %RUNNER_TEMP%\qa-assets\fuzz_corpora 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'
runs-on: ubuntu-latest
if: ${{ vars.SKIP_BRANCH_PUSH != 'true' || github.event_name == 'pull_request' }}
env:
FILE_ENV: './ci/test/00_setup_env_win64.sh'
DANGER_CI_ON_HOST_FOLDERS: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set CI directories
run: |
echo "CCACHE_DIR=${{ runner.temp }}/ccache_dir" >> "$GITHUB_ENV"
echo "BASE_ROOT_DIR=${{ runner.temp }}" >> "$GITHUB_ENV"
echo "DEPENDS_DIR=${{ runner.temp }}/depends" >> "$GITHUB_ENV"
echo "BASE_BUILD_DIR=${{ runner.temp }}/build" >> "$GITHUB_ENV"
- name: Depends cache
uses: actions/cache@v4
with:
path: ${{ env.DEPENDS_DIR }}/built
key: ${{ github.job }}-depends-${{ hashFiles('depends/**', 'ci/test/00_setup_env_win64.sh') }}
- 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: 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 }}
key: ${{ github.job }}-ccache-${{ github.run_id }}
- name: Upload built executables
uses: actions/upload-artifact@v4
with:
name: x86_64-w64-mingw32-executables-${{ github.run_id }}
path: |
${{ env.BASE_BUILD_DIR }}/bin/*.exe
${{ env.BASE_BUILD_DIR }}/src/secp256k1/bin/*.exe
${{ env.BASE_BUILD_DIR }}/src/univalue/*.exe
${{ env.BASE_BUILD_DIR }}/test/config.ini
windows-native-test:
name: 'Windows, test cross-built'
runs-on: windows-2022
needs: windows-cross
env:
PYTHONUTF8: 1
TEST_RUNNER_TIMEOUT_FACTOR: 40
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download built executables
uses: actions/download-artifact@v4
with:
name: x86_64-w64-mingw32-executables-${{ github.run_id }}
- name: Run bitcoind.exe
run: ./bin/bitcoind.exe -version
- name: Run unit tests
# Can't use ctest here like other jobs as we don't have a CMake build tree.
run: |
./bin/test_bitcoin.exe -l test_suite
./src/secp256k1/bin/exhaustive_tests.exe
./src/secp256k1/bin/noverify_tests.exe
./src/secp256k1/bin/tests.exe
./src/univalue/object.exe
./src/univalue/unitester.exe
- name: Run benchmarks
run: ./bin/bench_bitcoin.exe -sanity-check -priority-level=high
- name: Adjust paths in test/config.ini
shell: pwsh
run: |
(Get-Content "test/config.ini") -replace '(?<=^SRCDIR=).*', '${{ github.workspace }}' -replace '(?<=^BUILDDIR=).*', '${{ github.workspace }}' -replace '(?<=^RPCAUTH=).*', '${{ github.workspace }}/share/rpcauth/rpcauth.py' | Set-Content "test/config.ini"
Get-Content "test/config.ini"
- name: Run util tests
run: py -3 test/util/test_runner.py
- name: Run rpcauth test
run: py -3 test/util/rpcauth-test.py
- name: Run functional tests
env:
# TODO: Fix the excluded tests and re-enable them.
EXCLUDE: '--exclude wallet_migration.py,wallet_multiwallet.py'
TEST_RUNNER_EXTRA: ${{ github.event_name != 'pull_request' && '--extended' || '' }}
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 $EXCLUDE $TEST_RUNNER_EXTRA
asan-lsan-ubsan-integer-no-depends-usdt: asan-lsan-ubsan-integer-no-depends-usdt:
name: 'ASan + LSan + UBSan + integer, no depends, USDT' name: 'ASan + LSan + UBSan + integer, no depends, USDT'

View file

@ -10,11 +10,8 @@ export CONTAINER_NAME=ci_win64
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:noble" # Check that g++-mingw-w64-x86-64-posix (version 13.2, similar to guix) can cross-compile export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:noble" # Check that g++-mingw-w64-x86-64-posix (version 13.2, similar to guix) can cross-compile
export CI_IMAGE_PLATFORM="linux/amd64" export CI_IMAGE_PLATFORM="linux/amd64"
export HOST=x86_64-w64-mingw32 export HOST=x86_64-w64-mingw32
export DPKG_ADD_ARCH="i386" export PACKAGES="g++-mingw-w64-x86-64-posix nsis"
export PACKAGES="nsis g++-mingw-w64-x86-64-posix wine-binfmt wine64 wine32 file" export RUN_UNIT_TESTS=false
# Install wine, but do not run unit tests, as they surface frequent
# false-positives.
export RUN_UNIT_TESTS=${RUN_UNIT_TESTS:-false}
export RUN_FUNCTIONAL_TESTS=false export RUN_FUNCTIONAL_TESTS=false
export GOAL="deploy" export GOAL="deploy"
export BITCOIN_CONFIG="-DREDUCE_EXPORTS=ON -DBUILD_GUI_TESTS=OFF \ export BITCOIN_CONFIG="-DREDUCE_EXPORTS=ON -DBUILD_GUI_TESTS=OFF \

View file

@ -132,10 +132,6 @@ bash -c "${PRINT_CCACHE_STATISTICS}"
du -sh "${DEPENDS_DIR}"/*/ du -sh "${DEPENDS_DIR}"/*/
du -sh "${PREVIOUS_RELEASES_DIR}" du -sh "${PREVIOUS_RELEASES_DIR}"
if [[ $HOST = *-mingw32 ]]; then
"${BASE_ROOT_DIR}/ci/test/wrap-wine.sh"
fi
if [ -n "$USE_VALGRIND" ]; then if [ -n "$USE_VALGRIND" ]; then
"${BASE_ROOT_DIR}/ci/test/wrap-valgrind.sh" "${BASE_ROOT_DIR}/ci/test/wrap-valgrind.sh"
fi fi

View file

@ -1,20 +0,0 @@
#!/usr/bin/env bash
#
# Copyright (c) 2020-2022 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
export LC_ALL=C.UTF-8
for b_name in {"${BASE_OUTDIR}/bin"/*,src/univalue/{test_json,unitester,object}}.exe; do
# shellcheck disable=SC2044
for b in $(find "${BASE_ROOT_DIR}" -executable -type f -name "$(basename "$b_name")"); do
if (file "$b" | grep "Windows"); then
echo "Wrap $b ..."
mv "$b" "${b}_orig"
echo '#!/usr/bin/env bash' > "$b"
echo "( wine \"${b}_orig\" \"\$@\" ) || ( sleep 1 && wine \"${b}_orig\" \"\$@\" )" >> "$b"
chmod +x "$b"
fi
done
done