From 9382c7a9c0a9eb2e5cb761ea17bb34787b07d564 Mon Sep 17 00:00:00 2001 From: Martin Boehm Date: Mon, 25 Feb 2019 17:32:06 +0100 Subject: [PATCH] Add automatic backend deploy and integration test to gitlab CI --- .gitlab-ci.yml | 23 ++++++++++++++++++ contrib/scripts/backend-deploy-and-test.sh | 27 ++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100755 contrib/scripts/backend-deploy-and-test.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9cefeef3..c9345942 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,7 @@ stages: - build - test + - backend-deploy-and-test build: stage: build @@ -25,3 +26,25 @@ integration-test: tags: - blockbook script: make test-integration ARGS="-run='TestIntegration/(bcash|bgold|bitcoin|dash|dogecoin|litecoin|vertcoin|zcash)=main/'" + +backend-deploy-and-test-bitcoin: + stage: backend-deploy-and-test + only: + refs: + - master + changes: + - configs/coins/bitcoin.json + tags: + - blockbook + script: ./contrib/scripts/backend-deploy-and-test.sh bitcoin bitcoin=main debug.log + +backend-deploy-and-test-bitcoin_testnet: + stage: backend-deploy-and-test + only: + refs: + - master + changes: + - configs/coins/bitcoin_testnet.json + tags: + - blockbook + script: ./contrib/scripts/backend-deploy-and-test.sh bitcoin_testnet bitcoin=test testnet3/debug.log diff --git a/contrib/scripts/backend-deploy-and-test.sh b/contrib/scripts/backend-deploy-and-test.sh new file mode 100755 index 00000000..87b8d174 --- /dev/null +++ b/contrib/scripts/backend-deploy-and-test.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ $# -lt 1 ] +then + echo "Usage: $(basename $(readlink -f $0)) coin [coin_test] [backend log file]" 1>&2 + exit 1 +fi + +COIN=$1 +COIN_TEST=$2 +LOGFILE=$3 + +[ -z "${BACKEND_TIMEOUT}" ] && BACKEND_TIMEOUT=15s +[ -z "${COIN_TEST}" ] && COIN_TEST="${COIN}=main" +[ -z "${LOGFILE}" ] && LOGFILE=debug.log + +rm build/*.deb +make "deb-backend-${COIN}" + +PACKAGE=$(ls "./build/backend-${COIN}*.deb") +[ -z "${PACKAGE}" ] && echo "Package not found" && exit 1 + +sudo /usr/bin/dpkg -i "${PACKAGE}" || exit 1 +sudo /bin/systemctl restart "backend-${COIN}" || exit 1 +timeout ${BACKEND_TIMEOUT} tail -f "/opt/coins/data/${COIN}/backend/${LOGFILE}" +make test-integration ARGS="-v -run=TestIntegration/${COIN_TEST}" +