Skip to content

Commit

Permalink
ci: Run interop tests
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <[email protected]>
  • Loading branch information
magik6k committed May 31, 2018
1 parent 9818379 commit 971b64f
Showing 1 changed file with 63 additions and 47 deletions.
110 changes: 63 additions & 47 deletions ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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) {
Expand All @@ -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
}

Expand Down Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 971b64f

Please sign in to comment.