Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: Add a native build job on Ubuntu 20.04 + CMake 3.16 #64

Merged
merged 5 commits into from
Dec 15, 2023
Merged
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
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something that comes with the github actions image? I do not have this package when I do:

docker pull ubuntu:20.04
docker run -ti --rm ubuntu:20.04 /bin/bash

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something that comes with the github actions image?

It is.


- 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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be a warning or something if there is no PYTHON_COMMAND?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Added.

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