From fe55312548d5bcdbbec5a0bebb218a162f122b17 Mon Sep 17 00:00:00 2001 From: isabello Date: Tue, 9 May 2017 11:32:40 +0200 Subject: [PATCH 1/7] Add Jenkinsfile to enable Jenkins-CI --- Jenkinsfile | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..468d40405 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,113 @@ +pipeline { + agent { label 'master-nano-01' } + environment { + ON_JENKINS = 'TRUE' + } + stages { + stage ('Lisk Provisioning') { + steps { + parallel( + "Build Components for Nano" : { + node('master-nano-01'){ + lock(resource: "master-nano-01", inversePrecedence: true) { + sh '''#!/bin/bash + cd /var/lib/jenkins/workspace/ + pkill -f app.js || true + rm -rf lisk + git clone https://github.com/LiskHQ/lisk.git + cd lisk + git checkout development + 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 + ''' + } + } + node('master-nano-01'){ + lock(resource: "master-nano-01", inversePrecedence: true) { + sh '''#!/bin/bash + pkill -f selenium -9 || true + pkill -f Xvfb -9 || true + rm -rf /tmp/.X0-lock || true + cd /var/lib/jenkins/workspace/ + rm -rf lisk-nano + git clone https://github.com/LiskHQ/lisk-nano.git + cd lisk-nano + git checkout $BRANCH_NAME + npm install + cd src + npm install + ''' + } + } + }) + } + } + stage ('Run Tests') { + steps { + node('master-nano-01'){ + lock(resource: "master-nano-01", inversePrecedence: true) { + sh '''#!/bin/bash + export CI_PULL_REQUEST=$ghprbPullId + cd /var/lib/jenkins/workspace/lisk-nano/src + cp ~/.coveralls.yml-nano .coveralls.yml + npm run build + npm run dev &> .lisk-nano.log & + bash ~/tx.sh + npm run test + + # Commented until e2e is ready + # export CHROME_BIN=chromium-browser + # export DISPLAY=:0.0 + # Xvfb :0 -ac -screen 0 1280x1024x24 & + # ./node_modules/protractor/bin/webdriver-manager update + # npm run e2e-test + ''' + } + } + } + } + stage ('Output logging') { + steps { + parallel( + "Output Logs from Testing" : { + node('master-nano-01'){ + sh '''#!/bin/bash + cd /var/lib/jenkins/workspace/lisk-nano/src + # Commented until e2e is ready + # cat .protractor.log + cat .lisk-nano.log + ''' + } + }) + } + } + stage ('Node Cleanup') { + steps { + parallel( + "Cleanup Lisk-Core for Nano" : { + node('master-nano-01'){ + sh '''#!/bin/bash + pkill -f app.js -9 + pkill -f webpack-dev-server -9 + ''' + } + }) + } + } + } +} From 4ed0f0574872bb67747031b48dc8bfa9409d7f28 Mon Sep 17 00:00:00 2001 From: isabello Date: Tue, 9 May 2017 11:34:24 +0200 Subject: [PATCH 2/7] Implement Jenkins-ci reporting --- src/karma.conf.js | 22 ++++++++++++---------- src/package.json | 1 + 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/karma.conf.js b/src/karma.conf.js index 46f25eb94..d41bd107c 100644 --- a/src/karma.conf.js +++ b/src/karma.conf.js @@ -16,6 +16,7 @@ preprocessors[test] = ['webpack']; const opts = { onTravis: process.env.ON_TRAVIS, + onJenkins: process.env.ON_JENKINS, live: process.env.LIVE, }; @@ -43,14 +44,10 @@ module.exports = function (config) { // Rest results reporter to use // Possible values: 'dots', 'progress' // Available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['coverage', 'mocha'].concat(opts.onTravis ? ['coveralls'] : []), + reporters: ['coverage', 'mocha'].concat(opts.onTravis ? ['coveralls'] : []).concat(opts.onJenkins ? ['coveralls'] : []), preprocessors, - mochaReporter: { - output: 'autowatch', - }, - babelPreprocessor: { options: { presets: ['es2015'], @@ -82,11 +79,16 @@ module.exports = function (config) { }, coverageReporter: { - reporters: [ - { - type: opts.onTravis ? 'lcov' : 'html', - dir: 'coverage/', - }].concat(opts.onTravis ? [{ type: 'text' }] : []), + reporters: [{ + type: 'text', + dir: 'coverage/', + }, { + type: opts.onTravis ? 'lcov' : 'html', + dir: 'coverage/', + }, { + type: opts.onJenkins ? 'lcov' : 'html', + dir: 'coverage/', + }], }, // Start these browsers diff --git a/src/package.json b/src/package.json index d0a0fb576..e6e9bbceb 100644 --- a/src/package.json +++ b/src/package.json @@ -61,6 +61,7 @@ "karma-chrome-launcher": "=2.0.0", "karma-coverage": "=1.1.1", "karma-coveralls": "=1.1.2", + "karma-jenkins-reporter": "0.0.2", "karma-mocha": "=1.3.0", "karma-mocha-reporter": "=2.2.2", "karma-ng-html2js-preprocessor": "=1.0.0", From 2057f4cd4847699dfb3aa209ef13090beede40ca Mon Sep 17 00:00:00 2001 From: isabello Date: Tue, 9 May 2017 12:23:04 +0200 Subject: [PATCH 3/7] Add conditional check for Pull Request --- Jenkinsfile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 468d40405..0c47d4cd6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,8 +3,8 @@ pipeline { environment { ON_JENKINS = 'TRUE' } - stages { - stage ('Lisk Provisioning') { + stages { + stage ('Lisk Provisioning') { steps { parallel( "Build Components for Nano" : { @@ -57,31 +57,31 @@ pipeline { }) } } - stage ('Run Tests') { + stage ('Run Tests') { steps { node('master-nano-01'){ lock(resource: "master-nano-01", inversePrecedence: true) { sh '''#!/bin/bash - export CI_PULL_REQUEST=$ghprbPullId + if [ -z ${ghprbPullId+x} ]; then echo "Not a PR build"; else export CI_PULL_REQUEST=$ghprbPullId; fi cd /var/lib/jenkins/workspace/lisk-nano/src cp ~/.coveralls.yml-nano .coveralls.yml npm run build npm run dev &> .lisk-nano.log & bash ~/tx.sh npm run test - + # Commented until e2e is ready # export CHROME_BIN=chromium-browser # export DISPLAY=:0.0 # Xvfb :0 -ac -screen 0 1280x1024x24 & # ./node_modules/protractor/bin/webdriver-manager update - # npm run e2e-test + # npm run e2e-test ''' } } } } - stage ('Output logging') { + stage ('Output logging') { steps { parallel( "Output Logs from Testing" : { @@ -89,20 +89,20 @@ pipeline { sh '''#!/bin/bash cd /var/lib/jenkins/workspace/lisk-nano/src # Commented until e2e is ready - # cat .protractor.log + # cat .protractor.log cat .lisk-nano.log ''' } }) } } - stage ('Node Cleanup') { + stage ('Node Cleanup') { steps { parallel( "Cleanup Lisk-Core for Nano" : { node('master-nano-01'){ sh '''#!/bin/bash - pkill -f app.js -9 + pkill -f app.js -9 pkill -f webpack-dev-server -9 ''' } From 084a49f89808f19fe2f4fe3c43baf3a3d41702b3 Mon Sep 17 00:00:00 2001 From: isabello Date: Tue, 9 May 2017 15:29:02 +0200 Subject: [PATCH 4/7] Remove .travis.yml to disable travis --- .travis.yml | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5c858b87f..000000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: node_js -node_js: - - 'node' # Latest stable Node.js release -cache: - directories: - - src/node_modules/ -env: - - ON_TRAVIS=true -before_install: cd src -before_script: - - npm install -script: - - npm run test - - npm run build - From 5df422d8807491743f9c59744f35c88b779e45b4 Mon Sep 17 00:00:00 2001 From: isabello Date: Wed, 10 May 2017 14:26:28 +0200 Subject: [PATCH 5/7] Rework Jenkinsfile --- Jenkinsfile | 146 ++++++++++++++++++++-------------------------------- 1 file changed, 57 insertions(+), 89 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0c47d4cd6..413cc5016 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,112 +1,80 @@ pipeline { - agent { label 'master-nano-01' } + agent none environment { - ON_JENKINS = 'TRUE' + ON_JENKINS = 'TRUE' } stages { - stage ('Lisk Provisioning') { - steps { - parallel( - "Build Components for Nano" : { - node('master-nano-01'){ - lock(resource: "master-nano-01", inversePrecedence: true) { - sh '''#!/bin/bash - cd /var/lib/jenkins/workspace/ - pkill -f app.js || true - rm -rf lisk - git clone https://github.com/LiskHQ/lisk.git - cd lisk - git checkout development - 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 - ''' - } - } - node('master-nano-01'){ - lock(resource: "master-nano-01", inversePrecedence: true) { - sh '''#!/bin/bash - pkill -f selenium -9 || true - pkill -f Xvfb -9 || true - rm -rf /tmp/.X0-lock || true - cd /var/lib/jenkins/workspace/ - rm -rf lisk-nano - git clone https://github.com/LiskHQ/lisk-nano.git - cd lisk-nano - git checkout $BRANCH_NAME - npm install - cd src - npm install - ''' - } - } - }) - } - } - stage ('Run Tests') { + stage ('Lisk Provisioning') { steps { node('master-nano-01'){ - lock(resource: "master-nano-01", inversePrecedence: true) { - sh '''#!/bin/bash - if [ -z ${ghprbPullId+x} ]; then echo "Not a PR build"; else export CI_PULL_REQUEST=$ghprbPullId; fi - cd /var/lib/jenkins/workspace/lisk-nano/src + lock(resource: "master-nano-01", inversePrecedence: true) { + 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 + + # 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 + + # Build nano + cd $WORKSPACE/src + npm installå + + # Add coveralls config file cp ~/.coveralls.yml-nano .coveralls.yml - npm run build - npm run dev &> .lisk-nano.log & + + # Prepare lisk core for testing bash ~/tx.sh + + # Run test npm run test + # Run nano build + npm run build + # Commented until e2e is ready # export CHROME_BIN=chromium-browser # export DISPLAY=:0.0 # Xvfb :0 -ac -screen 0 1280x1024x24 & # ./node_modules/protractor/bin/webdriver-manager update # npm run e2e-test - ''' - } - } - } - } - stage ('Output logging') { - steps { - parallel( - "Output Logs from Testing" : { - node('master-nano-01'){ - sh '''#!/bin/bash - cd /var/lib/jenkins/workspace/lisk-nano/src + # Commented until e2e is ready # cat .protractor.log cat .lisk-nano.log - ''' + + pkill -f app.js -9 || true + pkill -f webpack-dev-server -9 || true + ''' + milestone 1 } - }) - } - } - stage ('Node Cleanup') { - steps { - parallel( - "Cleanup Lisk-Core for Nano" : { - node('master-nano-01'){ - sh '''#!/bin/bash - pkill -f app.js -9 - pkill -f webpack-dev-server -9 - ''' - } - }) + } } } } From 96eae6ea80eb997f305b07d8b31ff076b7727baf Mon Sep 17 00:00:00 2001 From: isabello Date: Wed, 10 May 2017 14:27:58 +0200 Subject: [PATCH 6/7] Remove errant character --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 413cc5016..12a8bc3aa 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -44,7 +44,7 @@ pipeline { # Build nano cd $WORKSPACE/src - npm installå + npm install # Add coveralls config file cp ~/.coveralls.yml-nano .coveralls.yml From 66da7afc9de209910255f50b40232875f38713f0 Mon Sep 17 00:00:00 2001 From: isabello Date: Wed, 10 May 2017 14:34:44 +0200 Subject: [PATCH 7/7] Stop running build --- Jenkinsfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 12a8bc3aa..9dc86fdf8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -55,9 +55,6 @@ pipeline { # Run test npm run test - # Run nano build - npm run build - # Commented until e2e is ready # export CHROME_BIN=chromium-browser # export DISPLAY=:0.0 @@ -67,7 +64,7 @@ pipeline { # Commented until e2e is ready # cat .protractor.log - cat .lisk-nano.log + # cat .lisk-nano.log pkill -f app.js -9 || true pkill -f webpack-dev-server -9 || true