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

Commit f57b30d

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

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
@@ -33,7 +33,7 @@ pipeline {
3333
archiveArtifacts '*.tar.gz'
3434
}
3535
} finally {
36-
def clean_images = /docker image ls --format "{{.ID}}\t{{.Tag}}" | grep $(git describe --always --dirty) | awk '{print $1}' | xargs docker image rm/
36+
def clean_images = /docker image ls --format "{{.ID}}\t{{.Tag}}" | grep $(git describe --always --dirty) | awk '{print $1}' | xargs docker image rm -f/
3737
sh clean_images
3838
}
3939
}
@@ -42,6 +42,20 @@ pipeline {
4242
}
4343
stage('Test') {
4444
parallel {
45+
stage("Coverage report") {
46+
agent {
47+
label 'gcp-linux-worker-0'
48+
}
49+
steps {
50+
dir('src/github.com/docker/lunchbox') {
51+
sh 'ls -la'
52+
sh 'make ci-coverage'
53+
archiveArtifacts 'cov/all.out'
54+
archiveArtifacts 'cov/coverage.html'
55+
sh 'curl -s https://codecov.io/bash | bash -s - -t 0b5323a7-aa90-4855-95ad-c859a917d611 -f cov/all.out -C'
56+
}
57+
}
58+
}
4559
stage("Test Linux") {
4660
agent {
4761
label 'gcp-linux-worker-0'

Makefile

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

104+
COV_LABEL := com.docker.lunchbox.cov-run=$(TAG)
105+
104106
ci-lint:
105107
@echo "Linting..."
106108
docker build -t $(IMAGE_NAME)-lint:$(TAG) $(IMAGE_BUILD_ARGS) -f Dockerfile.lint . --target=lint-image
@@ -110,10 +112,15 @@ ci-test:
110112
@echo "Testing..."
111113
docker build -t $(IMAGE_NAME)-test:$(TAG) $(IMAGE_BUILD_ARGS) . --target=test
112114

115+
ci-coverage:
116+
docker build --target=build -t $(IMAGE_NAME)-cov:$(TAG) $(IMAGE_BUILD_ARGS) .
117+
docker run --label $(COV_LABEL) $(IMAGE_NAME)-cov:$(TAG) make COMMIT=$(TAG) TAG=$(COMMIT) coverage
118+
docker cp $$(docker ps -aql --filter label=$(COV_LABEL)):$(PKG_PATH)/_build/cov/ ./cov
119+
113120
ci-bin-all:
114121
docker build -t $(IMAGE_NAME)-bin-all:$(TAG) $(IMAGE_BUILD_ARGS) . --target=bin-build
115122
$(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;)
116123
$(foreach OS, $(OS_LIST), docker run --rm $(IMAGE_NAME)-bin-all:$(TAG) /bin/sh -c "cp $(PKG_PATH)/_build/*-$(OS)* $(PKG_PATH)/e2e && cd $(PKG_PATH)/e2e && tar -cz * --exclude=*.go" > $(E2E_NAME)-$(OS)-$(TAG).tar.gz || exit 1;)
117124

118-
.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
125+
.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
119126
.DEFAULT: all

0 commit comments

Comments
 (0)