Commit e7d534d5 authored by Tomasz Maczukin's avatar Tomasz Maczukin

Merge branch 'docker-ci-image/generate-junit-report-file-for-tests' into 'master'

Generate junit report file for tests

See merge request gitlab-org/gitlab-runner!1060
parents 7443b5f4 66043b5d
......@@ -9,7 +9,7 @@ stages:
- cleanup
variables:
CI_IMAGE: registry.gitlab.com/gitlab-org/gitlab-runner/ci:1.8.7-1
CI_IMAGE: registry.gitlab.com/gitlab-org/gitlab-runner/ci:1.8.7-2
GOROOT: /usr/local/go
before_script:
......@@ -29,7 +29,7 @@ image: $CI_IMAGE
services:
- docker:dind
variables: &docker_variables
CI_IMAGE: registry.gitlab.com/gitlab-org/gitlab-runner/ci:1.8.7-1
CI_IMAGE: registry.gitlab.com/gitlab-org/gitlab-runner/ci:1.8.7-2
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://docker:2375
tags:
......@@ -291,10 +291,13 @@ git 1.7.1:
# Coverage stage
#
test coverage report: &test_coverage_report
<<: *except_docs
.coverage_job: &coverage_job
stage: coverage
image: golang:1.10
when: always
test coverage report: &test_coverage_report
<<: *coverage_job
coverage: /regular total:\s+\(statements\)\s+\d+.\d+\%/
script:
- source ci/touch_make_dependencies
......@@ -306,13 +309,21 @@ test coverage report: &test_coverage_report
expire_in: 7d
race conditions detector:
<<: *except_docs
stage: coverage
image: golang:1.10
<<: *test_coverage_report
script:
- source ci/touch_make_dependencies
- make check_race_conditions
test junit report:
<<: *coverage_job
image: $CI_IMAGE
script:
- source ci/touch_make_dependencies
- make parallel_test_junit_report
artifacts:
reports:
junit: out/junit/report.xml
#
# Build stage
#
......
......@@ -138,6 +138,10 @@ parallel_test_coverage_report: $(GOPATH_SETUP)
# Preparing coverage report
@./scripts/go_test_with_coverage_report coverage
parallel_test_junit_report: $(GOPATH_SETUP)
# Preparing jUnit test report
@./scripts/go_test_with_coverage_report junit
pull_images_for_tests: $(GOPATH_SETUP)
# Pulling images required for some tests
@go run ./scripts/pull-images-for-tests/main.go
......
......@@ -25,3 +25,5 @@ RUN wget -q https://get.docker.com/builds/Linux/x86_64/docker-1.13.1.tgz -O /tmp
COPY Makefile* /tmp/
RUN cd /tmp; \
make deps package-deps packagecloud-deps
RUN go get -u github.com/jstemmer/go-junit-report
\ No newline at end of file
......@@ -41,10 +41,10 @@ prepareTestCommands() {
local tempFile=$(mktemp)
local exitCode=0
go test -list "Test.*" "${pkg}" > ${tempFile} || exitCode=1
go test -list "Test.*" "${pkg}" > "${tempFile}" || exitCode=1
local tests=$(grep "^Test" ${tempFile})
rm ${tempFile}
local tests=$(grep "^Test" "${tempFile}")
rm "${tempFile}"
if [[ ${exitCode} -ne 0 ]]; then
exit ${exitCode}
......@@ -138,7 +138,7 @@ computeCoverageReport() {
local htmlReportFile="${reportDirectory}/coverprofile.${output}.html"
local textReportFile="${reportDirectory}/coverprofile.${output}.txt"
mkdir -p ${reportDirectory}
mkdir -p "${reportDirectory}"
echo "mode: ${coverMode}" > ${sourceFile}
grep -h -v -e "^mode:" -e "executors/docker/bindata.go" .cover/*.${coverMode}.cover.txt >> ${sourceFile}
......@@ -156,6 +156,17 @@ computeCoverageReport() {
fi
}
computeJUnitReport() {
local reportDirectory="out/junit"
local concatenatedOutputFile="/tmp/test-output.txt"
mkdir -p "${reportDirectory}"
cat .testoutput/*.${output}.output.txt > "${concatenatedOutputFile}"
go-junit-report < "${concatenatedOutputFile}" > "${reportDirectory}/report.xml"
}
case "$1" in
prepare)
prepareTestCommands
......@@ -166,4 +177,7 @@ case "$1" in
coverage)
computeCoverageReport
;;
junit)
computeJUnitReport
;;
esac
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment