From 4875819ae3af75567d85068c069f9e0977be081f Mon Sep 17 00:00:00 2001 From: Jay McCure Date: Tue, 11 Jul 2023 16:20:39 +1000 Subject: [PATCH] chore(ci): save test log as an artifact --- .gitignore | 3 +++ .gitlab-ci.yml | 2 ++ Makefile | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b2601786..5e4ac2ad 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,6 @@ log.txt.glab-cli *.tar *.tar.gz *.tar.bz2 + +# gotestsum test log +test-output.log diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3f6de580..df71a6ef 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -128,6 +128,8 @@ run_tests: - echo -e "\e[0Ksection_end:`date +%s`:coverage\r\e[0K" coverage: /^total:\t+\(statements\)\t+\d+\.\d+%$/ artifacts: + paths: + - test-output.log reports: junit: coverage.xml diff --git a/Makefile b/Makefile index 42cd43c7..e3a14b89 100644 --- a/Makefile +++ b/Makefile @@ -118,7 +118,7 @@ TEST_PKGS ?= ./pkg/... ./internal/... ./commands/... ./cmd/... # # Finally, there are some integration tests perform actual API calls and require GITLAB_TOKEN (personal access token) # and GITLAB_TEST_HOST (GitLab instance to test) to be set. If either of these are not set the integration tests -# will be skipped and only the unit tests will be run. +# will fail in CI or will be skipped if not in CI. test: TEST_FORMAT ?= short test: SHELL = /bin/bash # set environment variables to ensure consistent test behavior test: VISUAL= @@ -127,7 +127,7 @@ test: PAGER= test: export CI_PROJECT_PATH=$(shell git remote get-url origin) test: export CGO_ENABLED=1 test: bin/gotestsum ## Run tests - $(GOTEST) --no-summary=skipped --junitfile ./coverage.xml --format ${TEST_FORMAT} -- -coverprofile=./coverage.txt -covermode=atomic $(filter-out -v,${GOARGS}) $(if ${TEST_PKGS},${TEST_PKGS},./...) + $(GOTEST) --jsonfile test-output.log --no-summary=skipped --junitfile ./coverage.xml --format ${TEST_FORMAT} -- -coverprofile=./coverage.txt -covermode=atomic $(filter-out -v,${GOARGS}) $(if ${TEST_PKGS},${TEST_PKGS},./...) .PHONY: test-race test-race: SHELL = /bin/bash # set environment variables to ensure consistent test behavior