Skip to content

sharness: Generate JUnit test reports #4530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 169 additions & 0 deletions ci/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
import groovy.transform.Field

/* SETTINGS */

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']
]

/* PIPELINE UTILS */

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') { run ->
run "make gx-deps"

list.each { platform ->
withEnv(["GOOS=${platform[0]}", "GOARCH=${platform[1]}"]) {
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"
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 ."
archiveArtifacts artifacts: "cmd/ipfs/go-ipfs_${env.GOOS}-${env.GOARCH}-${env.SUBNAME}-${env.BUILD_NUMBER}.tar.gz", fingerprint: true
}
}
}
}

/* PIPELINE */

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 vet': {
setupStep('linux') { run ->
run 'go vet ./...'
}
},
'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 {
/* IGNORE TEST FAILS */
/* 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 TEST_NO_DOCKER=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 {
/* IGNORE TEST FAILS */
/* 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 {
/* IGNORE TEST FAILS */
/* junit allowEmptyResults: true, testResults: 'test/sharness/test-results/sharness.xml' */
}
}
},
)
}
}}}
1 change: 0 additions & 1 deletion ci/jenkins

This file was deleted.

9 changes: 9 additions & 0 deletions test/sharness/Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,23 @@ export MAKE_SKIP_PATH=1

$(T_$(d)): $$(DEPS_$(d)) # use second expansion so coverage can inject dependency
@echo "*** $@ ***"
ifeq ($(CONTINUE_ON_S_FAILURE),1)
-@(cd $(@D) && ./$(@F)) 2>&1
else
@(cd $(@D) && ./$(@F)) 2>&1
endif
.PHONY: $(T_$(d))

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

$(d)/test-results/sharness.xml: export TEST_GENERATE_JUNIT=1
$(d)/test-results/sharness.xml: test_sharness_expensive
@echo "*** $@ ***"
@(cd $(@D)/.. && ./lib/gen-junit-report.sh)

$(d)/clean-test-results:
rm -rf $(@D)/test-results
.PHONY: $(d)/clean-test-results
Expand Down
Loading