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

Commit 91c4bf3

Browse files
author
Ian Campbell
committed
ci: ensure we always get the test results even if they fail
The previous strucuture meant that a failure skipped the result extraction. I considered switching to using `-v` to mount the output dirs to the host, but this would result in root owned files. Instead I split the `Makefile` target into two parts which the CI can call independently, the original target remains with the same overall behaviour for end user use. Signed-off-by: Ian Campbell <[email protected]>
1 parent d1a5932 commit 91c4bf3

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

Jenkinsfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ pipeline {
115115
sh 'docker load -i coverage-invocation-image.tar'
116116
}
117117
ansiColor('xterm') {
118-
sh 'make -f docker.Makefile BUILD_TAG=$BUILD_TAG-coverage coverage'
118+
sh 'make -f docker.Makefile BUILD_TAG=$BUILD_TAG-coverage coverage-run || true'
119+
sh 'make -f docker.Makefile BUILD_TAG=$BUILD_TAG-coverage coverage-results'
119120
}
120121
archiveArtifacts '_build/ci-cov/all.out'
121122
archiveArtifacts '_build/ci-cov/coverage.html'
@@ -146,7 +147,8 @@ pipeline {
146147
sh 'docker load -i coverage-experimental-invocation-image.tar'
147148
}
148149
ansiColor('xterm') {
149-
sh 'make EXPERIMENTAL=on TEST_RESULTS_PREFIX="experimental-" -f docker.Makefile BUILD_TAG=$BUILD_TAG-coverage-experimental coverage'
150+
sh 'make EXPERIMENTAL=on TEST_RESULTS_PREFIX="experimental-" -f docker.Makefile BUILD_TAG=$BUILD_TAG-coverage-experimental coverage-run || true'
151+
sh 'make EXPERIMENTAL=on TEST_RESULTS_PREFIX="experimental-" -f docker.Makefile BUILD_TAG=$BUILD_TAG-coverage-experimental coverage-results'
150152
}
151153
}
152154
}

Jenkinsfile.baguette

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ pipeline {
9898
sh 'docker load -i coverage-invocation-image.tar'
9999
}
100100
ansiColor('xterm') {
101-
sh 'make -f docker.Makefile BUILD_TAG=$BUILD_TAG-coverage coverage'
101+
sh 'make -f docker.Makefile BUILD_TAG=$BUILD_TAG-coverage coverage-run || true'
102+
sh 'make -f docker.Makefile BUILD_TAG=$BUILD_TAG-coverage coverage-results'
102103
}
103104
archiveArtifacts '_build/ci-cov/all.out'
104105
archiveArtifacts '_build/ci-cov/coverage.html'

docker.Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,15 @@ test-e2e: build_dev_image invocation-image ## run end-to-end tests
103103
docker run -v /var/run:/var/run:ro --rm --network="host" $(DEV_IMAGE_NAME) make EXPERIMENTAL=$(EXPERIMENTAL) TEST_RESULTS_PREFIX=$(TEST_RESULTS_PREFIX) bin/$(BIN_NAME) test-e2e
104104

105105
COV_LABEL := com.docker.app.cov-run=$(TAG)
106-
coverage: build_dev_image ## run tests with coverage
106+
coverage-run: build_dev_image ## run tests with coverage
107107
@$(call mkdir,_build)
108108
docker run -v /var/run:/var/run:ro --name $(COV_CTNR_NAME) --network="host" -t $(DEV_IMAGE_NAME) make COMMIT=${COMMIT} TAG=${TAG} EXPERIMENTAL=$(EXPERIMENTAL) TEST_RESULTS_PREFIX=$(TEST_RESULTS_PREFIX) coverage
109+
coverage-results:
109110
docker cp $(COV_CTNR_NAME):$(PKG_PATH)/_build/cov/ ./_build/ci-cov
110111
docker cp $(COV_CTNR_NAME):$(PKG_PATH)/_build/test-results/ ./_build/test-results
111112
docker rm $(COV_CTNR_NAME)
113+
# coverage is split in two like this so that CI can extract the results even on failure (which will be detected via the junit) using the individual steps, but for end users running we want the overall failure.
114+
coverage: coverage-run coverage-results
112115

113116
gradle-test:
114117
tar cf - Dockerfile.gradle bin/docker-app-linux integrations/gradle | docker build -t $(GRADLE_IMAGE_NAME) -f Dockerfile.gradle -
@@ -165,4 +168,4 @@ push-invocation-image:
165168
help: ## this help
166169
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
167170

168-
.PHONY: lint test-e2e test-unit test cli-cross cross e2e-cross coverage gradle-test shell build_dev_image tars vendor check-vendor schemas help invocation-image save-invocation-image save-invocation-image-tag push-invocation-image
171+
.PHONY: lint test-e2e test-unit test cli-cross cross e2e-cross coverage coverage-run coverage-results gradle-test shell build_dev_image tars vendor check-vendor schemas help invocation-image save-invocation-image save-invocation-image-tag push-invocation-image

0 commit comments

Comments
 (0)