diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index a2c9f2f623..451d705b68 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -2,10 +2,6 @@ name: Unit Tests on: [push, pull_request] -env: - RELEASE: 0 - artifact: 0 - jobs: macos_test: name: macOS [${{ matrix.BACKEND }}] @@ -17,8 +13,9 @@ jobs: - ${{ startsWith(github.ref, 'refs/tags/') }} env: BACKEND: ${{ matrix.BACKEND }} - TEST_USE_ROCKSDB: ${{ matrix.BACKEND == 'rocksdb' && '1' || '0' }} RELEASE: ${{ matrix.RELEASE }} + TEST_USE_ROCKSDB: ${{ matrix.BACKEND == 'rocksdb' && '1' || '0' }} + DEADLINE_SCALE_FACTOR: ${{ matrix.BACKEND == 'rocksdb' && '2' || '1' }} runs-on: macos-12 if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository steps: @@ -26,7 +23,7 @@ jobs: uses: actions/checkout@v3 with: submodules: "recursive" - fetch-depth: 0 # full history needed for restoring file timestamps + fetch-depth: 0 # Full history needed for restoring file timestamps - name: Restore Timestamps uses: ./.github/actions/restore-git-mtimes @@ -39,14 +36,15 @@ jobs: path: build key: ${{ runner.os }}-build-cache - - name: Fetch Deps - run: TEST=1 ci/actions/osx/install_deps.sh + - name: Prepare + run: ci/prepare/macos/prepare.sh - name: Build Tests - run: ci/build-ci.sh "/tmp/qt/lib/cmake/Qt5"; + id: build + run: ci/build-tests.sh - name: Save Build Cache - # only save build cache from develop to avoid polluting it by other branches / PRs + # Only save build cache from develop to avoid polluting it by other branches / PRs if: github.ref == 'refs/heads/develop' && success() uses: actions/cache/save@v3 continue-on-error: true @@ -54,10 +52,17 @@ jobs: path: build key: ${{ runner.os }}-build-cache - - name: Run Tests - run: cd build && sudo TEST_USE_ROCKSDB=$TEST_USE_ROCKSDB ../ci/test.sh . - env: - DEADLINE_SCALE_FACTOR: ${{ env.TEST_USE_ROCKSDB == 1 && '2' || '1' }} + - name: Core Tests + if: steps.build.outcome == 'success' && (success() || failure()) + run: cd build && ../ci/tests/run-core-tests.sh + + - name: RPC Tests + if: steps.build.outcome == 'success' && (success() || failure()) + run: cd build && ../ci/tests/run-rpc-tests.sh + + - name: System Tests + if: steps.build.outcome == 'success' && (success() || failure()) + run: cd build && ../ci/tests/run-system-tests.sh linux_test: name: Linux [${{ matrix.BACKEND }} | ${{ matrix.COMPILER }}] @@ -73,15 +78,16 @@ jobs: env: COMPILER: ${{ matrix.COMPILER }} BACKEND: ${{ matrix.BACKEND }} - TEST_USE_ROCKSDB: ${{ matrix.BACKEND == 'rocksdb' && '1' || '0' }} RELEASE: ${{ matrix.RELEASE }} + TEST_USE_ROCKSDB: ${{ matrix.BACKEND == 'rocksdb' && '1' || '0' }} + DEADLINE_SCALE_FACTOR: ${{ matrix.BACKEND == 'rocksdb' && '2' || '1' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository steps: - name: Checkout uses: actions/checkout@v3 with: submodules: "recursive" - fetch-depth: 0 # full history needed for restoring file timestamps + fetch-depth: 0 # Full history needed for restoring file timestamps - name: Restore Timestamps uses: ./.github/actions/restore-git-mtimes @@ -94,14 +100,15 @@ jobs: path: build key: ${{ runner.os }}-${{ env.COMPILER }}-build-cache - - name: Fetch Deps - run: ci/actions/linux/install_deps.sh + - name: Prepare + run: sudo -E ci/prepare/linux/prepare.sh - name: Build Tests - run: docker run -e TEST_USE_ROCKSDB -e RELEASE -v ${PWD}:/workspace nanocurrency/nano-env:${{ matrix.COMPILER }} /bin/bash -c "cd /workspace && ./ci/build-ci.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5" + id: build + run: ci/build-tests.sh - name: Save Build Cache - # only save build cache from develop to avoid polluting it by other branches / PRs + # Only save build cache from develop to avoid polluting it by other branches / PRs if: github.ref == 'refs/heads/develop' && success() uses: actions/cache/save@v3 continue-on-error: true @@ -109,10 +116,21 @@ jobs: path: build key: ${{ runner.os }}-${{ env.COMPILER }}-build-cache - - name: Run Tests - run: docker run -e RELEASE -e TEST_USE_ROCKSDB -e DEADLINE_SCALE_FACTOR -v ${PWD}:/workspace nanocurrency/nano-env:${{ matrix.COMPILER }} /bin/bash -c "cd /workspace/build && ../ci/test.sh ." - env: - DEADLINE_SCALE_FACTOR: ${{ env.TEST_USE_ROCKSDB == 1 && '2' || '1' }} + - name: Core Tests + if: steps.build.outcome == 'success' && (success() || failure()) + run: cd build && ../ci/tests/run-core-tests.sh + + - name: RPC Tests + if: steps.build.outcome == 'success' && (success() || failure()) + run: cd build && ../ci/tests/run-rpc-tests.sh + + - name: System Tests + if: steps.build.outcome == 'success' && (success() || failure()) + run: cd build && ../ci/tests/run-system-tests.sh + + - name: QT Tests + if: steps.build.outcome == 'success' && (success() || failure()) + run: cd build && ../ci/tests/run-qt-tests.sh windows_test: name: Windows [${{ matrix.BACKEND }}] @@ -126,8 +144,8 @@ jobs: runs-on: windows-latest env: BACKEND: ${{ matrix.BACKEND }} - TEST_USE_ROCKSDB: ${{ matrix.BACKEND == 'rocksdb' && '1' || '0' }} RELEASE: ${{ matrix.RELEASE }} + TEST_USE_ROCKSDB: ${{ matrix.BACKEND == 'rocksdb' && '1' || '0' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository steps: - name: Checkout @@ -147,14 +165,13 @@ jobs: path: build key: ${{ runner.os }}-build-cache - - name: Windows Defender - run: ci/actions/windows/disable_windows_defender.ps1 - - - name: Fetch Deps - run: ci/actions/windows/install_deps.ps1 + - name: Prepare + run: ci/prepare/windows/prepare.ps1 - name: Build Tests - run: ci/actions/windows/build.ps1 + id: build + run: ci/build-tests.sh + shell: bash - name: Save Build Cache # only save build cache from develop to avoid polluting it by other branches / PRs @@ -165,7 +182,17 @@ jobs: path: build key: ${{ runner.os }}-build-cache - - name: Run Tests [TEST_USE_ROCKSDB=${{ env.TEST_USE_ROCKSDB }}] - run: ci/actions/windows/run.ps1 - env: - DEADLINE_SCALE_FACTOR: ${{ env.TEST_USE_ROCKSDB == 1 && '2' || '1' }} + - name: Core Tests + if: steps.build.outcome == 'success' && (success() || failure()) + run: cd build && ../ci/tests/run-core-tests.sh + shell: bash + + - name: RPC Tests + if: steps.build.outcome == 'success' && (success() || failure()) + run: cd build && ../ci/tests/run-rpc-tests.sh + shell: bash + + - name: System Tests + if: steps.build.outcome == 'success' && (success() || failure()) + run: cd build && ../ci/tests/run-system-tests.sh + shell: bash \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index c3b800d77e..162b33d5c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,10 +34,6 @@ if(COVERAGE) include(CoverageTest) endif() -set(CI_TEST - 0 - CACHE STRING "") - if(MSVC) add_definitions(/MP) endif() @@ -67,6 +63,8 @@ endif() # Create all libraries and executables in the root binary dir set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}) set(NANO_GUI OFF @@ -658,6 +656,12 @@ add_subdirectory(nano/nano_node) add_subdirectory(nano/rpc) add_subdirectory(nano/nano_rpc) +add_custom_target( + executables + COMMAND echo "BATCH BUILDING node + rpc" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + DEPENDS nano_node nano_rpc) + if(NANO_FUZZER_TEST) if(NOT WIN32) add_subdirectory(nano/fuzzer_test) @@ -696,15 +700,10 @@ if(NANO_TEST OR RAIBLOCKS_TEST) add_subdirectory(nano/rpc_test) add_subdirectory(nano/slow_test) add_custom_target( - build_tests + all_tests COMMAND echo "BATCH BUILDING TESTS" WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - DEPENDS core_test load_test rpc_test nano_node nano_rpc) - add_custom_target( - run_tests - COMMAND ${PROJECT_SOURCE_DIR}/ci/test.sh ${CMAKE_BINARY_DIR} - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - DEPENDS build_tests) + DEPENDS core_test load_test rpc_test slow_test nano_node nano_rpc) endif() if(NANO_TEST OR RAIBLOCKS_TEST) @@ -809,7 +808,7 @@ if(NANO_GUI OR RAIBLOCKS_GUI) set_target_properties( qt_test PROPERTIES COMPILE_FLAGS "-DQT_NO_KEYWORDS -DBOOST_ASIO_HAS_STD_ARRAY=1") - add_dependencies(build_tests qt_test) + add_dependencies(all_tests qt_test) endif() if(APPLE) diff --git a/ci/actions/windows/build.ps1 b/ci/actions/windows/build.ps1 index b984534ea3..af867129c5 100644 --- a/ci/actions/windows/build.ps1 +++ b/ci/actions/windows/build.ps1 @@ -31,7 +31,6 @@ else { } $env:NETWORK_CFG = "dev" $env:NANO_TEST = "-DNANO_TEST=ON" - $env:CI = '-DCI_TEST="1"' $env:RUN = "test" } diff --git a/ci/build-ci.sh b/ci/build-ci.sh index 39d4259e20..f03b00c9df 100755 --- a/ci/build-ci.sh +++ b/ci/build-ci.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -euo pipefail qt_dir=${1} build_target=${2:-all} @@ -47,7 +48,6 @@ cmake \ -DNANO_WARN_TO_ERR=ON \ -DCMAKE_BUILD_TYPE=${BUILD_TYPE:-Debug} \ -DQt5_DIR=${qt_dir} \ --DCI_TEST="1" \ ${BACKTRACE:-} \ ${SANITIZERS:-} \ .. diff --git a/ci/build-node.sh b/ci/build-node.sh new file mode 100755 index 0000000000..6cebd1fbe5 --- /dev/null +++ b/ci/build-node.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -euox pipefail + +$(dirname "$BASH_SOURCE")/build.sh executables \ No newline at end of file diff --git a/ci/build-tests.sh b/ci/build-tests.sh new file mode 100755 index 0000000000..c916ba4411 --- /dev/null +++ b/ci/build-tests.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -euox pipefail + +BUILD_TYPE="Debug" +if [[ "${RELEASE:-false}" == "true" ]]; then + BUILD_TYPE="RelWithDebInfo" +fi + +BUILD_TYPE=$BUILD_TYPE \ +NANO_TEST=ON \ +NANO_NETWORK=dev \ +NANO_GUI=ON \ +$(dirname "$BASH_SOURCE")/build.sh all_tests \ No newline at end of file diff --git a/ci/build.sh b/ci/build.sh new file mode 100755 index 0000000000..a238241022 --- /dev/null +++ b/ci/build.sh @@ -0,0 +1,93 @@ +#!/bin/bash +set -euox pipefail + +BUILD_TARGET="" +if [[ ${1:-} ]]; then + BUILD_TARGET="--target $1" +fi + +SRC=${SRC:-${PWD}} +OS=$(uname) + +CMAKE_BACKTRACE="" +if [[ "$OS" == 'Linux' ]]; then + CMAKE_BACKTRACE="-DNANO_STACKTRACE_BACKTRACE=ON" + + if [[ "$COMPILER" == 'clang' ]]; then + CMAKE_BACKTRACE="${CMAKE_BACKTRACE} -DNANO_BACKTRACE_INCLUDE=" + fi +fi + +CMAKE_QT_DIR="" +if [[ ${QT_DIR:-} ]]; then + CMAKE_QT_DIR="-DQt5_DIR=${QT_DIR}" +fi + +CMAKE_SANITIZER="" +if [[ ${SANITIZER:-} ]]; then + case "${SANITIZER}" in + ASAN) + CMAKE_SANITIZER="-DNANO_ASAN=ON" + ;; + ASAN_INT) + CMAKE_SANITIZER="-DNANO_ASAN_INT=ON" + ;; + TSAN) + CMAKE_SANITIZER="-DNANO_TSAN=ON" + ;; + *) + echo "Unknown sanitizer: '${SANITIZER}'" + exit 1 + ;; + esac +fi + +BUILD_DIR="build" + +mkdir -p $BUILD_DIR +pushd $BUILD_DIR + +cmake \ +-DCMAKE_BUILD_TYPE=${BUILD_TYPE:-"Debug"} \ +-DPORTABLE=ON \ +-DACTIVE_NETWORK=nano_${NANO_NETWORK:-"live"}_network \ +-DNANO_TEST=${NANO_TEST:-OFF} \ +-DNANO_GUI=${NANO_GUI:-OFF} \ +-DCOVERAGE=${COVERAGE:-OFF} \ +${CMAKE_SANITIZER:-} \ +${CMAKE_QT_DIR:-} \ +${CMAKE_BACKTRACE:-} \ +${SRC} + +number_of_processors() { + case "$(uname -s)" in + Linux*) + nproc + ;; + Darwin*) + sysctl -n hw.ncpu + ;; + CYGWIN*|MINGW32*|MSYS*|MINGW*) + echo "${NUMBER_OF_PROCESSORS}" + ;; + *) + echo "Unknown OS" + exit 1 + ;; + esac +} + +parallel_build_flag() { + case "$(uname -s)" in + CYGWIN*|MINGW32*|MSYS*|MINGW*) + echo "-- -m" + ;; + *) + echo "--parallel $(number_of_processors)" + ;; + esac +} + +cmake --build ${PWD} ${BUILD_TARGET} $(parallel_build_flag) + +popd \ No newline at end of file diff --git a/ci/prepare/linux/prepare-clang.sh b/ci/prepare/linux/prepare-clang.sh new file mode 100755 index 0000000000..f11b7050a1 --- /dev/null +++ b/ci/prepare/linux/prepare-clang.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -euo pipefail + +apt-get update -qq && apt-get install -yqq \ +clang \ +lldb + +export CXX=/usr/bin/clang++ +export CC=/usr/bin/clang +update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100 +update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100 + +# workaround to get a path that can be easily passed into cmake for +# BOOST_STACKTRACE_BACKTRACE_INCLUDE_FILE +# see https://www.boost.org/doc/libs/1_70_0/doc/html/stacktrace/configuration_and_build.html#stacktrace.configuration_and_build.f3 + +backtrace_file=$(find /usr/lib/gcc/ -name 'backtrace.h' | head -n 1) && test -f $backtrace_file && ln -s $backtrace_file /tmp/backtrace.h \ No newline at end of file diff --git a/ci/prepare/linux/prepare-gcc.sh b/ci/prepare/linux/prepare-gcc.sh new file mode 100755 index 0000000000..2a9b97a5a3 --- /dev/null +++ b/ci/prepare/linux/prepare-gcc.sh @@ -0,0 +1,2 @@ +#!/bin/bash +set -euo pipefail \ No newline at end of file diff --git a/ci/prepare/linux/prepare.sh b/ci/prepare/linux/prepare.sh new file mode 100755 index 0000000000..2ed1a8f545 --- /dev/null +++ b/ci/prepare/linux/prepare.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -euox pipefail + +COMPILER=${COMPILER:-gcc} + +echo "Compiler: '${COMPILER}'" + +# Common dependencies needed for building & testing +apt-get update -qq + +DEBIAN_FRONTEND=noninteractive apt-get install -yqq \ +build-essential \ +g++ \ +wget \ +python3 \ +zlib1g-dev \ +cmake \ +git \ +qtbase5-dev \ +qtchooser \ +qt5-qmake \ +qtbase5-dev-tools \ +valgrind \ +xorg xvfb xauth xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic + +# Compiler specific setup +$(dirname "$BASH_SOURCE")/prepare-${COMPILER}.sh \ No newline at end of file diff --git a/ci/prepare/macos/prepare.sh b/ci/prepare/macos/prepare.sh new file mode 100755 index 0000000000..5ca21a9b82 --- /dev/null +++ b/ci/prepare/macos/prepare.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -euox pipefail + +brew update +brew install coreutils + +brew install qt@5 +brew link qt@5 + +# Workaround: https://github.com/Homebrew/homebrew-core/issues/8392 +echo "$(brew --prefix qt5)/bin" >> $GITHUB_PATH \ No newline at end of file diff --git a/ci/prepare/windows/disable-defender.ps1 b/ci/prepare/windows/disable-defender.ps1 new file mode 100644 index 0000000000..dcb1434c4a --- /dev/null +++ b/ci/prepare/windows/disable-defender.ps1 @@ -0,0 +1,5 @@ +$ErrorActionPreference = "Continue" + +Set-MpPreference -DisableArchiveScanning $true +Set-MpPreference -DisableRealtimeMonitoring $true +Set-MpPreference -DisableBehaviorMonitoring $true \ No newline at end of file diff --git a/ci/prepare/windows/install-qt.ps1 b/ci/prepare/windows/install-qt.ps1 new file mode 100644 index 0000000000..ac293592bd --- /dev/null +++ b/ci/prepare/windows/install-qt.ps1 @@ -0,0 +1,45 @@ +$ErrorActionPreference = "Stop" + +# Download and extract Qt library. +# Original files can be found at: https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5152/qt.qt5.5152.win64_msvc2019_64/ + +# Define URLs, file names and their corresponding SHA1 hashes +$toDownload = @( + @{ + Url = 'https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5152/qt.qt5.5152.win64_msvc2019_64/5.15.2-0-202011130602qtbase-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64.7z'; + FileName = 'qt5base.7z'; + SHA1 = 'e29464430a2225bce6ce96b4ed18eec3f8b944d6'; + }, + @{ + Url = 'https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_5152/qt.qt5.5152.win64_msvc2019_64/5.15.2-0-202011130602qtwinextras-Windows-Windows_10-MSVC2019-Windows-Windows_10-X86_64.7z'; + FileName = 'qt5winextra.7z'; + SHA1 = '70da33b18ddeac4dd00ceed205f8110c426cea16'; + } +) + +$targetFolder = "C:\Qt" + +# Download and process files +foreach ($entry in $toDownload) { + $tempFile = Join-Path $env:TEMP $entry.FileName + + # Download file + Invoke-WebRequest -Uri $entry.Url -OutFile $tempFile + + # Calculate file hash + $fileHash = (Get-FileHash -Path $tempFile -Algorithm SHA1).Hash + + # Compare hashes + if ($fileHash -eq $entry.SHA1) { + Write-Host "Hashes match for $($entry.FileName)." + } else { + Write-Error "Hashes do not match for $($entry.FileName). Stopping script execution." + exit 1 + } + + # Decompress archive + 7z x $tempFile -o"$targetFolder" -aoa +} + +# Save install location for subsequent steps +"QT_DIR=C:\Qt\5.15.2\msvc2019_64\lib\cmake\Qt5" >> $env:GITHUB_ENV \ No newline at end of file diff --git a/ci/prepare/windows/prepare.ps1 b/ci/prepare/windows/prepare.ps1 new file mode 100644 index 0000000000..7ed8f7e7ab --- /dev/null +++ b/ci/prepare/windows/prepare.ps1 @@ -0,0 +1,4 @@ +$ErrorActionPreference = "Stop" + +& "$PSScriptRoot\disable-defender.ps1" +& "$PSScriptRoot\install-qt.ps1" \ No newline at end of file diff --git a/ci/tests/common.sh b/ci/tests/common.sh new file mode 100644 index 0000000000..03d464a1ad --- /dev/null +++ b/ci/tests/common.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +get_exec_extension() { + case "$(uname -s)" in + Linux*|Darwin*) + echo "" + ;; + CYGWIN*|MINGW32*|MSYS*|MINGW*) + echo ".exe" + ;; + *) + echo "Unknown OS" + exit 1 + ;; + esac +} \ No newline at end of file diff --git a/ci/tests/run-core-tests.sh b/ci/tests/run-core-tests.sh new file mode 100755 index 0000000000..a3e02b70bf --- /dev/null +++ b/ci/tests/run-core-tests.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -euo pipefail + +source "$(dirname "$BASH_SOURCE")/common.sh" + +BUILD_DIR=${1-${PWD}} + +${BUILD_DIR}/core_test$(get_exec_extension) \ No newline at end of file diff --git a/ci/tests/run-qt-tests.sh b/ci/tests/run-qt-tests.sh new file mode 100755 index 0000000000..8faa28d43a --- /dev/null +++ b/ci/tests/run-qt-tests.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -euo pipefail + +source "$(dirname "$BASH_SOURCE")/common.sh" + +BUILD_DIR=${1-${PWD}} + +# Alpine doesn't offer an xvfb +xvfb_run_() +{ + INIT_DELAY_SEC=3 + + Xvfb :2 -screen 0 1024x768x24 & + xvfb_pid=$! + sleep ${INIT_DELAY_SEC} + DISPLAY=:2 $@ + res=${?} + kill ${xvfb_pid} + + return ${res} +} + +xvfb_run_ ${BUILD_DIR}/qt_test$(get_exec_extension) \ No newline at end of file diff --git a/ci/tests/run-rpc-tests.sh b/ci/tests/run-rpc-tests.sh new file mode 100755 index 0000000000..6b64607d95 --- /dev/null +++ b/ci/tests/run-rpc-tests.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -euo pipefail + +source "$(dirname "$BASH_SOURCE")/common.sh" + +BUILD_DIR=${1-${PWD}} + +${BUILD_DIR}/rpc_test$(get_exec_extension) \ No newline at end of file diff --git a/ci/tests/run-system-tests.sh b/ci/tests/run-system-tests.sh new file mode 100755 index 0000000000..e5e5394536 --- /dev/null +++ b/ci/tests/run-system-tests.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -euo pipefail + +source "$(dirname "$BASH_SOURCE")/common.sh" + +BUILD_DIR=${1-${PWD}} + +export NANO_NODE_EXE=${BUILD_DIR}/nano_node$(get_exec_extension) +cd ../systest && ./RUNALL \ No newline at end of file diff --git a/docker/node/Dockerfile b/docker/node/Dockerfile index cb409594aa..ec0ea85663 100644 --- a/docker/node/Dockerfile +++ b/docker/node/Dockerfile @@ -1,37 +1,32 @@ -ARG ENV_REPOSITORY=nanocurrency/nano-env -ARG COMPILER=gcc -FROM ${ENV_REPOSITORY}:${COMPILER} +FROM ubuntu:22.04 as builder -ARG NETWORK=live +ARG COMPILER=gcc +ARG NANO_NETWORK=live ARG CI_TAG=DEV_BUILD ARG CI_BUILD=OFF ARG CI_VERSION_PRE_RELEASE=OFF -ADD ./ /tmp/src -WORKDIR /tmp/build +# Install build dependencies +COPY ./ci/prepare/linux /tmp/prepare +RUN /tmp/prepare/prepare.sh -RUN \ -cmake /tmp/src \ --DCI_BUILD=${CI_BUILD} \ --DCI_VERSION_PRE_RELEASE=${CI_VERSION_PRE_RELEASE} \ --DPORTABLE=1 \ --DACTIVE_NETWORK=nano_${NETWORK}_network +COPY ./ /tmp/src +WORKDIR /tmp/src -RUN \ -make nano_node -j $(nproc) && \ -make nano_rpc -j $(nproc) && \ -cd .. && \ -echo ${NETWORK} >/etc/nano-network +# Build node +RUN ci/build-node.sh +RUN echo ${NANO_NETWORK} >/etc/nano-network FROM ubuntu:22.04 RUN groupadd --gid 1000 nanocurrency && \ useradd --uid 1000 --gid nanocurrency --shell /bin/bash --create-home nanocurrency -COPY --from=0 /tmp/build/nano_node /usr/bin -COPY --from=0 /tmp/build/nano_rpc /usr/bin -COPY --from=0 /tmp/src/api/ /usr/bin/api/ -COPY --from=0 /etc/nano-network /etc +COPY --from=builder /tmp/src/build/nano_node /usr/bin +COPY --from=builder /tmp/src/build/nano_rpc /usr/bin +COPY --from=builder /tmp/src/api/ /usr/bin/api/ +COPY --from=builder /etc/nano-network /etc + COPY docker/node/entry.sh /usr/bin/entry.sh COPY docker/node/config /usr/share/nano/config RUN chmod +x /usr/bin/entry.sh @@ -44,5 +39,6 @@ USER root ENV PATH="${PATH}:/usr/bin" ENTRYPOINT ["/usr/bin/entry.sh"] CMD ["nano_node", "daemon", "-l"] + ARG REPOSITORY=nanocurrency/nano-node LABEL org.opencontainers.image.source https://github.com/$REPOSITORY diff --git a/nano/core_test/CMakeLists.txt b/nano/core_test/CMakeLists.txt index aa5a123d04..f2aae4d263 100644 --- a/nano/core_test/CMakeLists.txt +++ b/nano/core_test/CMakeLists.txt @@ -61,7 +61,7 @@ add_executable( target_compile_definitions( core_test PRIVATE -DTAG_VERSION_STRING=${TAG_VERSION_STRING} - -DGIT_COMMIT_HASH=${GIT_COMMIT_HASH} -DCI=${CI_TEST}) + -DGIT_COMMIT_HASH=${GIT_COMMIT_HASH}) target_link_libraries( core_test diff --git a/nano/core_test/network.cpp b/nano/core_test/network.cpp index 227be9a8b8..55efe9355b 100644 --- a/nano/core_test/network.cpp +++ b/nano/core_test/network.cpp @@ -1014,7 +1014,7 @@ TEST (network, tcp_message_manager) // This should give sufficient time to execute put_message // and prove that it waits on condition variable - std::this_thread::sleep_for (CI ? 200ms : 100ms); + std::this_thread::sleep_for (200ms); ASSERT_EQ (manager.entries.size (), manager.max_entries); ASSERT_EQ (manager.get_message ().node_id, item.node_id); diff --git a/nano/lib/CMakeLists.txt b/nano/lib/CMakeLists.txt index 53cbc27c54..2002406120 100644 --- a/nano/lib/CMakeLists.txt +++ b/nano/lib/CMakeLists.txt @@ -124,5 +124,4 @@ target_compile_definitions( -DMINOR_VERSION_STRING=${CPACK_PACKAGE_VERSION_MINOR} -DPATCH_VERSION_STRING=${CPACK_PACKAGE_VERSION_PATCH} -DPRE_RELEASE_VERSION_STRING=${CPACK_PACKAGE_VERSION_PRE_RELEASE} - -DCI=${CI_TEST} PUBLIC -DACTIVE_NETWORK=${ACTIVE_NETWORK})