Skip to content

Commit

Permalink
add test network to build artifacts for non DB tags (nanocurrency#3000)
Browse files Browse the repository at this point in the history
* add test network to build artifacts for non DB tags
different installation defaults for different networks
update debian package, will create user(nanocurrency) and service for
each network

* rename variable for continuity
  • Loading branch information
Russel Waters authored Oct 20, 2020
1 parent 41a6423 commit ccdbda7
Show file tree
Hide file tree
Showing 13 changed files with 213 additions and 32 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/test_network_artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: TestNetwork

on:
push:
tags-ignore:
- '*DB*'
env:
artifact: 1
TEST: 1

jobs:
osx_job:
runs-on: macOS-latest
env:
BOOST_ROOT: /tmp/boost
steps:
- uses: actions/checkout@722adc6
- uses: chrislennon/action-aws-cli@f0f8671
- name: tag
run: echo "::set-env name=TAG::`git describe --tags $GITHUB_SHA`"
- name: Checkout Submodules
run: git submodule update --init --recursive
- name: Fetch Deps
run: ci/actions/osx/install_deps.sh
- name: Build Artifact
run: TRAVIS_TAG=${TAG} ci/build-deploy.sh "/tmp/qt/lib/cmake/Qt5";
- name: Deploy Artifact
run: ci/actions/deploy.sh
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-2

linux_job:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@722adc6
- uses: chrislennon/action-aws-cli@f0f8671
- name: tag
run: echo "::set-env name=TAG::`git describe --tags $GITHUB_SHA`"
- name: Checkout Submodules
run: git submodule update --init --recursive
- name: Fetch Deps
run: ci/actions/linux/install_deps.sh
- name: Build Artifact
run: docker run -e TEST -v ${GITHUB_WORKSPACE}:/workspace nanocurrency/nano-env:gcc /bin/bash -c "cd /workspace && TRAVIS_TAG=${TAG} ci/build-deploy.sh /usr/lib/x86_64-linux-gnu/cmake/Qt5 ${PWD}"
- name: Deploy Artifact
run: ci/actions/deploy.sh
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-2

linux_docker_job:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@722adc6
- uses: chrislennon/action-aws-cli@f0f8671
- name: tag
run: echo "::set-env name=TAG::`git describe --tags $GITHUB_SHA`"
- name: Checkout Submodules
run: git submodule update --init --recursive
- name: Fetch Deps
run: ci/actions/linux/install_deps.sh
- name: Deploy Docker (nanocurrency/nano)
run: TRAVIS_TAG=${TAG} ci/actions/linux/deploy-docker.sh
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

windows_job:
runs-on: windows-latest
steps:
- uses: actions/checkout@722adc6
- uses: chrislennon/action-aws-cli@f0f8671
- name: tag
run: |
$TRAVIS_TAG=git describe --tags $GITHUB_SHA
echo "::set-env name=TAG::$TRAVIS_TAG"
- name: Checkout Submodules
run: git submodule update --init --recursive
- name: Fetch Deps
run: ci/actions/windows/install_deps.ps1
- name: Build Artifact
run: ci/actions/windows/build.ps1
env:
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
- name: Deploy Artifact
run: ci/actions/windows/deploy.ps1
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-2
78 changes: 55 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,27 @@ option(ENABLE_AVX2 "Enable AVX2 optimizations" OFF)

SET (ACTIVE_NETWORK nano_live_network CACHE STRING "Selects which network parameters are used")
set_property (CACHE ACTIVE_NETWORK PROPERTY STRINGS nano_dev_network nano_beta_network nano_live_network nano_test_network)
set (CPACK_PACKAGE_NAME "nano-node" CACHE STRING "" FORCE)
set (CPACK_NSIS_PACKAGE_NAME "Nano" CACHE STRING "" FORCE)
set (CPACK_PACKAGE_INSTALL_DIRECTORY "nanocurrency" CACHE STRING "" FORCE)
set (NANO_SERVICE "nanocurrency.service")
set (NANO_PREFIX "")
if ("${ACTIVE_NETWORK}" MATCHES "nano_beta_network")
project("nano-node-beta")
set (CPACK_PACKAGE_NAME "nano-node-beta" CACHE STRING "" FORCE)
set (CPACK_NSIS_PACKAGE_NAME "Nano-Beta" CACHE STRING "" FORCE)
set (CPACK_PACKAGE_INSTALL_DIRECTORY "nanocurrency-beta" CACHE STRING "" FORCE)
set (NANO_SERVICE "nanocurrency-beta.service")
set (NANO_PREFIX "Beta")
elseif ("${ACTIVE_NETWORK}" MATCHES "nano_test_network")
project("nano-node-test")
set (CPACK_PACKAGE_NAME "nano-node-test" CACHE STRING "" FORCE)
set (CPACK_NSIS_PACKAGE_NAME "Nano-Test" CACHE STRING "" FORCE)
set (CPACK_PACKAGE_INSTALL_DIRECTORY "nanocurrency-test" CACHE STRING "" FORCE)
set (NANO_SERVICE "nanocurrency-test.service")
set (NANO_PREFIX "Test")
endif()
set (NANO_OSX_PACKAGE_NAME ${CPACK_NSIS_PACKAGE_NAME} CACHE STRING "" FORCE)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
Expand Down Expand Up @@ -548,47 +569,44 @@ if (NANO_GUI OR RAIBLOCKS_GUI)
if (APPLE)
set (CPACK_GENERATOR "DragNDrop")
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/Info.plist.in ${CMAKE_SOURCE_DIR}/Info.plist @ONLY)
install (TARGETS nano_wallet DESTINATION Nano.app/Contents/MacOS)
install (TARGETS nano_node DESTINATION Nano.app/Contents/MacOS)
install (TARGETS nano_rpc DESTINATION Nano.app/Contents/MacOS)
install (FILES Info.plist DESTINATION Nano.app/Contents)
install (FILES qt.conf DESTINATION Nano.app/Contents/Resources)
install (DIRECTORY ${Qt5_DIR}/../../QtCore.framework DESTINATION Nano.app/Contents/Frameworks)
install (DIRECTORY ${Qt5_DIR}/../../QtDBus.framework DESTINATION Nano.app/Contents/Frameworks)
install (DIRECTORY ${Qt5_DIR}/../../QtGui.framework DESTINATION Nano.app/Contents/Frameworks)
install (DIRECTORY ${Qt5_DIR}/../../QtPrintSupport.framework DESTINATION Nano.app/Contents/Frameworks)
install (DIRECTORY ${Qt5_DIR}/../../QtTest.framework DESTINATION Nano.app/Contents/Frameworks)
install (DIRECTORY ${Qt5_DIR}/../../QtWidgets.framework DESTINATION Nano.app/Contents/Frameworks)
install (FILES "${Qt5_DIR}/../../../plugins/platforms/libqcocoa.dylib" DESTINATION Nano.app/Contents/PlugIns/platforms)
install (TARGETS nano_wallet DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/MacOS)
install (TARGETS nano_node DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/MacOS)
install (TARGETS nano_rpc DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/MacOS)
install (FILES Info.plist DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents)
install (FILES qt.conf DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/Resources)
install (DIRECTORY ${Qt5_DIR}/../../QtCore.framework DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/Frameworks)
install (DIRECTORY ${Qt5_DIR}/../../QtDBus.framework DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/Frameworks)
install (DIRECTORY ${Qt5_DIR}/../../QtGui.framework DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/Frameworks)
install (DIRECTORY ${Qt5_DIR}/../../QtPrintSupport.framework DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/Frameworks)
install (DIRECTORY ${Qt5_DIR}/../../QtTest.framework DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/Frameworks)
install (DIRECTORY ${Qt5_DIR}/../../QtWidgets.framework DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/Frameworks)
install (FILES "${Qt5_DIR}/../../../plugins/platforms/libqcocoa.dylib" DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/PlugIns/platforms)
if (NANO_SHARED_BOOST)
foreach(boost_lib IN LISTS Boost_LIBRARIES)
string(REGEX MATCH "(.+/.*boost_[^-]+)" boost_lib_name ${boost_lib})
set (boost_dll "${CMAKE_MATCH_1}")
if (${boost_dll} MATCHES "boost")
install (FILES ${boost_dll} DESTINATION Nano.app/Contents/boost/lib)
install (FILES ${boost_dll} DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/boost/lib)
endif()
endforeach(boost_lib)
endif()
if (NANO_POW_SERVER)
install (TARGETS nano_pow_server DESTINATION Nano.app/Contents/MacOS)
install (DIRECTORY ${PROJECT_SOURCE_DIR}/nano-pow-server/public DESTINATION Nano.app/Contents/MacOS)
install (TARGETS nano_pow_server DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/MacOS)
install (DIRECTORY ${PROJECT_SOURCE_DIR}/nano-pow-server/public DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/MacOS)
endif()
install (FILES Nano.icns DESTINATION Nano.app/Contents/Resources)
install (FILES Nano.icns DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/Resources)
elseif (WIN32)
if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set (WIN_REDIST vc_redist.x64.exe)
else ()
set (WIN_REDIST vc_redist.x86.exe)
endif ()
set (CPACK_NSIS_EXTRA_INSTALL_COMMANDS "ExecWait '\\\"$INSTDIR\\\\${WIN_REDIST}\\\" /quiet /norestart'
WriteRegDWORD HKLM 'SYSTEM\\\\CurrentControlSet\\\\Services\\\\EventLog\\\\Nano\\\\Nano' 'TypesSupported' '0x7'
WriteRegStr HKLM 'SYSTEM\\\\CurrentControlSet\\\\Services\\\\EventLog\\\\Nano\\\\Nano' 'EventMessageFile' '$INSTDIR\\\\nano_wallet.exe'")
set (CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "DeleteRegKey HKLM 'SYSTEM\\\\CurrentControlSet\\\\Services\\\\EventLog\\\\Nano'")
set (CPACK_PACKAGE_INSTALL_DIRECTORY "nanocurrency")
WriteRegDWORD HKLM 'SYSTEM\\\\CurrentControlSet\\\\Services\\\\EventLog\\\\Nano\\\\Nano${NANO_PREFIX}' 'TypesSupported' '0x7'
WriteRegStr HKLM 'SYSTEM\\\\CurrentControlSet\\\\Services\\\\EventLog\\\\Nano\\\\Nano${NANO_PREFIX}' 'EventMessageFile' '$INSTDIR\\\\nano_wallet.exe'")
set (CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "DeleteRegKey HKLM 'SYSTEM\\\\CurrentControlSet\\\\Services\\\\EventLog\\\\Nano${NANO_PREFIX}'")
set (CPACK_NSIS_MUI_ICON ${CMAKE_SOURCE_DIR}/Nano.ico)
set (CPACK_NSIS_DISPLAY_NAME "Nano")
set (CPACK_PACKAGE_NAME "nano-node")
set (CPACK_NSIS_PACKAGE_NAME "Nano")
set (CPACK_NSIS_DISPLAY_NAME "Nano${NANO_PREFIX}")
set (CPACK_NSIS_URL_INFO_ABOUT "https://nano.org")
set (CPACK_NSIS_CONTACT "[email protected]")
set (CPACK_NSIS_MENU_LINKS "nano_wallet.exe" "Nano Wallet" "https://nano.org" "Nano website")
Expand Down Expand Up @@ -645,6 +663,20 @@ if (NANO_GUI OR RAIBLOCKS_GUI)
install (TARGETS nano_pow_server DESTINATION ./bin)
install (DIRECTORY ${PROJECT_SOURCE_DIR}/nano-pow-server/public DESTINATION ./bin)
endif ()
set(DEBIAN_POSTINST postinst.in)
set(DEBIAN_POSTRM postrm.in)

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/debian-control/${DEBIAN_POSTINST}
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/postinst)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/debian-control/${DEBIAN_POSTRM}
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/postrm)
file(COPY ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/postinst
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/postrm
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/debian-control/.
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install (FILES etc/systemd/${NANO_SERVICE} DESTINATION ./extras/systemd/.)
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_BINARY_DIR}/debian-control/postinst;${CMAKE_CURRENT_BINARY_DIR}/debian-control/postrm")
endif ()
endif ()

Expand Down
2 changes: 1 addition & 1 deletion Info.plist.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<key>CFBundleExecutable</key>
<string>nano_wallet</string>
<key>CFBundleName</key>
<string>Nano</string>
<string>@NANO_OSX_PACKAGE_NAME@</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleIconFile</key>
Expand Down
2 changes: 2 additions & 0 deletions ci/actions/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ OS=`uname`

if [[ "${BETA-0}" -eq 1 ]]; then
BUILD="beta"
elif [[ "${TEST-0}" -eq 1 ]]; then
BUILD="test"
else
BUILD="live"
fi
Expand Down
6 changes: 5 additions & 1 deletion ci/actions/linux/deploy-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if [ -n "$DOCKER_PASSWORD" ]; then
tags=()
if [ -n "$TRAVIS_TAG" ]; then
tags+=("$TRAVIS_TAG" latest)
if [[ "$GITHUB_WORKFLOW" = "Beta" ]]; then
if [[ "$GITHUB_WORKFLOW" = "Beta" || "$GITHUB_WORKFLOW" = "TestNetwork" ]]; then
tags+=(latest-including-rc)
fi
elif [ -n "$TRAVIS_BRANCH" ]; then
Expand All @@ -32,6 +32,10 @@ if [ -n "$DOCKER_PASSWORD" ]; then
echo "Beta"
network_tag_suffix="-beta"
network="beta"
elif [[ "$GITHUB_WORKFLOW" = "TestNetwork" ]]; then
echo "Test"
network_tag_suffix="-test"
network="test"
else
echo "Nothing to deploy"
exit 1
Expand Down
5 changes: 4 additions & 1 deletion ci/actions/windows/build.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
$ErrorActionPreference = "Continue"

if (${env:artifact} -eq 1) {
$env:BUILD_TYPE = "Release"
if ( ${env:BETA} -eq 1 ) {
$env:NETWORK_CFG = "beta"
$env:BUILD_TYPE = "RelWithDebInfo"
}
elseif(${env:TEST} -eq 1) {
$env:NETWORK_CFG= "test"
}
else {
$env:NETWORK_CFG = "live"
$env:BUILD_TYPE = "Release"
}
$env:NANO_SHARED_BOOST = "ON"
$env:ROCKS_LIB = '-DROCKSDB_LIBRARIES="c:\vcpkg\installed\x64-windows-static\lib\rocksdb.lib"'
Expand Down
4 changes: 3 additions & 1 deletion ci/build-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ OS=`uname`

mkdir build
pushd build
CONFIGURATION="Release"

if [[ "${BETA:-0}" -eq 1 ]]; then
NETWORK_CFG="beta"
CONFIGURATION="RelWithDebInfo"
elif [[ "${TEST:-0}" -eq 1 ]]; then
NETWORK_CFG="test"
else
NETWORK_CFG="live"
CONFIGURATION="Release"
fi

cmake \
Expand Down
22 changes: 22 additions & 0 deletions debian-control/postinst.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set +e

useradd -r nanocurrency
groupadd -r nanocurrency

mkdir -p /var/nanocurrency/Nano
mkdir -p /var/nanocurrency/NanoBeta
mkdir -p /var/nanocurrency/NanoTest
chown -R nanocurrency: /var/nanocurrency

systemctl stop ${NANO_SERVICE} 2>/dev/null
systemctl disable ${NANO_SERVICE} 2>/dev/null
cp ${CMAKE_INSTALL_PREFIX}/extras/systemd/${NANO_SERVICE} /etc/systemd/system/${NANO_SERVICE}
systemctl daemon-reload
systemctl enable ${NANO_SERVICE}
systemctl start ${NANO_SERVICE}
sleep 1
systemctl --no-pager status ${NANO_SERVICE}

set -e
10 changes: 10 additions & 0 deletions debian-control/postrm.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set +e

systemctl stop ${NANO_SERVICE} 2>/dev/null
systemctl disable ${NANO_SERVICE} 2>/dev/null
rm -rf /etc/systemd/system/${NANO_SERVICE}
systemctl daemon-reload

set -e
4 changes: 2 additions & 2 deletions etc/systemd/nanocurrency-beta.service
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[Unit]
Description=Nano Daemon beta network
Description=Nano Beta Network Daemon
After=network.target

[Service]
Type=simple
User=nanocurrency
WorkingDirectory=/var/nanocurrency/NanoBeta
ExecStart=/usr/bin/nano_node-beta --daemon
ExecStart=/usr/bin/nano_node --daemon --network=beta --data_path=/var/nanocurrency/NanoBeta
Restart=on-failure

[Install]
Expand Down
13 changes: 13 additions & 0 deletions etc/systemd/nanocurrency-test.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Nano Test Network Daemon
After=network.target

[Service]
Type=simple
User=nanocurrency
WorkingDirectory=/var/nanocurrency/NanoTest
ExecStart=/usr/bin/nano_node --daemon --network=test --data_path=/var/nanocurrency/NanoTest
Restart=on-failure

[Install]
WantedBy=multi-user.target
4 changes: 2 additions & 2 deletions etc/systemd/nanocurrency.service
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[Unit]
Description=Nano Daemon live network
Description=Nano Live Network Daemon
After=network.target

[Service]
Type=simple
User=nanocurrency
WorkingDirectory=/var/nanocurrency/Nano
ExecStart=/usr/bin/nano_node --daemon
ExecStart=/usr/bin/nano_node --daemon --data_path=/var/nanocurrency/Nano
Restart=on-failure

[Install]
Expand Down
2 changes: 1 addition & 1 deletion nano/ipc_flatbuffers_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ add_subdirectory(../../flatbuffers ${CMAKE_CURRENT_BINARY_DIR}/flatbuffers-build
# we currently only use one, to avoid include-file issues with certain language bindings.
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/generated/flatbuffers)
if (APPLE)
install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../api/flatbuffers/ DESTINATION Nano.app/Contents/MacOS/api/flatbuffers)
install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../api/flatbuffers/ DESTINATION ${NANO_OSX_PACKAGE_NAME}.app/Contents/MacOS/api/flatbuffers)
elseif(LINUX)
install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../api/flatbuffers/ DESTINATION ./bin/api/flatbuffers)
else()
Expand Down

0 comments on commit ccdbda7

Please sign in to comment.