Skip to content

Commit

Permalink
Add test coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Tinkham <[email protected]>
  • Loading branch information
andytinkham committed Jul 31, 2020
1 parent 2173cd6 commit 21de6e4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ RUN apk add --no-cache bash \
git && \
go mod download && \
go get -u github.com/jstemmer/go-junit-report && \
go get -u github.com/axw/gocov/gocov && \
go get -u github.com/AlekSi/gocov-xml && \
mkdir -p /summon/output

COPY . .
Expand Down
3 changes: 3 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ pipeline {
stage('Run unit tests') {
steps {
sh './test_unit'
sh 'mv output/c.out .'
ccCoverage("gocov", "--prefix github.com/cyberark/summon")
}
post {
always {
junit 'output/junit.xml'
cobertura autoUpdateHealth: true, autoUpdateStability: true, coberturaReportFile: 'output/coverage.xml', conditionalCoverageTargets: '30, 0, 0', failUnhealthy: true, failUnstable: false, lineCoverageTargets: '30, 0, 0', maxNumberOfBuilds: 0, methodCoverageTargets: '30, 0, 0', onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions test_unit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -e

TEST_CMD='go test -v ./... | tee junit.output && cat junit.output | go-junit-report > output/junit.xml'
TEST_CMD='go test -coverprofile=output/c.out -v ./... | tee junit.output && cat junit.output | go-junit-report > output/junit.xml'

echo "Running unit tests"
docker build --pull -t summon-builder .
Expand All @@ -9,4 +9,6 @@ rm -f "output/*.xml"

docker run --rm -t \
-v "$PWD/output:/summon/output" \
summon-builder bash -c "$TEST_CMD"
summon-builder bash -c "$TEST_CMD;
gocov convert output/c.out | gocov-xml > output/coverage.xml;
"

0 comments on commit 21de6e4

Please sign in to comment.