Skip to content

Commit

Permalink
Merge #64: cmake: Add a native build job on Ubuntu 20.04 + CMake 3.16
Browse files Browse the repository at this point in the history
53cb2c8 fixup! ci: Test CMake edge cases (Hennadii Stepanov)
343e92a fixup! ci: Test CMake edge cases (Hennadii Stepanov)
9e92156 fixup! ci: Test CMake edge cases (Hennadii Stepanov)
ffe035f fixup! ci: Test CMake edge cases (Hennadii Stepanov)
097f84f fixup! cmake: Include CTest (Hennadii Stepanov)

Pull request description:

  This PR:
  1. Adds a CI job that uses the minimum required CMake 3.16 and tests the `ALLOW_HOST_PACKAGES` depends feature.
  2. Fixes tests when Pyrhon is not available.

ACKs for top commit:
  TheCharlatan:
    ACK 53cb2c8

Tree-SHA512: 0cbfd9c70ae610e6b0652c26b2ac204d0f3cb3f9f9585a882a598008b88c633186cef1605fb61e516197349e1d68daa3bc3685d983bfccab41525f5f84128c1a
  • Loading branch information
hebasto committed Dec 15, 2023
2 parents 1958b54 + 53cb2c8 commit af3ac22
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 11 deletions.
66 changes: 62 additions & 4 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

name: CMake
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.
# Running for pushes is enough in the cmake-staging branch.
# pull_request:
push:
branches:
- '**'
Expand Down Expand Up @@ -80,6 +79,53 @@ jobs:
diff -u src/obj/build.h build/src/obj/build.h
ubuntu-focal-native:
name: 'Ubuntu 20.04, CMake 3.16, Boost from depends'
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Remove preinstalled CMake
run: |
sudo rm /usr/local/bin/cmake /usr/local/bin/ctest
- name: Install packages
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends curl g++10 cmake libevent-dev libsqlite3-dev libdb-dev libdb++-dev libminiupnpc-dev libnatpmp-dev libzmq3-dev systemtap-sdt-dev
- name: CMake version
run: |
cmake --version
ctest --version
- name: Build Boost in depends
working-directory: ./depends
run: |
make -j $(nproc) NO_LIBEVENT=1 NO_QT=1 NO_WALLET=1 NO_NATPMP=1 NO_UPNP=1 NO_ZMQ=1 NO_USDT=1 ALLOW_HOST_PACKAGES=1 CC=gcc-10 CXX=g++-10
- name: Generate build system
run: |
cmake -B build -DCMAKE_TOOLCHAIN_FILE=depends/x86_64-pc-linux-gnu/share/toolchain.cmake -DENABLE_WALLET=ON -DWITH_NATPMP=ON -DWITH_MINIUPNPC=ON -DWITH_ZMQ=ON -DWITH_USDT=ON -DWERROR=ON
- name: Build
working-directory: ./build
run: |
cmake --build . -j $(nproc)
- name: Test
working-directory: ./build
run: |
ctest -j $(nproc)
- name: Install
run: |
cmake --install build --prefix install
tree install
cross-build:
name: ${{ matrix.host.name }}
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -156,10 +202,15 @@ jobs:
path: ${{ env.CCACHE_DIR }}
key: ${{ matrix.host.triplet }}-ccache-${{ github.run_id }}

- name: Check
- name: Test
run: |
ctest --test-dir build -j $(nproc)
- name: Install
run: |
cmake --install build --prefix install
tree install
win64-native-builtin-tools:
name: 'Win64 native, VS 2022, built-in tools'
Expand Down Expand Up @@ -196,6 +247,7 @@ jobs:
- name: Restore vcpkg binary cache
uses: actions/cache/restore@v3
id: vcpkg-binary-cache
with:
path: ~/AppData/Local/vcpkg/archives
key: ${{ runner.os }}-${{ runner.arch }}-vcpkg-binary-${{ hashFiles('cmake_version', 'msbuild_version', 'toolset_version', 'vcpkg.json') }}
Expand All @@ -206,6 +258,7 @@ jobs:
- name: Save vcpkg binary cache
uses: actions/cache/save@v3
if: github.event_name != 'pull_request' && steps.vcpkg-binary-cache.outputs.cache-hit != 'true'
with:
path: ~/AppData/Local/vcpkg/archives
key: ${{ runner.os }}-${{ runner.arch }}-vcpkg-binary-${{ hashFiles('cmake_version', 'msbuild_version', 'toolset_version', 'vcpkg.json') }}
Expand All @@ -217,3 +270,8 @@ jobs:
- name: Test Release configuration
run: |
ctest --test-dir build -j $env:NUMBER_OF_PROCESSORS -C Release
- name: Install Release configuration
run: |
cmake --install build --prefix install --config Release
tree /f install
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,13 @@ if(WERROR)
endif()

find_package(Python3 3.9 COMPONENTS Interpreter)
set(PYTHON_COMMAND ${Python3_EXECUTABLE})
if(Python3_EXECUTABLE)
set(PYTHON_COMMAND ${Python3_EXECUTABLE})
else()
list(APPEND configure_warnings
"Minimum required Python not found. Utils and rpcauth tests are disabled."
)
endif()

add_subdirectory(src)
add_subdirectory(test)
Expand Down
14 changes: 8 additions & 6 deletions cmake/tests.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# Copyright (c) 2023 The Bitcoin Core developers
# Copyright (c) 2023-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# file COPYING or https://opensource.org/license/mit/.

include(CTest)

if(TARGET bitcoin-util AND TARGET bitcoin-tx)
if(TARGET bitcoin-util AND TARGET bitcoin-tx AND PYTHON_COMMAND)
add_test(NAME util_test_runner
COMMAND ${CMAKE_COMMAND} -E env BITCOINUTIL=$<TARGET_FILE:bitcoin-util> BITCOINTX=$<TARGET_FILE:bitcoin-tx> ${PYTHON_COMMAND} ${CMAKE_BINARY_DIR}/test/util/test_runner.py
)
endif()

add_test(NAME util_rpcauth_test
COMMAND ${PYTHON_COMMAND} ${CMAKE_BINARY_DIR}/test/util/rpcauth-test.py
)
if(PYTHON_COMMAND)
add_test(NAME util_rpcauth_test
COMMAND ${PYTHON_COMMAND} ${CMAKE_BINARY_DIR}/test/util/rpcauth-test.py
)
endif()

if(TARGET bench_bitcoin)
add_test(NAME bench_sanity_check_high_priority
Expand Down

0 comments on commit af3ac22

Please sign in to comment.