From c95ce74c6027080e184a2004f486c11dbb7ca618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Thu, 20 Apr 2023 23:45:13 +0200 Subject: [PATCH 01/15] Fail early in `build-ci` script --- ci/build-ci.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/build-ci.sh b/ci/build-ci.sh index 39d4259e20..eee9cece28 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} From 80a794f3751378dece820543ef051ae25ddf5dfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Thu, 20 Apr 2023 23:58:26 +0200 Subject: [PATCH 02/15] Separate test actions --- .github/workflows/unit_tests.yml | 47 +++++++++++++++++++------------- ci/tests/run-core-tests.sh | 6 ++++ ci/tests/run-qt-tests.sh | 21 ++++++++++++++ ci/tests/run-rpc-tests.sh | 6 ++++ ci/tests/run-system-tests.sh | 7 +++++ 5 files changed, 68 insertions(+), 19 deletions(-) create mode 100755 ci/tests/run-core-tests.sh create mode 100755 ci/tests/run-qt-tests.sh create mode 100755 ci/tests/run-rpc-tests.sh create mode 100755 ci/tests/run-system-tests.sh diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index a2c9f2f623..03d2a58c49 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 @@ -46,7 +43,7 @@ jobs: run: ci/build-ci.sh "/tmp/qt/lib/cmake/Qt5"; - 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 +51,14 @@ 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 + run: cd build && ../ci/tests/run-core-tests.sh + + - name: RPC Tests + run: cd build && ../ci/tests/run-rpc-tests.sh + + - name: System Tests + run: cd build && ../ci/tests/run-system-tests.sh linux_test: name: Linux [${{ matrix.BACKEND }} | ${{ matrix.COMPILER }}] @@ -73,15 +74,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 @@ -101,7 +103,7 @@ jobs: 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" - 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 +111,17 @@ 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 + 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/tests/run-core-tests.sh" + + - name: RPC 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/tests/run-rpc-tests.sh" + + - name: System 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/tests/run-system-tests.sh" + + - name: QT 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/tests/run-qt-tests.sh" windows_test: name: Windows [${{ matrix.BACKEND }}] @@ -126,8 +135,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 diff --git a/ci/tests/run-core-tests.sh b/ci/tests/run-core-tests.sh new file mode 100755 index 0000000000..e2d5613630 --- /dev/null +++ b/ci/tests/run-core-tests.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -euo pipefail + +BUILD_DIR=${1-${PWD}} + +${BUILD_DIR}/core_test \ 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..caceb686ab --- /dev/null +++ b/ci/tests/run-qt-tests.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -euo pipefail + +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 \ 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..d62ee5dee3 --- /dev/null +++ b/ci/tests/run-rpc-tests.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -euo pipefail + +BUILD_DIR=${1-${PWD}} + +${BUILD_DIR}/rpc_test \ 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..2fc71f42b1 --- /dev/null +++ b/ci/tests/run-system-tests.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -euo pipefail + +BUILD_DIR=${1-${PWD}} + +export NANO_NODE_EXE=${BUILD_DIR}/nano_node +cd ../systest && ./RUNALL \ No newline at end of file From 87448a51515431d3d3483beaff585ce7fd1ba7cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Fri, 21 Apr 2023 02:47:24 +0200 Subject: [PATCH 03/15] Linux prepare --- .github/workflows/unit_tests.yml | 4 ++-- ci/prepare/linux/prepare-clang.sh | 17 +++++++++++++++++ ci/prepare/linux/prepare-gcc.sh | 2 ++ ci/prepare/linux/prepare.sh | 27 +++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100755 ci/prepare/linux/prepare-clang.sh create mode 100755 ci/prepare/linux/prepare-gcc.sh create mode 100755 ci/prepare/linux/prepare.sh diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 03d2a58c49..f6d3b25bb3 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -96,8 +96,8 @@ 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" 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 From 969c34ea4a18e5775a9987c3d6b7ee1a9bae9fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Thu, 27 Apr 2023 21:24:55 +0200 Subject: [PATCH 04/15] macOS prepare --- .github/workflows/unit_tests.yml | 4 ++-- ci/prepare/macos/prepare.sh | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100755 ci/prepare/macos/prepare.sh diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index f6d3b25bb3..962466a639 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -36,8 +36,8 @@ 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"; 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 From 6280a95b27620e79ead800ffc22c0fd806fc4584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Mon, 24 Apr 2023 17:11:52 +0200 Subject: [PATCH 05/15] Windows prepare --- .github/workflows/unit_tests.yml | 7 ++-- ci/prepare/windows/disable-defender.ps1 | 5 +++ ci/prepare/windows/install-qt.ps1 | 45 +++++++++++++++++++++++++ ci/prepare/windows/prepare.ps1 | 4 +++ 4 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 ci/prepare/windows/disable-defender.ps1 create mode 100644 ci/prepare/windows/install-qt.ps1 create mode 100644 ci/prepare/windows/prepare.ps1 diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 962466a639..bf86a89440 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -156,11 +156,8 @@ 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 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..5f4f2b335e --- /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 +"NANO_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 From 2a84f83f66dcd940156abb25cad4cad856e24b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Thu, 27 Apr 2023 21:25:49 +0200 Subject: [PATCH 06/15] Introduce universal build script --- .github/workflows/unit_tests.yml | 8 +-- CMakeLists.txt | 2 + ci/build.sh | 84 ++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 3 deletions(-) create mode 100755 ci/build.sh diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index bf86a89440..ca26acf4e8 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -40,7 +40,7 @@ jobs: run: ci/prepare/macos/prepare.sh - name: Build Tests - run: ci/build-ci.sh "/tmp/qt/lib/cmake/Qt5"; + run: ci/build.sh - name: Save Build Cache # Only save build cache from develop to avoid polluting it by other branches / PRs @@ -100,7 +100,7 @@ jobs: 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" + run: ci/build.sh - name: Save Build Cache # Only save build cache from develop to avoid polluting it by other branches / PRs @@ -160,7 +160,9 @@ jobs: run: ci/prepare/windows/prepare.ps1 - name: Build Tests - run: ci/actions/windows/build.ps1 + id: build + run: ci/build.sh + shell: bash - name: Save Build Cache # only save build cache from develop to avoid polluting it by other branches / PRs diff --git a/CMakeLists.txt b/CMakeLists.txt index c3b800d77e..cdd370f579 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,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 diff --git a/ci/build.sh b/ci/build.sh new file mode 100755 index 0000000000..bf939d54de --- /dev/null +++ b/ci/build.sh @@ -0,0 +1,84 @@ +#!/bin/bash +set -euox pipefail + +NODE_SRC=${1:-${PWD}} + +OS=$(uname) +BUILD_TYPE=${NANO_BUILD_TYPE:-Debug} +BUILD_TARGET=build_tests + +if [[ "${RELEASE:-false}" == "true" ]]; then + BUILD_TYPE="RelWithDebInfo" +fi + +if [[ ${NANO_ASAN_INT:-0} -eq 1 ]]; then + SANITIZERS="-DNANO_ASAN_INT=ON" +fi +if [[ ${NANO_ASAN:-0} -eq 1 ]]; then + SANITIZERS="-DNANO_ASAN=ON" +fi +if [[ ${NANO_TSAN:-0} -eq 1 ]]; then + SANITIZERS="-DNANO_TSAN=ON" +fi +if [[ ${NANO_COVERAGE:-0} -eq 1 ]]; then + SANITIZERS="-DCOVERAGE=ON" +fi + +if [[ "$OS" == 'Linux' ]]; then + BACKTRACE="-DNANO_STACKTRACE_BACKTRACE=ON" + + if [[ "$COMPILER" == 'clang' ]]; then + BACKTRACE="${BACKTRACE} -DNANO_BACKTRACE_INCLUDE=" + fi +else + BACKTRACE="" +fi + +mkdir -p build +pushd build + +cmake \ +-DACTIVE_NETWORK=nano_dev_network \ +-DNANO_TEST=ON \ +-DNANO_GUI=ON \ +-DPORTABLE=ON \ +-DNANO_WARN_TO_ERR=ON \ +-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ +-DCI_TEST=ON \ +-DQt5_DIR=${NANO_QT_DIR:-} \ +${BACKTRACE:-} \ +${SANITIZERS:-} \ +${NODE_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} --target ${BUILD_TARGET} $(parallel_build_flag) + +popd \ No newline at end of file From 135867b88ae4d1e3d5afc32b06435656b971732b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Thu, 27 Apr 2023 21:26:06 +0200 Subject: [PATCH 07/15] Linux build & run directly on GH runner --- .github/workflows/unit_tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index ca26acf4e8..16a5375cca 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -112,16 +112,16 @@ jobs: key: ${{ runner.os }}-${{ env.COMPILER }}-build-cache - name: Core 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/tests/run-core-tests.sh" + run: cd build && ../ci/tests/run-core-tests.sh - name: RPC 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/tests/run-rpc-tests.sh" + run: cd build && ../ci/tests/run-rpc-tests.sh - name: System 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/tests/run-system-tests.sh" + run: cd build && ../ci/tests/run-system-tests.sh - name: QT 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/tests/run-qt-tests.sh" + run: cd build && ../ci/tests/run-qt-tests.sh windows_test: name: Windows [${{ matrix.BACKEND }}] From 3bee5d30850ea64b4620ee7ea133e56b0df13230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Mon, 24 Apr 2023 16:45:04 +0200 Subject: [PATCH 08/15] Run tests only if build succeeds --- .github/workflows/unit_tests.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 16a5375cca..3914571023 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -40,6 +40,7 @@ jobs: run: ci/prepare/macos/prepare.sh - name: Build Tests + id: build run: ci/build.sh - name: Save Build Cache @@ -52,12 +53,15 @@ jobs: key: ${{ runner.os }}-build-cache - 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: @@ -100,6 +104,7 @@ jobs: run: sudo -E ci/prepare/linux/prepare.sh - name: Build Tests + id: build run: ci/build.sh - name: Save Build Cache @@ -112,15 +117,19 @@ jobs: key: ${{ runner.os }}-${{ env.COMPILER }}-build-cache - 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: From a8025906348005384f44deece9adcb289e60f2cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Thu, 27 Apr 2023 21:29:04 +0200 Subject: [PATCH 09/15] Windows run tests using bash scripts --- .github/workflows/unit_tests.yml | 18 ++++++++++++++---- ci/tests/common.sh | 16 ++++++++++++++++ ci/tests/run-core-tests.sh | 4 +++- ci/tests/run-qt-tests.sh | 4 +++- ci/tests/run-rpc-tests.sh | 4 +++- ci/tests/run-system-tests.sh | 4 +++- 6 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 ci/tests/common.sh diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 3914571023..80fa0c3d70 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -182,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/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 index e2d5613630..a3e02b70bf 100755 --- a/ci/tests/run-core-tests.sh +++ b/ci/tests/run-core-tests.sh @@ -1,6 +1,8 @@ #!/bin/bash set -euo pipefail +source "$(dirname "$BASH_SOURCE")/common.sh" + BUILD_DIR=${1-${PWD}} -${BUILD_DIR}/core_test \ No newline at end of file +${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 index caceb686ab..8faa28d43a 100755 --- a/ci/tests/run-qt-tests.sh +++ b/ci/tests/run-qt-tests.sh @@ -1,6 +1,8 @@ #!/bin/bash set -euo pipefail +source "$(dirname "$BASH_SOURCE")/common.sh" + BUILD_DIR=${1-${PWD}} # Alpine doesn't offer an xvfb @@ -18,4 +20,4 @@ xvfb_run_() return ${res} } -xvfb_run_ ${BUILD_DIR}/qt_test \ No newline at end of file +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 index d62ee5dee3..6b64607d95 100755 --- a/ci/tests/run-rpc-tests.sh +++ b/ci/tests/run-rpc-tests.sh @@ -1,6 +1,8 @@ #!/bin/bash set -euo pipefail +source "$(dirname "$BASH_SOURCE")/common.sh" + BUILD_DIR=${1-${PWD}} -${BUILD_DIR}/rpc_test \ No newline at end of file +${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 index 2fc71f42b1..e5e5394536 100755 --- a/ci/tests/run-system-tests.sh +++ b/ci/tests/run-system-tests.sh @@ -1,7 +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 +export NANO_NODE_EXE=${BUILD_DIR}/nano_node$(get_exec_extension) cd ../systest && ./RUNALL \ No newline at end of file From 3b775c5a49ae595e68cc5d0822c5034ecfceab17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Fri, 28 Apr 2023 00:46:42 +0200 Subject: [PATCH 10/15] Remove `CI_TEST` option --- CMakeLists.txt | 4 ---- ci/actions/windows/build.ps1 | 1 - ci/build-ci.sh | 1 - ci/build.sh | 1 - nano/core_test/CMakeLists.txt | 2 +- nano/core_test/network.cpp | 2 +- nano/lib/CMakeLists.txt | 1 - 7 files changed, 2 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cdd370f579..9a2136379e 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() 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 eee9cece28..f03b00c9df 100755 --- a/ci/build-ci.sh +++ b/ci/build-ci.sh @@ -48,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.sh b/ci/build.sh index bf939d54de..676c8f761b 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -44,7 +44,6 @@ cmake \ -DPORTABLE=ON \ -DNANO_WARN_TO_ERR=ON \ -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ --DCI_TEST=ON \ -DQt5_DIR=${NANO_QT_DIR:-} \ ${BACKTRACE:-} \ ${SANITIZERS:-} \ 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}) From 8e402852b42b0c95889cf14118da1fe00a4271c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Fri, 21 Apr 2023 03:38:06 +0200 Subject: [PATCH 11/15] Tweak build targets --- .github/workflows/unit_tests.yml | 6 +-- CMakeLists.txt | 17 +++---- ci/build-node.sh | 4 ++ ci/build-tests.sh | 13 +++++ ci/build.sh | 82 ++++++++++++++++++-------------- 5 files changed, 75 insertions(+), 47 deletions(-) create mode 100755 ci/build-node.sh create mode 100755 ci/build-tests.sh diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 80fa0c3d70..451d705b68 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -41,7 +41,7 @@ jobs: - name: Build Tests id: build - run: ci/build.sh + run: ci/build-tests.sh - name: Save Build Cache # Only save build cache from develop to avoid polluting it by other branches / PRs @@ -105,7 +105,7 @@ jobs: - name: Build Tests id: build - run: ci/build.sh + run: ci/build-tests.sh - name: Save Build Cache # Only save build cache from develop to avoid polluting it by other branches / PRs @@ -170,7 +170,7 @@ jobs: - name: Build Tests id: build - run: ci/build.sh + run: ci/build-tests.sh shell: bash - name: Save Build Cache diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a2136379e..1a58185967 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -656,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) @@ -694,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) @@ -807,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/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 index 676c8f761b..fabfe42855 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -1,52 +1,62 @@ #!/bin/bash set -euox pipefail -NODE_SRC=${1:-${PWD}} - -OS=$(uname) -BUILD_TYPE=${NANO_BUILD_TYPE:-Debug} -BUILD_TARGET=build_tests - -if [[ "${RELEASE:-false}" == "true" ]]; then - BUILD_TYPE="RelWithDebInfo" +BUILD_TARGET="" +if [[ ${1:-} ]]; then + BUILD_TARGET="--target $1" fi -if [[ ${NANO_ASAN_INT:-0} -eq 1 ]]; then - SANITIZERS="-DNANO_ASAN_INT=ON" -fi -if [[ ${NANO_ASAN:-0} -eq 1 ]]; then - SANITIZERS="-DNANO_ASAN=ON" -fi -if [[ ${NANO_TSAN:-0} -eq 1 ]]; then - SANITIZERS="-DNANO_TSAN=ON" -fi -if [[ ${NANO_COVERAGE:-0} -eq 1 ]]; then - SANITIZERS="-DCOVERAGE=ON" -fi +NODE_SRC=${NODE_SRC:-${PWD}} +OS=$(uname) +CMAKE_BACKTRACE="" if [[ "$OS" == 'Linux' ]]; then - BACKTRACE="-DNANO_STACKTRACE_BACKTRACE=ON" + CMAKE_BACKTRACE="-DNANO_STACKTRACE_BACKTRACE=ON" if [[ "$COMPILER" == 'clang' ]]; then - BACKTRACE="${BACKTRACE} -DNANO_BACKTRACE_INCLUDE=" + CMAKE_BACKTRACE="${CMAKE_BACKTRACE} -DNANO_BACKTRACE_INCLUDE=" fi -else - BACKTRACE="" fi -mkdir -p build -pushd build +CMAKE_QT_DIR="" +if [[ ${NANO_QT_DIR:-} ]]; then + CMAKE_QT_DIR="-DQt5_DIR=${NANO_QT_DIR}" +fi + +CMAKE_SANITIZER="" +if [[ ${NANO_SANITIZER:-} ]]; then + case "${NANO_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: '${NANO_SANITIZER}'" + exit 1 + ;; + esac +fi + +BUILD_DIR="build" + +mkdir -p $BUILD_DIR +pushd $BUILD_DIR cmake \ --DACTIVE_NETWORK=nano_dev_network \ --DNANO_TEST=ON \ --DNANO_GUI=ON \ +-DCMAKE_BUILD_TYPE=${BUILD_TYPE:-"Debug"} \ -DPORTABLE=ON \ --DNANO_WARN_TO_ERR=ON \ --DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ --DQt5_DIR=${NANO_QT_DIR:-} \ -${BACKTRACE:-} \ -${SANITIZERS:-} \ +-DACTIVE_NETWORK=nano_${NANO_NETWORK:-"live"}_network \ +-DNANO_TEST=${NANO_TEST:-OFF} \ +-DNANO_GUI=${NANO_GUI:-OFF} \ +-DCOVERAGE=${NANO_COVERAGE:-OFF} \ +${CMAKE_SANITIZER:-} \ +${CMAKE_QT_DIR:-} \ +${CMAKE_BACKTRACE:-} \ ${NODE_SRC} number_of_processors() { @@ -78,6 +88,6 @@ parallel_build_flag() { esac } -cmake --build ${PWD} --target ${BUILD_TARGET} $(parallel_build_flag) +cmake --build ${PWD} ${BUILD_TARGET} $(parallel_build_flag) -popd \ No newline at end of file +popd From 7d34852cc75a937e94f31c33e22aa70add8ac751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Fri, 26 May 2023 15:42:15 +0200 Subject: [PATCH 12/15] Introduce a proper multi-stage dockerfile --- docker/node/Dockerfile | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/docker/node/Dockerfile b/docker/node/Dockerfile index cb409594aa..3b6c8ad676 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 ${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 From 37482cf51c3f81a36d2286f998a0a5fc3ee316ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Sun, 28 May 2023 15:16:09 +0200 Subject: [PATCH 13/15] Simplify env variable names --- ci/build.sh | 18 +++++++++--------- ci/prepare/windows/install-qt.ps1 | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index fabfe42855..a238241022 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -6,7 +6,7 @@ if [[ ${1:-} ]]; then BUILD_TARGET="--target $1" fi -NODE_SRC=${NODE_SRC:-${PWD}} +SRC=${SRC:-${PWD}} OS=$(uname) CMAKE_BACKTRACE="" @@ -19,13 +19,13 @@ if [[ "$OS" == 'Linux' ]]; then fi CMAKE_QT_DIR="" -if [[ ${NANO_QT_DIR:-} ]]; then - CMAKE_QT_DIR="-DQt5_DIR=${NANO_QT_DIR}" +if [[ ${QT_DIR:-} ]]; then + CMAKE_QT_DIR="-DQt5_DIR=${QT_DIR}" fi CMAKE_SANITIZER="" -if [[ ${NANO_SANITIZER:-} ]]; then - case "${NANO_SANITIZER}" in +if [[ ${SANITIZER:-} ]]; then + case "${SANITIZER}" in ASAN) CMAKE_SANITIZER="-DNANO_ASAN=ON" ;; @@ -36,7 +36,7 @@ if [[ ${NANO_SANITIZER:-} ]]; then CMAKE_SANITIZER="-DNANO_TSAN=ON" ;; *) - echo "Unknown sanitizer: '${NANO_SANITIZER}'" + echo "Unknown sanitizer: '${SANITIZER}'" exit 1 ;; esac @@ -53,11 +53,11 @@ cmake \ -DACTIVE_NETWORK=nano_${NANO_NETWORK:-"live"}_network \ -DNANO_TEST=${NANO_TEST:-OFF} \ -DNANO_GUI=${NANO_GUI:-OFF} \ --DCOVERAGE=${NANO_COVERAGE:-OFF} \ +-DCOVERAGE=${COVERAGE:-OFF} \ ${CMAKE_SANITIZER:-} \ ${CMAKE_QT_DIR:-} \ ${CMAKE_BACKTRACE:-} \ -${NODE_SRC} +${SRC} number_of_processors() { case "$(uname -s)" in @@ -90,4 +90,4 @@ parallel_build_flag() { cmake --build ${PWD} ${BUILD_TARGET} $(parallel_build_flag) -popd +popd \ No newline at end of file diff --git a/ci/prepare/windows/install-qt.ps1 b/ci/prepare/windows/install-qt.ps1 index 5f4f2b335e..ac293592bd 100644 --- a/ci/prepare/windows/install-qt.ps1 +++ b/ci/prepare/windows/install-qt.ps1 @@ -42,4 +42,4 @@ foreach ($entry in $toDownload) { } # Save install location for subsequent steps -"NANO_QT_DIR=C:\Qt\5.15.2\msvc2019_64\lib\cmake\Qt5" >> $env:GITHUB_ENV \ No newline at end of file +"QT_DIR=C:\Qt\5.15.2\msvc2019_64\lib\cmake\Qt5" >> $env:GITHUB_ENV \ No newline at end of file From 5a97e55bc77d146a87b3ad78d9622afe142545eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Tue, 20 Jun 2023 17:18:44 +0200 Subject: [PATCH 14/15] Fix docker network --- docker/node/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/node/Dockerfile b/docker/node/Dockerfile index 3b6c8ad676..ec0ea85663 100644 --- a/docker/node/Dockerfile +++ b/docker/node/Dockerfile @@ -15,7 +15,7 @@ WORKDIR /tmp/src # Build node RUN ci/build-node.sh -RUN echo ${NETWORK} >/etc/nano-network +RUN echo ${NANO_NETWORK} >/etc/nano-network FROM ubuntu:22.04 From 47a718eee395f05e83f656cc4f30cd4b8eb8f863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Wo=CC=81jcik?= <3044353+pwojcikdev@users.noreply.github.com> Date: Tue, 20 Jun 2023 20:51:30 +0200 Subject: [PATCH 15/15] Formatting --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a58185967..162b33d5c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -657,10 +657,10 @@ 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) + executables + COMMAND echo "BATCH BUILDING node + rpc" + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + DEPENDS nano_node nano_rpc) if(NANO_FUZZER_TEST) if(NOT WIN32)