ci: generate junit reports for unit tests

This commit is contained in:
Anton Iakimov 2023-08-10 12:46:57 +02:00
parent 14c61d9768
commit 3a41a2550a
No known key found for this signature in database
GPG Key ID: DEA1FE58DD8BF7FA
5 changed files with 18 additions and 4 deletions

3
.gitignore vendored
View File

@ -79,3 +79,6 @@ vendor/**/vendor
package.json package.json
package-lock.json package-lock.json
# junit reports for Jenkins integration
report.xml

View File

@ -240,7 +240,7 @@ setup-dev: ##@setup Install all necessary tools for development
setup-dev: install-lint install-mock install-modvendor install-protobuf tidy install-os-deps setup-dev: install-lint install-mock install-modvendor install-protobuf tidy install-os-deps
setup-build: ##@setup Install all necessary build tools setup-build: ##@setup Install all necessary build tools
setup-build: install-lint install-release install-gomobile setup-build: install-lint install-release install-gomobile install-junit-report
install-os-deps: ##@install Operating System Dependencies install-os-deps: ##@install Operating System Dependencies
_assets/scripts/install_deps.sh _assets/scripts/install_deps.sh
@ -254,6 +254,9 @@ install-gomobile: ##@install Go Mobile Build Tools
install-lint: ##@install Install Linting Tools install-lint: ##@install Install Linting Tools
GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2 GO111MODULE=on go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2
install-junit-report: ##@install Install Junit Report Tool for Jenkins integration
GO111MODULE=on go install github.com/jstemmer/go-junit-report/v2@latest
install-mock: ##@install Install Module Mocking Tools install-mock: ##@install Install Module Mocking Tools
GO111MODULE=on go install github.com/golang/mock/mockgen@v1.4.4 GO111MODULE=on go install github.com/golang/mock/mockgen@v1.4.4
@ -314,7 +317,9 @@ test-unit: UNIT_TEST_PACKAGES = $(shell go list ./... | \
test-unit: ##@tests Run unit and integration tests test-unit: ##@tests Run unit and integration tests
for file in $(UNIT_TEST_PACKAGES); do \ for file in $(UNIT_TEST_PACKAGES); do \
set -e; \ set -e; \
go test -tags '$(BUILD_TAGS)' -timeout 20m -v -failfast $$file $(gotest_extraflags); \ path=$$(echo $$file | cut -d\/ -f 4-); \
go test -tags '$(BUILD_TAGS)' -timeout 20m -v -failfast $$file $(gotest_extraflags) | \
go-junit-report -iocopy -out $${path}/report.xml; \
done done
test-unit-race: gotest_extraflags=-race test-unit-race: gotest_extraflags=-race

View File

@ -85,7 +85,10 @@ pipeline {
} // stages } // stages
post { post {
always { script { env.PKG_URL = "${currentBuild.absoluteUrl}/consoleText" } } always {
script { env.PKG_URL = "${currentBuild.absoluteUrl}/consoleText" }
junit '**/report.xml'
}
success { script { github.notifyPR(true) } } success { script { github.notifyPR(true) } }
failure { script { github.notifyPR(false) } } failure { script { github.notifyPR(false) } }
cleanup { dir(env.TMPDIR) { deleteDir() } } cleanup { dir(env.TMPDIR) { deleteDir() } }

View File

@ -48,6 +48,9 @@ func OverrideRootLog(enabled bool, levelStr string, fileOpts FileOptions, termin
disableRootLog() disableRootLog()
return nil return nil
} }
if os.Getenv("CI") == "true" {
terminal = false
}
var ( var (
handler log.Handler handler log.Handler
) )

View File

@ -49,7 +49,7 @@ in pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
git jq which git jq which
go_1_19 golangci-lint gopls go-bindata gomobileMod go_1_19 golangci-lint go-junit-report gopls go-bindata gomobileMod
mockgen protobuf3_20 protoc-gen-go mockgen protobuf3_20 protoc-gen-go
] ++ lib.optional stdenv.isDarwin xcodeWrapper; ] ++ lib.optional stdenv.isDarwin xcodeWrapper;