@cryptotaxi247 / kubo / commits / d6fe0c195

ci: New Jenkinsfile

License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>

Łukasz Magiera committed Mar 14, 2018 at 23:13 UTC d6fe0c195d85d6c52fe5b6a0af303b50ebfbcb71
4 files changed +155 -3
ci/Jenkinsfile new
+153
@@ -0,0 +1,153 @@
1 +import groovy.transform.Field
2 +
3 +def test = 'go test -v ./...'
4 +
5 +def fast_build_platforms = [
6 + ['linux', 'amd64'],
7 +]
8 +
9 +def build_platforms = [
10 + ['windows', '386'],
11 + ['windows', 'amd64'],
12 +
13 + ['linux', 'arm'],
14 + ['linux', 'arm64'],
15 + ['linux', '386'],
16 +
17 + ['darwin', '386'],
18 + ['darwin', 'amd64'],
19 +
20 + ['freebsd', 'amd64']
21 +]
22 +
23 +def setupStep(nodeLabel, f) {
24 + node(label: nodeLabel) {
25 + def ps = nodeLabel != 'windows' ? '/' : '\\'
26 + def psep = nodeLabel != 'windows' ? ':' : ';'
27 +
28 + def root = tool name: '1.9.2', type: 'go'
29 + def jobNameArr = "${JOB_NAME}"
30 + def jobName = jobNameArr.split("/")[0..1].join(nodeLabel != 'windows' ? '/' : '\\\\').toLowerCase()
31 + def subName = jobNameArr.split("/")[2].toLowerCase()
32 + def originalWs = "${WORKSPACE}"
33 +
34 + ws("${originalWs}${ps}src${ps}github.com${ps}${jobName}") {
35 + def goEnv = ["GOROOT=${root}", "GOPATH=${originalWs}", "SUBNAME=${subName}", "PATH=$PATH${psep}${root}${ps}bin${psep}${originalWs}${ps}bin"]
36 + withEnv(goEnv) {
37 + checkout scm
38 +
39 + def run = nodeLabel != 'windows' ? this.&sh : this.&bat
40 +
41 + f(run)
42 + }
43 + }
44 + }
45 +}
46 +
47 +def gobuild_step(list) {
48 + setupStep('linux') {
49 + list.each { platform ->
50 + withEnv(["GOOS=${platform[0]}", "GOARCH=${platform[1]}"]) {
51 + 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"
52 + 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 ."
53 + archiveArtifacts artifacts: "cmd/ipfs/go-ipfs_${env.GOOS}-${env.GOARCH}-${env.SUBNAME}-${env.BUILD_NUMBER}.tar.gz", fingerprint: true
54 + }
55 + }
56 + }
57 +}
58 +
59 +ansiColor('xterm') { withEnv(['TERM=xterm-color']) { timeout(time: 30, unit: 'MINUTES') {
60 + stage('Checks') {
61 + parallel(
62 + 'go fmt': {
63 + setupStep('linux') { run ->
64 + run 'make test_go_fmt'
65 + }
66 + },
67 + 'go build': {
68 + gobuild_step(fast_build_platforms)
69 + }
70 + )
71 + }
72 +
73 + stage('Tests') {
74 + parallel(
75 + 'go build (other platforms)': {
76 + gobuild_step(build_platforms)
77 + },
78 + windows: {
79 + setupStep('windows') { run ->
80 + run 'go get -v github.com/jstemmer/go-junit-report github.com/whyrusleeping/gx github.com/whyrusleeping/gx-go'
81 + run "gx install --global"
82 +
83 + try {
84 + run test + ' -tags="nofuse" > output & type output'
85 + run 'type output | go-junit-report > junit-report-windows.xml'
86 + } catch (err) {
87 + throw err
88 + } finally {
89 + junit allowEmptyResults: true, testResults: 'junit-report-*.xml'
90 + }
91 + }
92 + },
93 + linux: {
94 + setupStep('linux') { run ->
95 + run 'go get -v github.com/jstemmer/go-junit-report'
96 + run "make gx-deps"
97 +
98 + try {
99 + run test + ' -tags="nofuse" 2>&1 | tee output'
100 + run 'cat output | go-junit-report > junit-report-linux.xml'
101 + } catch (err) {
102 + throw err
103 + } finally {
104 + junit allowEmptyResults: true, testResults: 'junit-report-*.xml'
105 + }
106 + }
107 + },
108 + linuxSharness: {
109 + setupStep('linux') { run ->
110 + run 'go get -v github.com/jstemmer/go-junit-report'
111 + run "make gx-deps"
112 +
113 + try {
114 + run "make -j12 -Otarget test/sharness/test-results/sharness.xml CONTINUE_ON_S_FAILURE=1 TEST_NO_FUSE=1"
115 + } catch (err) {
116 + throw err
117 + } finally {
118 + junit allowEmptyResults: true, testResults: 'test/sharness/test-results/sharness.xml'
119 + }
120 + }
121 + },
122 + macOS: {
123 + setupStep('macos') { run ->
124 + run 'go get -v github.com/jstemmer/go-junit-report'
125 + run "make gx-deps"
126 +
127 + try {
128 + run test + ' -tags="nofuse" 2>&1 | tee output'
129 + run 'cat output | go-junit-report > junit-report-macos.xml'
130 + } catch (err) {
131 + throw err
132 + } finally {
133 + junit 'junit-report-*.xml'
134 + }
135 + }
136 + },
137 + macSharness: {
138 + setupStep('macos') { run ->
139 + run 'go get -v github.com/jstemmer/go-junit-report'
140 + run "make gx-deps"
141 +
142 + try {
143 + run "make -j12 test/sharness/test-results/sharness.xml CONTINUE_ON_S_FAILURE=1 TEST_NO_FUSE=1"
144 + } catch (err) {
145 + throw err
146 + } finally {
147 + junit allowEmptyResults: true, testResults: 'test/sharness/test-results/sharness.xml'
148 + }
149 + }
150 + },
151 + )
152 + }
153 +}}}
ci/jenkins deleted
-1
@@ -1 +0,0 @@
1 -go-ipfs-jenkinsfile
test/sharness/lib/0001-Generate-partial-JUnit-reports.patch
+1 -1
@@ -196,7 +196,7 @@ index 6750ff7..dc99ef9 100644
196 + if test -n "$TEST_GENERATE_JUNIT"; then
197 + cat >>"$junit_results_path" <<-EOF
198 + <testsuite errors="$test_broken" failures="$((test_failure+test_fixed))" tests="$test_count" name="$SHARNESS_TEST_FILE">
199 -+ $(find .junit -name 'case-*' | sort | xargs -i cat "{}")
199 ++ $(find .junit -name 'case-*' | sort | xargs cat)
200 + </testsuite>
201 + EOF
202 + fi
test/sharness/lib/gen-junit-report.sh
+1 -1
@@ -3,6 +3,6 @@
3 cat > test-results/sharness.xml <<-EOF
4 <?xml version="1.0" encoding="UTF-8"?>
5 <testsuites name="sharness">
6 - $(find test-results -name '*.xml.part' | sort | xargs -i cat "{}")
6 + $(find test-results -name '*.xml.part' | sort | xargs cat)
7 </testsuites>
8 EOF