diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2020-12-07 07:40:45 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2020-12-07 07:40:45 +0300 |
commit | 39bd2710f86f90a0a6765fbd2d8c07e2493ad5e5 (patch) | |
tree | 1560b11970faa8a34ac299436bd96f72c90cc60b | |
parent | 0a1587752423d5851a8d1c09dc55bb212cb83374 (diff) |
Use junit report
-rw-r--r-- | .gitignore | 7 | ||||
-rw-r--r-- | .gitlab/ci/test.yml | 12 | ||||
-rw-r--r-- | Makefile.build.mk | 1 | ||||
-rw-r--r-- | Makefile.internal.mk | 3 | ||||
-rw-r--r-- | Makefile.util.mk | 6 | ||||
-rw-r--r-- | go.mod | 1 | ||||
-rw-r--r-- | tools.go | 1 |
7 files changed, 26 insertions, 5 deletions
@@ -4,12 +4,11 @@ shared/pages/.update /vendor /gitlab-pages.conf /gl-code-quality-report.json +/gl-license-scanning-report.json /coverage.html +/junit-test-report.xml +/tests.out # Used by the makefile /.GOPATH /bin - -# reports -gl-license-scanning-report.json -gl-code-quality-report.json diff --git a/.gitlab/ci/test.yml b/.gitlab/ci/test.yml index 3218d8ee..d862ccd7 100644 --- a/.gitlab/ci/test.yml +++ b/.gitlab/ci/test.yml @@ -7,6 +7,7 @@ script: - echo "Running all tests without daemonizing..." - make test + - make junit-report - echo "Running just the acceptance tests daemonized (tmpdir)...." - TEST_DAEMONIZE=tmpdir make acceptance - echo "Running just the acceptance tests daemonized (inplace)...." @@ -74,3 +75,14 @@ check deps: needs: ['download deps'] script: - make deps-check + +## Use https://github.com/jstemmer/go-junit-report to generate a JUnit report format XML file with go +golang: + stage: test + script: + - go get -u github.com/jstemmer/go-junit-report + - go test -v 2>&1 | go-junit-report -set-exit-code > report.xml + artifacts: + when: always + reports: + junit: report.xml diff --git a/Makefile.build.mk b/Makefile.build.mk index 2c9e9159..2656e62e 100644 --- a/Makefile.build.mk +++ b/Makefile.build.mk @@ -10,6 +10,7 @@ setup: clean .GOPATH/.ok go get github.com/wadey/gocovmerge@v0.0.0-20160331181800-b5bfa59ec0ad go get github.com/golang/mock/mockgen@v1.3.1 go get github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) + go get github.com/jstemmer/go-junit-report generate-mocks: .GOPATH/.ok $Q bin/mockgen -source=internal/interface.go -destination=internal/mocks/mocks.go -package=mocks diff --git a/Makefile.internal.mk b/Makefile.internal.mk index a33634fd..54e7f7da 100644 --- a/Makefile.internal.mk +++ b/Makefile.internal.mk @@ -43,3 +43,6 @@ bin/golangci-lint: .GOPATH/.ok @test -x $@ || \ { echo "Vendored golangci-lint not found, try running 'make setup'..."; exit 1; } +bin/go-junit-report: .GOPATH/.ok + @test -x $@ || \ + { echo "Vendored go-junit-report not found, try running 'make setup'..."; exit 1; } diff --git a/Makefile.util.mk b/Makefile.util.mk index ae78673a..1294b442 100644 --- a/Makefile.util.mk +++ b/Makefile.util.mk @@ -10,7 +10,8 @@ lint: .GOPATH/.ok bin/golangci-lint $Q ./bin/golangci-lint run ./... --out-format $(OUT_FORMAT) $(LINT_FLAGS) | tee ${REPORT_FILE} test: .GOPATH/.ok gitlab-pages - go test $(if $V,-v) $(allpackages) + rm tests.out || true + go test $(if $V,-v) $(allpackages) 2>&1 | tee tests.out race: .GOPATH/.ok gitlab-pages CGO_ENABLED=1 go test -race $(if $V,-v) $(allpackages) @@ -55,3 +56,6 @@ deps-check: .GOPATH/.ok deps-download: .GOPATH/.ok go mod download + +junit-report: bin/go-junit-report + cat tests.out | ./bin/go-junit-report -set-exit-code > junit-test-report.xml @@ -12,6 +12,7 @@ require ( github.com/gorilla/handlers v1.4.2 github.com/gorilla/securecookie v1.1.1 github.com/gorilla/sessions v1.2.0 + github.com/jstemmer/go-junit-report v0.9.1 github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 github.com/karlseguin/ccache/v2 v2.0.6 github.com/karrick/godirwalk v1.10.12 @@ -4,6 +4,7 @@ package main import ( _ "github.com/fzipp/gocyclo" + _ "github.com/jstemmer/go-junit-report" _ "github.com/wadey/gocovmerge" _ "golang.org/x/lint/golint" _ "golang.org/x/tools/cmd/goimports" |