From 8a6cd4e569fb910604e39552a216f748127811aa Mon Sep 17 00:00:00 2001 From: isabello Date: Mon, 15 May 2017 15:47:06 +0200 Subject: [PATCH 1/6] Implement try/catch into Jenkinsfile --- Jenkinsfile | 181 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 107 insertions(+), 74 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7ab5f50e1..e739e149b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,88 +1,121 @@ -pipeline { - agent none - environment { - ON_JENKINS = 'TRUE' - } - stages { - stage ('Lisk Provisioning') { - steps { - node('master-nano-01'){ - lock(resource: "master-nano-01", inversePrecedence: true) { - deleteDir() - checkout scm - sh '''#!/bin/bash - env - # Clean up old processes - pkill -f selenium -9 || true - pkill -f Xvfb -9 || true - rm -rf /tmp/.X0-lock || true - pkill -f app.js || true - pkill -f webpack-dev-server -9 || true +environment { + ON_JENKINS = 'TRUE' +} +node('master-nano-01'){ + lock(resource: "master-nano-01", inversePrecedence: true) { + stage ('Cleanup Orphaned Processes') { + try { + sh ''' + # Clean up old processes + cd /var/lib/jenkins/lisk-test-nano + bash lisk.sh stop_node + pkill -f selenium -9 || true + pkill -f Xvfb -9 || true + rm -rf /tmp/.X0-lock || true + pkill -f webpack -9 || true + ''' + } catch (err) { + currentBuild.result = 'FAILURE' + milestone 1 + error('Stopping build, installation failed') + } + } + + stage ('Prepare Workspace') { + try { + deleteDir() + checkout scm + } catch (err) { + currentBuild.result = 'FAILURE' + milestone 1 + error('Stopping build, Checkout failed') + } + } + + stage ('Start Lisk Core') { + try { + sh '''#!/bin/bash + cd /var/lib/jenkins/lisk-test-nano + bash lisk.sh rebuild -0 + ''' + } catch (err) { + currentBuild.result = 'FAILURE' + milestone 1 + error('Stopping build, Lisk Core failed to start') + } + } - # Start lisk and make sure its current - cd /var/lib/jenkins/workspace/ - git clone https://github.com/LiskHQ/lisk.git - cd /var/lib/jenkins/workspace/lisk - git checkout development - git pull - dropdb lisk_test || true - createdb lisk_test - psql -d lisk_test -c "alter user "$USER" with password 'password';" - cp /var/lib/jenkins/workspace/lisk-node-Linux-x86_64.tar.gz . - tar -zxvf lisk-node-Linux-x86_64.tar.gz - npm install - git submodule init - git submodule update - cd public - npm install - bower install - grunt release - cd .. - cd test/lisk-js/; npm install; cd ../.. - cp test/config.json test/genesisBlock.json . - export NODE_ENV=test - BUILD_ID=dontKillMe ~/start_lisk.sh + stage ('Build Nano') { + try { + sh '''#!/bin/bash + # Build nano + cd $WORKSPACE/src + npm install - # Build nano - cd $WORKSPACE/src - npm install + # Add coveralls config file + cp ~/.coveralls.yml-nano .coveralls.yml - # Add coveralls config file - cp ~/.coveralls.yml-nano .coveralls.yml + # Run Build + npm run build + ''' + } catch (err) { + currentBuild.result = 'FAILURE' + milestone 1 + error('Stopping build, Nano build failed') + } + } - # Run Build - npm run build + stage ('Run Tests') { + try { + sh ''' + # Run test + cd $WORKSPACE/src + npm run test + ''' + } catch (err) { + currentBuild.result = 'FAILURE' + error('Stopping build, Test suite failed') + } + } - # Run test - npm run test + stage ('Start Dev Server and Run Tests') { + try { + sh ''' + # Run Dev build and Build + cd $WORKSPACE/src + export NODE_ENV= + npm run dev &> .lisk-nano.log & + sleep 20 - # Run Dev build and Build - export NODE_ENV= - npm run dev &> .lisk-nano.log & - sleep 20 + # End to End test configuration + export DISPLAY=:99 + Xvfb :99 -ac -screen 0 1280x1024x24 & + ./node_modules/protractor/bin/webdriver-manager update + ./node_modules/protractor/bin/webdriver-manager start & - # End to End test configuration - export DISPLAY=:99 - Xvfb :99 -ac -screen 0 1024x768x24 & - ./node_modules/protractor/bin/webdriver-manager update - ./node_modules/protractor/bin/webdriver-manager start & + # Prepare lisk core for testing + bash ~/tx.sh - # Prepare lisk core for testing - bash ~/tx.sh + # Run End to End Tests + npm run e2e-test - # Run End to End Tests - npm run e2e-test + cd /var/lib/jenkins/lisk-test-nano + bash lisk.sh stop_node + pkill -f selenium -9 || true + pkill -f Xvfb -9 || true + rm -rf /tmp/.X0-lock || true + pkill -f webpack -9 || true - pkill -f selenium -9 || true - pkill -f Xvfb -9 || true - rm -rf /tmp/.X0-lock || true - pkill -f app.js || true - pkill -f webpack-dev-server -9 || true - ''' - milestone 1 - } - } + ''' + } catch (err) { + currentBuild.result = 'FAILURE' + milestone 1 + error('Stopping build, End to End Test suite failed') } } + + stage ('Set milestone') { + milestone 1 + } } } From 270acbfa04093406ff0bcce6b81a141b0f96e3a7 Mon Sep 17 00:00:00 2001 From: isabello Date: Mon, 15 May 2017 16:50:36 +0200 Subject: [PATCH 2/6] Move transaction submission prior to tests --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e739e149b..77ca46d5b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -81,6 +81,9 @@ node('master-nano-01'){ stage ('Start Dev Server and Run Tests') { try { sh ''' + # Prepare lisk core for testing + bash ~/tx.sh + # Run Dev build and Build cd $WORKSPACE/src export NODE_ENV= @@ -93,9 +96,6 @@ node('master-nano-01'){ ./node_modules/protractor/bin/webdriver-manager update ./node_modules/protractor/bin/webdriver-manager start & - # Prepare lisk core for testing - bash ~/tx.sh - # Run End to End Tests npm run e2e-test From ac7ebf52c1ef70a3413abd58bab460117a3c756a Mon Sep 17 00:00:00 2001 From: isabello Date: Wed, 17 May 2017 10:49:36 +0200 Subject: [PATCH 3/6] Add electron install --- Jenkinsfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 77ca46d5b..06c19ce92 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -48,6 +48,9 @@ node('master-nano-01'){ stage ('Build Nano') { try { sh '''#!/bin/bash + # Install Electron + npm install + # Build nano cd $WORKSPACE/src npm install From 42aba2be424a1c4e1113ef11925ab309967d4eb3 Mon Sep 17 00:00:00 2001 From: isabello Date: Wed, 17 May 2017 11:47:45 +0200 Subject: [PATCH 4/6] Repoint Jenkins to new host --- Jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 06c19ce92..5df97aded 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,13 +1,13 @@ environment { ON_JENKINS = 'TRUE' } -node('master-nano-01'){ +node('lisk-nano-01'){ lock(resource: "master-nano-01", inversePrecedence: true) { stage ('Cleanup Orphaned Processes') { try { sh ''' # Clean up old processes - cd /var/lib/jenkins/lisk-test-nano + cd ~/lisk-test-nano bash lisk.sh stop_node pkill -f selenium -9 || true pkill -f Xvfb -9 || true @@ -35,7 +35,7 @@ node('master-nano-01'){ stage ('Start Lisk Core') { try { sh '''#!/bin/bash - cd /var/lib/jenkins/lisk-test-nano + cd ~/lisk-test-nano bash lisk.sh rebuild -0 ''' } catch (err) { @@ -102,7 +102,7 @@ node('master-nano-01'){ # Run End to End Tests npm run e2e-test - cd /var/lib/jenkins/lisk-test-nano + cd ~/lisk-test-nano bash lisk.sh stop_node pkill -f selenium -9 || true pkill -f Xvfb -9 || true From 875fa3dfe0f38feb27f3b6ac00a6b3f2afa3b472 Mon Sep 17 00:00:00 2001 From: isabello Date: Wed, 17 May 2017 11:55:55 +0200 Subject: [PATCH 5/6] Add additional sleep before starting selenium --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5df97aded..188dd09e8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -91,7 +91,7 @@ node('lisk-nano-01'){ cd $WORKSPACE/src export NODE_ENV= npm run dev &> .lisk-nano.log & - sleep 20 + sleep 30 # End to End test configuration export DISPLAY=:99 From 8091bc8781f3b45eefc170dbe493f01281f65c55 Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Thu, 18 May 2017 09:00:25 +0200 Subject: [PATCH 6/6] Fix forging unit tests --- src/app/components/forging/forging.pug | 2 +- src/test/components/forging/forging.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/components/forging/forging.pug b/src/app/components/forging/forging.pug index 0d09bbff1..aad7b552a 100644 --- a/src/app/components/forging/forging.pug +++ b/src/app/components/forging/forging.pug @@ -44,7 +44,7 @@ div.offline-hide div Approval div.progress-label {{$ctrl.delegate.approval}}% round-progress(max='100', current='$ctrl.delegate.approval', color='#0288D1') - md-card(layout='column', ng-if='$ctrl.delegate.username') + md-card.forged-blocks(layout='column', ng-if='$ctrl.delegate.username') md-card-title md-card-title-text span.md-title Forged Blocks diff --git a/src/test/components/forging/forging.spec.js b/src/test/components/forging/forging.spec.js index fe464d382..4b672e72e 100644 --- a/src/test/components/forging/forging.spec.js +++ b/src/test/components/forging/forging.spec.js @@ -113,7 +113,7 @@ describe('Forging component', () => { const FORGED_BLOCKS_TITLE = 'Forged Blocks'; it(`should contain a card with title ${FORGED_BLOCKS_TITLE}`, () => { - expect(element.find('md-card .md-title').text()).to.equal(FORGED_BLOCKS_TITLE); + expect(element.find('md-card.forged-blocks .md-title').text()).to.equal(FORGED_BLOCKS_TITLE); }); });