Skip to content

Commit 27ccbdf

Browse files
committed
add go report card to readme
1 parent cd716b2 commit 27ccbdf

File tree

3 files changed

+62
-37
lines changed

3 files changed

+62
-37
lines changed

Jenkinsfile

+45-37
Original file line numberDiff line numberDiff line change
@@ -29,49 +29,57 @@ def goSlaveContainer = containerTemplate(
2929

3030
podTemplate(label: 'mobile-cli-go', cloud: "openshift", containers: [goSlaveContainer]) {
3131
node ("mobile-cli-go") {
32-
sh "mkdir -p src/github.com/aerogear/mobile-cli"
33-
withEnv(["GOPATH=${env.WORKSPACE}/","PATH=${env.PATH}:${env.WORKSPACE}/bin"]) {
34-
dir ("src/github.com/aerogear/mobile-cli") {
35-
stage("Checkout") {
36-
checkout scm
37-
}
32+
withCredentials([string(
33+
credentialsId: "coveralls_io_token",
34+
variable: 'COVERALLS_TOKEN')]) {
3835

39-
stage ("Setup") {
40-
sh "glide install"
41-
}
36+
sh "mkdir -p src/github.com/aerogear/mobile-cli"
37+
withEnv(["GOPATH=${env.WORKSPACE}/","PATH=${env.PATH}:${env.WORKSPACE}/bin"]) {
38+
dir ("src/github.com/aerogear/mobile-cli") {
39+
stage("Checkout") {
40+
checkout scm
41+
}
4242

43-
stage ("Build") {
44-
sh "make build"
45-
}
46-
def project = sanitizeObjectName("mobile-cli-${env.CHANGE_AUTHOR}-${env.BUILD_TAG}")
47-
stage ("Run") {
48-
// workaround because of the https://issues.jboss.org/browse/FH-4471
49-
sh "mkdir -p /home/jenkins/.kube"
50-
sh "rm /home/jenkins/.kube/config || true"
51-
sh "oc config view > /home/jenkins/.kube/config"
52-
sh "oc new-project ${project}"
53-
//end of workaround
43+
stage ("Setup") {
44+
sh "glide install"
45+
sh "go get golang.org/x/tools/cmd/cover"
46+
sh "go get github.com/mattn/goveralls"
47+
}
5448

55-
sh "./mobile"
56-
}
57-
49+
stage ("Build") {
50+
sh "make coveralls_build COVERALLS_TOKEN=${COVERALLS_TOKEN}"
51+
}
52+
53+
def project = sanitizeObjectName("mobile-cli-${env.CHANGE_AUTHOR}-${env.BUILD_TAG}")
54+
stage ("Run") {
55+
// workaround because of the https://issues.jboss.org/browse/FH-4471
56+
sh "mkdir -p /home/jenkins/.kube"
57+
sh "rm /home/jenkins/.kube/config || true"
58+
sh "oc config view > /home/jenkins/.kube/config"
59+
sh "oc new-project ${project}"
60+
//end of workaround
5861

59-
stage ("Integration") {
60-
sh "oc project ${project}"
61-
sh "go test -timeout 30m -c ./integration"
62-
sh "./integration.test -test.short -test.v -prefix=test-${sanitizeObjectName(env.BRANCH_NAME)}-build-$BUILD_NUMBER -namespace=`oc project -q` -executable=`pwd`/mobile"
63-
}
62+
sh "./mobile"
63+
}
64+
6465

65-
stage ("Archive") {
66-
sh "mkdir out"
67-
sh "cp mobile out/"
68-
sh "cp integration.test out/"
69-
sh "cp -R integration out/integration"
70-
archiveArtifacts artifacts: 'out/**'
71-
}
66+
stage ("Integration") {
67+
sh "oc project ${project}"
68+
sh "go test -timeout 30m -c ./integration"
69+
sh "./integration.test -test.short -test.v -prefix=test-${sanitizeObjectName(env.BRANCH_NAME)}-build-$BUILD_NUMBER -namespace=`oc project -q` -executable=`pwd`/mobile"
70+
}
71+
72+
stage ("Archive") {
73+
sh "mkdir out"
74+
sh "cp mobile out/"
75+
sh "cp integration.test out/"
76+
sh "cp -R integration out/integration"
77+
archiveArtifacts artifacts: 'out/**'
78+
}
7279

73-
stage ("Clear Project") {
74-
"sh oc delete project ${project}"
80+
stage ("Clear Project") {
81+
"sh oc delete project ${project}"
82+
}
7583
}
7684
}
7785
}

Makefile

+13
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ setup:
1515
.PHONY: build
1616
build: setup check build_binary
1717

18+
.PHONY: coveralls_build
19+
build: setup coveralls_check build_binary
20+
1821
.PHONY: build_binary_linux
1922
build_binary_linux:
2023
env GOOS=linux GOARCH=amd64 go build -o mobile ./cmd/mobile
@@ -33,6 +36,13 @@ test-unit:
3336
go test -v -race -cover $(UNIT_TEST_FLAGS) \
3437
$(addprefix $(PKG)/,$(TEST_DIRS))
3538

39+
.PHONY: coveralls_test-unit
40+
coveralls_test-unit:
41+
@echo Running tests:
42+
go test -v -race -cover -covermode=atomic -coverprofile=coverage.out $(UNIT_TEST_FLAGS) \
43+
$(addprefix $(PKG)/,$(TEST_DIRS))
44+
goveralls -coverprofile=coverage.out -service=jenkins-ci -repotoken $(COVERALLS_TOKEN)
45+
3646
.PHONY: integration
3747
integration: build_binary
3848
go test -v ./integration -args -namespace=`oc project -q` -executable=`pwd`/mobile
@@ -54,6 +64,9 @@ fmt:
5464
.PHONY: check
5565
check: errcheck vet fmt test-unit
5666

67+
.PHONY: coveralls_check
68+
check: errcheck vet fmt coveralls_test-unit
69+
5770
integration_binary:
5871
go test -c -v ./integration
5972

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[![Go Report Card](https://goreportcard.com/badge/github.com/golang/crypto)](https://goreportcard.com/report/github.com/golang/crypto)
2+
3+
[![Coverage Status](https://coveralls.io/repos/github/aerogear/mobile-cli/badge.svg?branch=add-go-report-card-to-readme)](https://coveralls.io/github/aerogear/mobile-cli?branch=add-go-report-card-to-readme)
4+
15
## The Mobile CLI is a standalone CLI that can also be used a kubectl / oc plugin
26

37
## Note this is still under construction and not yet fit for use

0 commit comments

Comments
 (0)