From 98183793c56226bff6c9eef62199829a41653566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 30 May 2018 10:47:31 +0200 Subject: [PATCH] ci: Run js-ipfs-api tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Ɓukasz Magiera --- ci/Jenkinsfile | 87 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 2 deletions(-) diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index 02676b378b2..ea0ebfb61f2 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -28,6 +28,15 @@ def build_platforms = [ ['freebsd', 'amd64'] ] +// js-ipfs-api tests +def js_api_commit = '7e78ee232bea8e5ea92bcfcff949b4ed671c2d50' // 22.0.1 +def js_api_platforms = ['linux', 'macos'] +def js_api_node_versions = ['8.11.1', '9.2.0'] + +def yarn_version = '1.5.1' +def yarn_path = './node_modules/.bin/yarn' + + /* PIPELINE UTILS */ def setupStep(nodeLabel, f) { @@ -63,6 +72,7 @@ def gobuild_step(list) { run "go build -i -ldflags=\"-X github.com/ipfs/go-ipfs/repo/config.CurrentCommit=${env.SUBNAME}-${env.BUILD_NUMBER}\" -o cmd/ipfs/ipfs github.com/ipfs/go-ipfs/cmd/ipfs" run "cp cmd/ipfs/ipfs cmd/ipfs/dist; cd cmd/ipfs/dist; tar -czvf ../go-ipfs_${env.GOOS}-${env.GOARCH}-${env.SUBNAME}-${env.BUILD_NUMBER}.tar.gz ." archiveArtifacts artifacts: "cmd/ipfs/go-ipfs_${env.GOOS}-${env.GOARCH}-${env.SUBNAME}-${env.BUILD_NUMBER}.tar.gz", fingerprint: true + stash name: "ipfs-${env.GOOS}-${env.GOARCH}", includes: "cmd/ipfs/ipfs" } } } @@ -70,8 +80,23 @@ def gobuild_step(list) { /* PIPELINE */ +def reportedStage(name, fn) { + githubNotify description: "Running ${name}", status: 'PENDING', context: "continuous-integration/jenkins/${name}" + + try { + stage(name.capitalize()) { + fn() + } + githubNotify description: "${name.capitalize()} passed", status: 'SUCCESS', context: "continuous-integration/jenkins/${name}" + } catch (err) { + githubNotify description: '${name.capitalize()} failed', status: 'FAILURE', context: "continuous-integration/jenkins/${name}" + throw err + } + +} + ansiColor('xterm') { withEnv(['TERM=xterm-color']) { - stage('Checks') { + reportedStage('checks') { parallel( 'go fmt': { setupStep('linux') { run -> @@ -96,7 +121,8 @@ ansiColor('xterm') { withEnv(['TERM=xterm-color']) { ) } - stage('Tests') { + + reportedStage('tests') { parallel( 'go build (other platforms)': { timeout(time: build_timeout, unit: 'MINUTES') { @@ -191,4 +217,61 @@ ansiColor('xterm') { withEnv(['TERM=xterm-color']) { }, ) } + + reportedStage('apis') { + def jsApiStep = { os, nodeVer -> + return { -> + setupStep(os) { + switch (os) { + case "linux": + unstash("ipfs-linux-amd64") + break + case "macos": + unstash("ipfs-darwin-amd64") + break + } + + withEnv(['IPFS_GO_EXEC=../cmd/ipfs/ipfs', 'CI=true']) { + dir('.js-ipfs-api') { + checkout changelog: false, scm: [$class: 'GitSCM', branches: [[name: "${js_api_commit}"]], userRemoteConfigs: [[url: 'https://github.com/ipfs/js-ipfs-api']]] + + //todo: deduplicate with https://github.com/ipfs/jenkins-libs/blob/master/vars/javascript.groovy somehow + + fileExists 'package.json' + nodejs(nodeVer) { + sh 'rm -rf node_modules/' + sh 'npm install yarn@' + yarn_version + sh yarn_path + ' --mutex network --no-lockfile' + def runTest = { -> + try { + sh yarn_path + ' test' + } finally { + junit allowEmptyResults: true, testResults: 'junit-report-*.xml' + } + } + + if (os == "linux") { + wrap([$class: 'Xvfb', parallelBuild: true, autoDisplayName: true]) { + runTest() + } + } else { + runTest() + } + } + } + } + } + } + } + + def steps = [:] + js_api_platforms.each {os -> + js_api_node_versions.each { nodeVer -> + steps["js-api-${os}-${nodeVer}"] = jsApiStep(os, nodeVer) + } + } + + parallel steps + } + }}