ci: New Jenkinsfile

License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
Łukasz Magiera 2018-03-14 23:13:37 +01:00
parent ea4a46250c
commit d6fe0c195d
4 changed files with 155 additions and 3 deletions

153
ci/Jenkinsfile vendored Normal file
View File

@ -0,0 +1,153 @@
import groovy.transform.Field
def test = 'go test -v ./...'
def fast_build_platforms = [
['linux', 'amd64'],
]
def build_platforms = [
['windows', '386'],
['windows', 'amd64'],
['linux', 'arm'],
['linux', 'arm64'],
['linux', '386'],
['darwin', '386'],
['darwin', 'amd64'],
['freebsd', 'amd64']
]
def setupStep(nodeLabel, f) {
node(label: nodeLabel) {
def ps = nodeLabel != 'windows' ? '/' : '\\'
def psep = nodeLabel != 'windows' ? ':' : ';'
def root = tool name: '1.9.2', type: 'go'
def jobNameArr = "${JOB_NAME}"
def jobName = jobNameArr.split("/")[0..1].join(nodeLabel != 'windows' ? '/' : '\\\\').toLowerCase()
def subName = jobNameArr.split("/")[2].toLowerCase()
def originalWs = "${WORKSPACE}"
ws("${originalWs}${ps}src${ps}github.com${ps}${jobName}") {
def goEnv = ["GOROOT=${root}", "GOPATH=${originalWs}", "SUBNAME=${subName}", "PATH=$PATH${psep}${root}${ps}bin${psep}${originalWs}${ps}bin"]
withEnv(goEnv) {
checkout scm
def run = nodeLabel != 'windows' ? this.&sh : this.&bat
f(run)
}
}
}
}
def gobuild_step(list) {
setupStep('linux') {
list.each { platform ->
withEnv(["GOOS=${platform[0]}", "GOARCH=${platform[1]}"]) {
sh "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"
sh "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
}
}
}
}
ansiColor('xterm') { withEnv(['TERM=xterm-color']) { timeout(time: 30, unit: 'MINUTES') {
stage('Checks') {
parallel(
'go fmt': {
setupStep('linux') { run ->
run 'make test_go_fmt'
}
},
'go build': {
gobuild_step(fast_build_platforms)
}
)
}
stage('Tests') {
parallel(
'go build (other platforms)': {
gobuild_step(build_platforms)
},
windows: {
setupStep('windows') { run ->
run 'go get -v github.com/jstemmer/go-junit-report github.com/whyrusleeping/gx github.com/whyrusleeping/gx-go'
run "gx install --global"
try {
run test + ' -tags="nofuse" > output & type output'
run 'type output | go-junit-report > junit-report-windows.xml'
} catch (err) {
throw err
} finally {
junit allowEmptyResults: true, testResults: 'junit-report-*.xml'
}
}
},
linux: {
setupStep('linux') { run ->
run 'go get -v github.com/jstemmer/go-junit-report'
run "make gx-deps"
try {
run test + ' -tags="nofuse" 2>&1 | tee output'
run 'cat output | go-junit-report > junit-report-linux.xml'
} catch (err) {
throw err
} finally {
junit allowEmptyResults: true, testResults: 'junit-report-*.xml'
}
}
},
linuxSharness: {
setupStep('linux') { run ->
run 'go get -v github.com/jstemmer/go-junit-report'
run "make gx-deps"
try {
run "make -j12 -Otarget test/sharness/test-results/sharness.xml CONTINUE_ON_S_FAILURE=1 TEST_NO_FUSE=1"
} catch (err) {
throw err
} finally {
junit allowEmptyResults: true, testResults: 'test/sharness/test-results/sharness.xml'
}
}
},
macOS: {
setupStep('macos') { run ->
run 'go get -v github.com/jstemmer/go-junit-report'
run "make gx-deps"
try {
run test + ' -tags="nofuse" 2>&1 | tee output'
run 'cat output | go-junit-report > junit-report-macos.xml'
} catch (err) {
throw err
} finally {
junit 'junit-report-*.xml'
}
}
},
macSharness: {
setupStep('macos') { run ->
run 'go get -v github.com/jstemmer/go-junit-report'
run "make gx-deps"
try {
run "make -j12 test/sharness/test-results/sharness.xml CONTINUE_ON_S_FAILURE=1 TEST_NO_FUSE=1"
} catch (err) {
throw err
} finally {
junit allowEmptyResults: true, testResults: 'test/sharness/test-results/sharness.xml'
}
}
},
)
}
}}}

View File

@ -1 +0,0 @@
go-ipfs-jenkinsfile

View File

@ -196,7 +196,7 @@ index 6750ff7..dc99ef9 100644
+ if test -n "$TEST_GENERATE_JUNIT"; then
+ cat >>"$junit_results_path" <<-EOF
+ <testsuite errors="$test_broken" failures="$((test_failure+test_fixed))" tests="$test_count" name="$SHARNESS_TEST_FILE">
+ $(find .junit -name 'case-*' | sort | xargs -i cat "{}")
+ $(find .junit -name 'case-*' | sort | xargs cat)
+ </testsuite>
+ EOF
+ fi

View File

@ -3,6 +3,6 @@
cat > test-results/sharness.xml <<-EOF
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="sharness">
$(find test-results -name '*.xml.part' | sort | xargs -i cat "{}")
$(find test-results -name '*.xml.part' | sort | xargs cat)
</testsuites>
EOF