Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit fc188bd

Browse files
committed
Run coverage in CI
Signed-off-by: Joffrey F <[email protected]>
1 parent 683eede commit fc188bd

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ ARG TAG=unknown
66
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS build
77
RUN apk add --no-cache \
88
build-base \
9-
git
9+
git \
10+
util-linux
1011
WORKDIR /go/src/github.com/docker/lunchbox/
1112
COPY . .
1213

Jenkinsfile

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pipeline {
3535
archiveArtifacts '*.tar.gz'
3636
}
3737
} finally {
38-
def clean_images = /docker image ls --format "{{.ID}}\t{{.Tag}}" | grep $(git describe --always --dirty) | awk '{print $1}' | xargs docker image rm/
38+
def clean_images = /docker image ls --format "{{.ID}}\t{{.Tag}}" | grep $(git describe --always --dirty) | awk '{print $1}' | xargs docker image rm -f/
3939
sh clean_images
4040
}
4141
}
@@ -44,6 +44,20 @@ pipeline {
4444
}
4545
stage('Test') {
4646
parallel {
47+
stage("Coverage report") {
48+
agent {
49+
label 'gcp-linux-worker-0'
50+
}
51+
steps {
52+
dir('src/github.com/docker/lunchbox') {
53+
sh 'ls -la'
54+
sh 'make ci-coverage'
55+
archiveArtifacts 'cov/all.out'
56+
archiveArtifacts 'cov/coverage.html'
57+
sh 'curl -s https://codecov.io/bash | bash -s - -t 0b5323a7-aa90-4855-95ad-c859a917d611 -f cov/all.out -C'
58+
}
59+
}
60+
}
4761
stage("Test Linux") {
4862
agent {
4963
label 'linux'

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ clean:
102102
# Continuous Integration #
103103
##########################
104104

105+
COV_LABEL := com.docker.lunchbox.cov-run=$(TAG)
106+
105107
ci-lint:
106108
@echo "Linting..."
107109
docker build -t $(IMAGE_NAME)-lint:$(TAG) $(IMAGE_BUILD_ARGS) -f Dockerfile.lint . --target=lint-image
@@ -111,6 +113,11 @@ ci-test:
111113
@echo "Testing..."
112114
docker build -t $(IMAGE_NAME)-test:$(TAG) $(IMAGE_BUILD_ARGS) . --target=test
113115

116+
ci-coverage:
117+
docker build --target=build -t $(IMAGE_NAME)-cov:$(TAG) $(IMAGE_BUILD_ARGS) .
118+
docker run --label $(COV_LABEL) $(IMAGE_NAME)-cov:$(TAG) make COMMIT=$(TAG) TAG=$(COMMIT) coverage
119+
docker cp $$(docker ps -aql --filter label=$(COV_LABEL)):$(PKG_PATH)/_build/cov/ ./cov
120+
114121
ci-bin-all:
115122
docker build -t $(IMAGE_NAME)-bin-all:$(TAG) $(IMAGE_BUILD_ARGS) . --target=bin-build
116123
$(foreach OS, $(OS_LIST), docker run --rm $(IMAGE_NAME)-bin-all:$(TAG) tar -cz -C $(PKG_PATH)/_build $(BIN_NAME)-$(OS)$(if $(filter windows, $(OS)),.exe,) > $(BIN_NAME)-$(OS)-$(TAG).tar.gz || exit 1;)
@@ -121,5 +128,5 @@ ci-gradle-test:
121128
-e GRADLE_USER_HOME=/tmp/gradle \
122129
gradle:jdk8 bash -c "cd /gradle && gradle --stacktrace build && cd example && gradle renderIt"
123130

124-
.PHONY: bin bin-all release test check lint test-cov e2e-test e2e-all unit-test coverage coverage-bin clean ci-lint ci-test ci-bin-all ci-e2e-all ci-gradle-test
131+
.PHONY: bin bin-all release test check lint test-cov e2e-test e2e-all unit-test coverage coverage-bin clean ci-lint ci-test ci-coverage ci-bin-all ci-e2e-all ci-gradle-test
125132
.DEFAULT: all

0 commit comments

Comments
 (0)