diff --git a/Makefile b/Makefile index a38b3c11d5..6310fd81e5 100644 --- a/Makefile +++ b/Makefile @@ -101,10 +101,19 @@ clean: unit: clean go test ./pkg/... ./cmd/... -coverprofile cover.out +unit_xml: clean + go test --json ./pkg/... ./cmd/... -coverprofile cover.out > unit-tests.json + gotestsum --junitfile unit-tests.xml --raw-command cat unit-tests.json + integration: GO_TAGS += integration integration: clean generate go test -tags='$(GO_TAGS)' ./pkg/... ./cmd/... -coverprofile cover.out +integration_xml: GO_TAGS += integration +integration_xml: clean generate + go test -tags='$(GO_TAGS)' --json ./pkg/... ./cmd/... -coverprofile cover.out > integration-tests.json + gotestsum --junitfile integration-tests.xml --raw-command cat integration-tests.json + check-fmt: ifneq ($(shell goimports -l pkg cmd),) $(error Invalid go formatting. Please run `make fmt`) @@ -338,7 +347,7 @@ e2e-local: ## -- Continuous integration -- ## ########################################## -ci: dep-vendor-only check-fmt lint generate check-local-changes unit integration e2e-compile docker-build +ci: dep-vendor-only check-fmt lint generate check-local-changes unit_xml integration_xml e2e-compile docker-build # Run e2e tests in a dedicated cluster. ci-e2e: dep-vendor-only run-deployer install-crds apply-psp e2e diff --git a/build/ci/Dockerfile b/build/ci/Dockerfile index e77ce167a6..90fdf3a686 100644 --- a/build/ci/Dockerfile +++ b/build/ci/Dockerfile @@ -6,6 +6,7 @@ ENV GCLOUD_VERSION=232.0.0 ENV KUBECTL_VERSION=1.13.6 ENV DOCKER_VERSION=18.03.1-ce ENV GOLANGCILINT_VERSION=1.17.1 +ENV GOTESTSUM_VERSION=0.3.5 # Download required golang tools RUN go get github.com/golang/dep/cmd/dep golang.org/x/tools/cmd/goimports @@ -50,6 +51,12 @@ RUN apt-get update && apt-get --no-install-recommends -y install \ # Download Azure CLI RUN curl -sSL https://aka.ms/InstallAzureCLIDeb | bash +# Install gotestsum to generate xUnit compatible XML for tests +RUN curl -fsSLO https://github.com/gotestyourself/gotestsum/releases/download/v${GOTESTSUM_VERSION}/gotestsum_${GOTESTSUM_VERSION}_linux_amd64.tar.gz && \ + tar xzf gotestsum_${GOTESTSUM_VERSION}_linux_amd64.tar.gz && \ + mv gotestsum /usr/local/bin/gotestsum && chmod +x /usr/local/bin/gotestsum && \ + rm gotestsum_${GOTESTSUM_VERSION}_linux_amd64.tar.gz + # Add Go dependencies to Docker image WORKDIR /go/src/github.com/elastic/cloud-on-k8s COPY Gopkg.lock . diff --git a/build/ci/pr/Jenkinsfile b/build/ci/pr/Jenkinsfile index 5173e2b865..7cc7d95492 100644 --- a/build/ci/pr/Jenkinsfile +++ b/build/ci/pr/Jenkinsfile @@ -41,6 +41,8 @@ pipeline { steps { createConfig() sh 'make -C build/ci TARGET=ci ci' + junit "unit-tests.xml" + junit "integration-tests.xml" } } stage("Run smoke E2E tests") {