Skip to content

Commit 67a8cb0

Browse files
Merge pull request #4530 from ipfs/feat/sharness-junit
sharness: Generate JUnit test reports
2 parents 922f821 + fe62f77 commit 67a8cb0

File tree

91 files changed

+530
-105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+530
-105
lines changed

ci/Jenkinsfile

+169
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
import groovy.transform.Field
2+
3+
/* SETTINGS */
4+
5+
def test = 'go test -v ./...'
6+
7+
def fast_build_platforms = [
8+
['linux', 'amd64'],
9+
]
10+
11+
def build_platforms = [
12+
['windows', '386'],
13+
['windows', 'amd64'],
14+
15+
['linux', 'arm'],
16+
['linux', 'arm64'],
17+
['linux', '386'],
18+
19+
['darwin', '386'],
20+
['darwin', 'amd64'],
21+
22+
['freebsd', 'amd64']
23+
]
24+
25+
/* PIPELINE UTILS */
26+
27+
def setupStep(nodeLabel, f) {
28+
node(label: nodeLabel) {
29+
def ps = nodeLabel != 'windows' ? '/' : '\\'
30+
def psep = nodeLabel != 'windows' ? ':' : ';'
31+
32+
def root = tool name: '1.9.2', type: 'go'
33+
def jobNameArr = "${JOB_NAME}"
34+
def jobName = jobNameArr.split("/")[0..1].join(nodeLabel != 'windows' ? '/' : '\\\\').toLowerCase()
35+
def subName = jobNameArr.split("/")[2].toLowerCase()
36+
def originalWs = "${WORKSPACE}"
37+
38+
ws("${originalWs}${ps}src${ps}github.com${ps}${jobName}") {
39+
def goEnv = ["GOROOT=${root}", "GOPATH=${originalWs}", "SUBNAME=${subName}", "PATH=$PATH${psep}${root}${ps}bin${psep}${originalWs}${ps}bin"]
40+
withEnv(goEnv) {
41+
checkout scm
42+
43+
def run = nodeLabel != 'windows' ? this.&sh : this.&bat
44+
45+
f(run)
46+
}
47+
}
48+
}
49+
}
50+
51+
def gobuild_step(list) {
52+
setupStep('linux') { run ->
53+
run "make gx-deps"
54+
55+
list.each { platform ->
56+
withEnv(["GOOS=${platform[0]}", "GOARCH=${platform[1]}"]) {
57+
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"
58+
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 ."
59+
archiveArtifacts artifacts: "cmd/ipfs/go-ipfs_${env.GOOS}-${env.GOARCH}-${env.SUBNAME}-${env.BUILD_NUMBER}.tar.gz", fingerprint: true
60+
}
61+
}
62+
}
63+
}
64+
65+
/* PIPELINE */
66+
67+
ansiColor('xterm') { withEnv(['TERM=xterm-color']) { timeout(time: 30, unit: 'MINUTES') {
68+
stage('Checks') {
69+
parallel(
70+
'go fmt': {
71+
setupStep('linux') { run ->
72+
run 'make test_go_fmt'
73+
}
74+
},
75+
'go vet': {
76+
setupStep('linux') { run ->
77+
run 'go vet ./...'
78+
}
79+
},
80+
'go build': {
81+
gobuild_step(fast_build_platforms)
82+
}
83+
)
84+
}
85+
86+
stage('Tests') {
87+
parallel(
88+
'go build (other platforms)': {
89+
gobuild_step(build_platforms)
90+
},
91+
windows: {
92+
setupStep('windows') { run ->
93+
run 'go get -v github.com/jstemmer/go-junit-report github.com/whyrusleeping/gx github.com/whyrusleeping/gx-go'
94+
run "gx install --global"
95+
96+
try {
97+
run test + ' -tags="nofuse" > output & type output'
98+
run 'type output | go-junit-report > junit-report-windows.xml'
99+
} catch (err) {
100+
throw err
101+
} finally {
102+
/* IGNORE TEST FAILS */
103+
/* junit allowEmptyResults: true, testResults: 'junit-report-*.xml' */
104+
}
105+
}
106+
},
107+
linux: {
108+
setupStep('linux') { run ->
109+
run 'go get -v github.com/jstemmer/go-junit-report'
110+
run "make gx-deps"
111+
112+
try {
113+
run test + ' -tags="nofuse" 2>&1 | tee output'
114+
run 'cat output | go-junit-report > junit-report-linux.xml'
115+
} catch (err) {
116+
throw err
117+
} finally {
118+
junit allowEmptyResults: true, testResults: 'junit-report-*.xml'
119+
}
120+
}
121+
},
122+
linuxSharness: {
123+
setupStep('linux') { run ->
124+
run 'go get -v github.com/jstemmer/go-junit-report'
125+
run "make gx-deps"
126+
127+
try {
128+
run "make -j12 -Otarget test/sharness/test-results/sharness.xml CONTINUE_ON_S_FAILURE=1 TEST_NO_FUSE=1 TEST_NO_DOCKER=1"
129+
} catch (err) {
130+
throw err
131+
} finally {
132+
junit allowEmptyResults: true, testResults: 'test/sharness/test-results/sharness.xml'
133+
}
134+
}
135+
},
136+
macOS: {
137+
setupStep('macos') { run ->
138+
run 'go get -v github.com/jstemmer/go-junit-report'
139+
run "make gx-deps"
140+
141+
try {
142+
run test + ' -tags="nofuse" 2>&1 | tee output'
143+
run 'cat output | go-junit-report > junit-report-macos.xml'
144+
} catch (err) {
145+
throw err
146+
} finally {
147+
/* IGNORE TEST FAILS */
148+
/* junit 'junit-report-*.xml' */
149+
}
150+
}
151+
},
152+
macSharness: {
153+
setupStep('macos') { run ->
154+
run 'go get -v github.com/jstemmer/go-junit-report'
155+
run "make gx-deps"
156+
157+
try {
158+
run "make -j12 test/sharness/test-results/sharness.xml CONTINUE_ON_S_FAILURE=1 TEST_NO_FUSE=1"
159+
} catch (err) {
160+
throw err
161+
} finally {
162+
/* IGNORE TEST FAILS */
163+
/* junit allowEmptyResults: true, testResults: 'test/sharness/test-results/sharness.xml' */
164+
}
165+
}
166+
},
167+
)
168+
}
169+
}}}

ci/jenkins

-1
This file was deleted.

test/sharness/Rules.mk

+9
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,23 @@ export MAKE_SKIP_PATH=1
2929

3030
$(T_$(d)): $$(DEPS_$(d)) # use second expansion so coverage can inject dependency
3131
@echo "*** $@ ***"
32+
ifeq ($(CONTINUE_ON_S_FAILURE),1)
33+
-@(cd $(@D) && ./$(@F)) 2>&1
34+
else
3235
@(cd $(@D) && ./$(@F)) 2>&1
36+
endif
3337
.PHONY: $(T_$(d))
3438

3539
$(d)/aggregate: $(T_$(d))
3640
@echo "*** $@ ***"
3741
@(cd $(@D) && ./lib/test-aggregate-results.sh)
3842
.PHONY: $(d)/aggregate
3943

44+
$(d)/test-results/sharness.xml: export TEST_GENERATE_JUNIT=1
45+
$(d)/test-results/sharness.xml: test_sharness_expensive
46+
@echo "*** $@ ***"
47+
@(cd $(@D)/.. && ./lib/gen-junit-report.sh)
48+
4049
$(d)/clean-test-results:
4150
rm -rf $(@D)/test-results
4251
.PHONY: $(d)/clean-test-results

0 commit comments

Comments
 (0)