diff options
author | James Fargher <jfargher@gitlab.com> | 2022-05-25 02:58:33 +0300 |
---|---|---|
committer | James Fargher <jfargher@gitlab.com> | 2022-05-26 01:42:31 +0300 |
commit | 8404fa872555a9cebd34235921ef075cfbcc1a61 (patch) | |
tree | e9b276d7156068fd9f6ad8b52e6d8d81f12f3683 | |
parent | ac989862106589558866e01fc5d77ad7326c99e4 (diff) |
Fix CI pipeline test reporting and coveragefix_test_reports
It turns out artifacts cannot be collected from /tmp as these temporary
files appear to be removed before gitlab CI collects them. This results
in:
> Uploading artifacts...
> WARNING: /tmp/go-tests-report.xml: no matching files
> ERROR: No files to upload
To fix this we first create an unprivileged reports/coverage directory
as part of preparing for tests.
-rw-r--r-- | .gitlab-ci.yml | 7 | ||||
-rw-r--r-- | Makefile | 8 |
2 files changed, 8 insertions, 7 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6809a65df..649f135c3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -81,8 +81,7 @@ include: PGUSER: postgres POSTGRES_DB: praefect_test POSTGRES_HOST_AUTH_METHOD: trust - TEST_REPORT: /tmp/go-tests-report.xml - TEST_COVERAGE_DIR: /tmp/coverage + TEST_REPORT_MKDIR_OPTIONS: -m777 before_script: &test_before_script - go version - while ! psql -h $PGHOST -U $PGUSER -c 'SELECT 1' > /dev/null; do echo "awaiting Postgres service to be ready..." && sleep 1 ; done && echo "Postgres service is ready!" @@ -90,7 +89,7 @@ include: paths: - ruby/tmp/gitaly-rspec-test.log reports: - junit: ${TEST_REPORT} + junit: _build/reports/go-tests-report.xml when: on_failure expire_in: 1 week @@ -190,7 +189,7 @@ test:coverage: reports: coverage_report: coverage_format: cobertura - path: ${TEST_COVERAGE_DIR}/cobertura.xml + path: _build/cover/cobertura.xml test:pgbouncer: <<: *test_definition @@ -232,6 +232,9 @@ TEST_REPO_MIRROR := ${TEST_REPO_DIR}/gitlab-test-mirror.git TEST_REPO_GIT := ${TEST_REPO_DIR}/gitlab-git-test.git BENCHMARK_REPO := ${TEST_REPO_DIR}/benchmark.git +# Allows setting permissions on test report directories +TEST_REPORT_MKDIR_OPTIONS ?= + # All executables provided by Gitaly GITALY_EXECUTABLES = $(addprefix ${BUILD_DIR}/bin/,$(notdir $(shell find ${SOURCE_DIR}/cmd -mindepth 1 -maxdepth 1 -type d -print)) gitaly-git2go-v14) # Find all Go source files. @@ -328,7 +331,8 @@ endif .PHONY: prepare-tests prepare-tests: libgit2 prepare-test-repos ${SOURCE_DIR}/.ruby-bundle ${GOTESTSUM} - ${Q}mkdir -p "$(dir ${TEST_REPORT})" + ${Q}[ -d "${TEST_COVERAGE_DIR}" ] || mkdir ${TEST_REPORT_MKDIR_OPTIONS} "${TEST_COVERAGE_DIR}" + ${Q}[ -d "$(dir ${TEST_REPORT})" ] || mkdir ${TEST_REPORT_MKDIR_OPTIONS} "$(dir ${TEST_REPORT})" .PHONY: prepare-test-repos prepare-test-repos: ${TEST_REPO_MIRROR} ${TEST_REPO} ${TEST_REPO_GIT} @@ -426,8 +430,6 @@ rubocop: ${SOURCE_DIR}/.ruby-bundle ## Generate coverage report via Go tests. cover: TEST_OPTIONS := ${TEST_OPTIONS} -coverprofile "${TEST_COVERAGE_DIR}/all.merged" cover: prepare-tests libgit2 ${GOCOVER_COBERTURA} - ${Q}rm -rf "${TEST_COVERAGE_DIR}" - ${Q}mkdir -p "${TEST_COVERAGE_DIR}" ${Q}$(call run_go_tests) ${Q}go tool cover -html "${TEST_COVERAGE_DIR}/all.merged" -o "${TEST_COVERAGE_DIR}/all.html" @ # sed is used below to convert file paths to repository root relative paths. See https://gitlab.com/gitlab-org/gitlab/-/issues/217664 |