From a27d7b357983bc595a8a93761343cebdcd930b16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Chavant?= Date: Fri, 30 Nov 2018 11:23:16 +0100 Subject: [PATCH 1/3] Use Node.js version from .nvmrc in Jenkinsfile --- Jenkinsfile | 60 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c7bb9788d..d0ab9aa7c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,31 +12,35 @@ pipeline { stages { stage ('Build dependencies') { steps { - script { - cache_file = restoreCache("package.json") - sh 'npm install' - saveCache(cache_file, './node_modules', 10) + nvm(getNodejsVersion()) { + sh 'npm ci' } } } stage ('Run ESLint') { steps { - sh 'npm run eslint' + nvm(getNodejsVersion()) { + sh 'npm run eslint' + } } } stage ('Build bundles') { steps { - sh 'npm run build' + nvm(getNodejsVersion()) { + sh 'npm run build' + } } } stage ('Build candles') { steps { - // marketwatcher needs to be enabled to builds candles - sh ''' - cp ./test/known.test.json ./known.json - redis-cli -n $REDIS_DB flushdb - grunt candles:build - ''' + nvm(getNodejsVersion()) { + // marketwatcher needs to be enabled to builds candles + sh ''' + cp ./test/known.test.json ./known.json + redis-cli -n $REDIS_DB flushdb + grunt candles:build + ''' + } } } stage ('Start Lisk') { @@ -65,29 +69,33 @@ pipeline { } stage ('Start Explorer') { steps { - sh ''' - cd $WORKSPACE/$BRANCH_NAME - LISK_PORT=$( docker-compose port lisk 4000 |cut -d ":" -f 2 ) - cd - - LISK_PORT=$LISK_PORT node app.js -p $EXPLORER_PORT &>/dev/null & - sleep 20 - ''' + nvm(getNodejsVersion()) { + sh ''' + cd $WORKSPACE/$BRANCH_NAME + LISK_PORT=$( docker-compose port lisk 4000 |cut -d ":" -f 2 ) + cd - + LISK_PORT=$LISK_PORT node app.js -p $EXPLORER_PORT &>/dev/null & + sleep 20 + ''' + } } } stage ('Run API tests') { steps { - sh ''' - sed -i -r -e "s/6040/$EXPLORER_PORT/" test/node.js - npm run test - ''' + nvm(getNodejsVersion()) { + sh ''' + sed -i -r -e "s/6040/$EXPLORER_PORT/" test/node.js + npm run test + ''' + } } } // stage ('Run E2E tests') { // steps { // wrap([$class: 'Xvfb']) { - // sh ''' - // npm run e2e -- --params.baseURL http://localhost:$EXPLORER_PORT - // ''' + // nvm(getNodejsVersion()) { + // sh 'npm run e2e -- --params.baseURL http://localhost:$EXPLORER_PORT' + // } // } // } // } From 8569e3ad862740031bfe88ad0a4d73ab02214ccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Chavant?= Date: Fri, 30 Nov 2018 11:23:26 +0100 Subject: [PATCH 2/3] Use Node.js version 8.14.0 --- .nvmrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nvmrc b/.nvmrc index 762ed9162..2a5dd0d63 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -8.11.2 +8.14.0 From 555c303d43b11811c10aa90d939b852fd8d54d41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Chavant?= Date: Fri, 30 Nov 2018 11:49:16 +0100 Subject: [PATCH 3/3] Test against Core 1.3.0 --- Jenkinsfile | 68 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 23 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d0ab9aa7c..3905d0082 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,7 +3,7 @@ pipeline { agent { node { label 'lisk-explorer' } } environment { - LISK_VERSION = '1.0.0-beta.9.2' + LISK_CORE_VERSION = '1.3.0' EXPLORER_PORT = "604$EXECUTOR_NUMBER" LISK_HOST = 'localhost' REDIS_DB = "$EXECUTOR_NUMBER" @@ -45,25 +45,47 @@ pipeline { } stage ('Start Lisk') { steps { - dir("$WORKSPACE/$BRANCH_NAME/") { - ansiColor('xterm') { - sh ''' - rsync -axl --delete ~/lisk-docker/examples/development/ ./ - cp ~/blockchain_explorer.db.gz ./blockchain.db.gz - make coldstart - ''' - // show some build-related info - sh ''' - sha1sum ./blockchain.db.gz - docker-compose config - docker-compose ps - ''' - // Explorer needs the topAccounts feature to be enabled - sh ''' - docker-compose exec -T lisk sed -i -r -e 's/(\\s*"topAccounts":)\\s*false,/\\1 true,/' config.json - docker-compose restart lisk - ''' - } + dir('lisk') { + checkout([$class: 'GitSCM', + branches: [[name: "v${env.LISK_CORE_VERSION}" ]], + userRemoteConfigs: [[url: 'https://github.com/LiskHQ/lisk']]]) + } + + ansiColor('xterm') { + sh '''#!/bin/bash -xe + rm -rf $WORKSPACE/$BRANCH_NAME/ + cp -rf $WORKSPACE/lisk/docker/ $WORKSPACE/$BRANCH_NAME/ + wget -nv https://downloads.lisk.io/lisk-explorer/dev/dev_blockchain.db.gz -O $WORKSPACE/$BRANCH_NAME/dev_blockchain.db.gz + cd $WORKSPACE/$BRANCH_NAME + cp .env.development .env + + sed -i -r -e '/ports:/,+2d' docker-compose.yml + # random port assignment + cat <docker-compose.override.yml +version: "2" +services: + + lisk: + ports: + - \\${ENV_LISK_HTTP_PORT} + - \\${ENV_LISK_WS_PORT} +EOF + + ENV_LISK_VERSION="$LISK_CORE_VERSION" make coldstart + ''' + // show some build-related info + sh ''' + cd $WORKSPACE/$BRANCH_NAME + sha1sum dev_blockchain.db.gz + docker-compose config + docker-compose ps + ''' + // Explorer needs the topAccounts feature to be enabled + sh ''' + cd $WORKSPACE/$BRANCH_NAME + docker-compose exec -T lisk sed -i -r -e 's/(\\s*"topAccounts":)\\s*false,/\\1 true,/' config/default/config.json + docker-compose restart lisk + ''' } } } @@ -93,9 +115,9 @@ pipeline { // stage ('Run E2E tests') { // steps { // wrap([$class: 'Xvfb']) { - // nvm(getNodejsVersion()) { - // sh 'npm run e2e -- --params.baseURL http://localhost:$EXPLORER_PORT' - // } + // nvm(getNodejsVersion()) { + // sh 'npm run e2e -- --params.baseURL http://localhost:$EXPLORER_PORT' + // } // } // } // }