diff options
author | Vladimir Shushlin <vshushlin@gitlab.com> | 2020-12-08 12:11:23 +0300 |
---|---|---|
committer | Vladimir Shushlin <vshushlin@gitlab.com> | 2020-12-08 12:11:23 +0300 |
commit | 5e1ce3197df7c3136d6c6c93877634e5c177df90 (patch) | |
tree | b92f3e9aeb4c9973e80d8e6a6a53b2ae9f39e398 | |
parent | fb4867bc78b986bd2a0c1d6f19c0d1aad148c94e (diff) | |
parent | 6390d9c1f901e91f25e667b44718781f9f5f1f6b (diff) |
Merge branch 'junit-report' into 'master'
Add junit report for tests
See merge request gitlab-org/gitlab-pages!403
-rw-r--r-- | .gitignore | 7 | ||||
-rw-r--r-- | .gitlab/ci/test.yml | 54 | ||||
-rw-r--r-- | Makefile.build.mk | 1 | ||||
-rw-r--r-- | Makefile.internal.mk | 3 | ||||
-rw-r--r-- | Makefile.util.mk | 8 | ||||
-rw-r--r-- | go.mod | 1 | ||||
-rw-r--r-- | tools.go | 1 |
7 files changed, 48 insertions, 27 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..74d49ee6 100644 --- a/.gitlab/ci/test.yml +++ b/.gitlab/ci/test.yml @@ -1,46 +1,62 @@ -.tests: +.tests-common: extends: .go-mod-cache stage: test tags: - gitlab-org-docker needs: ['download deps'] + artifacts: + reports: + junit: junit-test-report.xml + +.tests-unit: + extends: .tests-common script: - echo "Running all tests without daemonizing..." + - make setup - make test + - make junit-report + +.tests-acceptance-deamon: + extends: .tests-common + script: + - make setup - echo "Running just the acceptance tests daemonized (tmpdir)...." - TEST_DAEMONIZE=tmpdir make acceptance - echo "Running just the acceptance tests daemonized (inplace)...." - TEST_DAEMONIZE=inplace make acceptance - artifacts: - paths: - - bin/gitlab-pages + - make junit-report test:1.13: - extends: .tests + extends: .tests-unit + image: golang:1.13 + +test-acceptance:1.13: + extends: .tests-acceptance-deamon image: golang:1.13 test:1.14: - extends: .tests + extends: .tests-unit + image: golang:1.14 + +test-acceptance:1.14: + extends: .tests-acceptance-deamon image: golang:1.14 test:1.15: - extends: .tests + extends: .tests-unit + image: golang:1.15 +test-acceptance:1.15: + extends: .tests-acceptance-deamon image: golang:1.15 race: - extends: .go-mod-cache - stage: test - needs: ['download deps'] - tags: - - gitlab-org-docker + extends: .tests-common script: - echo "Running race detector" - make race cover: - stage: test - extends: .go-mod-cache - needs: ['download deps'] + extends: .tests-common script: - make setup - make generate-mocks @@ -51,9 +67,7 @@ cover: - coverage.html code_quality: - stage: test - extends: .go-mod-cache - needs: ['download deps'] + extends: .tests-common image: golangci/golangci-lint:v1.27.0 variables: REPORT_FILE: gl-code-quality-report.json @@ -69,8 +83,6 @@ code_quality: - ${REPORT_FILE} check deps: - stage: test - extends: .go-mod-cache - needs: ['download deps'] + extends: .tests-common script: - make deps-check 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..4f190ea4 100644 --- a/Makefile.util.mk +++ b/Makefile.util.mk @@ -10,13 +10,14 @@ 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) acceptance: .GOPATH/.ok gitlab-pages - go test $(if $V,-v) ./test/acceptance + go test $(if $V,-v) ./test/acceptance 2>&1 | tee tests.out bench: .GOPATH/.ok gitlab-pages go test -bench=. -run=^$$ $(allpackages) @@ -55,3 +56,6 @@ deps-check: .GOPATH/.ok deps-download: .GOPATH/.ok go mod download + +junit-report: .GOPATH/.ok 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" |