From 971b64f125a94d4704c3d90604884db026482838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 31 May 2018 01:32:10 +0200 Subject: [PATCH] ci: Run interop 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 | 110 ++++++++++++++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 47 deletions(-) diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index ea0ebfb61f2..7fa5bebf5b8 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -28,10 +28,12 @@ def build_platforms = [ ['freebsd', 'amd64'] ] -// js-ipfs-api tests +/* js-* tests */ def js_api_commit = '7e78ee232bea8e5ea92bcfcff949b4ed671c2d50' // 22.0.1 +def interop_commit = '4bfac3c406cc77d16992f9236896d442f3bcf181' + def js_api_platforms = ['linux', 'macos'] -def js_api_node_versions = ['8.11.1', '9.2.0'] +def js_api_node_versions = [/*'8.11.1', */'9.2.0'] def yarn_version = '1.5.1' def yarn_path = './node_modules/.bin/yarn' @@ -78,6 +80,54 @@ def gobuild_step(list) { } } +/* JS BASED TESTS */ + +def jsTestStep = { os, nodeVer, repo, commit -> + 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-test') { + checkout changelog: false, scm: [$class: 'GitSCM', branches: [[name: commit]], userRemoteConfigs: [[url: repo]]] + + //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' + cleanWs() + } + } + + if (os == "linux") { + wrap([$class: 'Xvfb', parallelBuild: true, autoDisplayName: true]) { + runTest() + } + } else { + runTest() + } + } + } + } + } + } +} + /* PIPELINE */ def reportedStage(name, fn) { @@ -89,7 +139,7 @@ def reportedStage(name, 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}" + githubNotify description: "${name.capitalize()} failed", status: 'FAILURE', context: "continuous-integration/jenkins/${name}" throw err } @@ -218,56 +268,22 @@ 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() - } - } - } - } - } + reportedStage('interop') { + def steps = [:] + js_api_platforms.each {os -> + js_api_node_versions.each { nodeVer -> + steps["interop-${os}-${nodeVer}"] = jsTestStep(os, nodeVer, 'https://github.com/ipfs/interop', interop_commit) } } + parallel steps + } + + reportedStage('apis') { def steps = [:] js_api_platforms.each {os -> js_api_node_versions.each { nodeVer -> - steps["js-api-${os}-${nodeVer}"] = jsApiStep(os, nodeVer) + steps["js-api-${os}-${nodeVer}"] = jsTestStep(os, nodeVer, 'https://github.com/ipfs/js-ipfs-api', js_api_commit) } }