Skip to content

Commit eb6a674

Browse files
authored
CLOUDP-62837: Output test results in junit format for evergreen (#182)
1 parent 13c48d1 commit eb6a674

File tree

3 files changed

+62
-35
lines changed

3 files changed

+62
-35
lines changed

.evergreen.yml

Lines changed: 59 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,30 @@ functions:
2929
<<: *go_options
3030
command: make build
3131
"test":
32-
- command: subprocess.exec
32+
- command: shell.exec
3333
type: test
3434
params:
35-
add_to_path:
36-
- ${go_bin}
37-
- ${workdir}/bin
3835
working_dir: src/github.com/mongodb/mongocli
39-
env:
40-
GOROOT: ${go_root}
41-
<<: *go_options
42-
command: make test
36+
script: |
37+
set -o xtrace
38+
set -o errexit
39+
set -o verbose
40+
41+
export GOROOT="${go_root}"
42+
export PATH="./bin:$GOROOT/bin:$PATH"
43+
44+
gotestsum --junitfile unit-tests.xml -- -race -cover -count=1 -coverprofile coverage.out ./internal...
4345
"generate html coverage":
4446
- command: subprocess.exec
4547
type: test
4648
params:
4749
add_to_path:
4850
- ${go_bin}
49-
- ${workdir}/bin
5051
working_dir: src/github.com/mongodb/mongocli
5152
env:
5253
GOROOT: ${go_root}
5354
<<: *go_options
54-
command: make coverage
55+
command: go tool cover -html=coverage.out -o coverage.html
5556
"upload html coverage":
5657
- command: s3.put
5758
params:
@@ -71,7 +72,6 @@ functions:
7172
- ${go_bin}
7273
working_dir: src/github.com/mongodb/mongocli
7374
env:
74-
WORKDIR: ${workdir}
7575
GOROOT: ${go_root}
7676
MCLI_OPS_MANAGER_URL: ${mcli_ops_manager_url}
7777
MCLI_ORG_ID: ${atlas_org_id}
@@ -89,7 +89,6 @@ functions:
8989
- ${go_bin}
9090
working_dir: src/github.com/mongodb/mongocli
9191
env:
92-
WORKDIR: ${workdir}
9392
GOROOT: ${go_root}
9493
MCLI_OPS_MANAGER_URL: ${mcli_ops_manager_url}
9594
MCLI_ORG_ID: ${cloud_manager_org_id}
@@ -100,17 +99,18 @@ functions:
10099
<<: *go_options
101100
command: make e2e-test-cloud
102101
"lint":
103-
- command: subprocess.exec
102+
- command: shell.exec
104103
type: test
105104
params:
106-
add_to_path:
107-
- ${go_bin}
108105
working_dir: src/github.com/mongodb/mongocli
109-
env:
110-
WORKDIR: ${workdir}
111-
GOROOT: ${go_root}
112-
<<: *go_options
113-
command: make lint
106+
script: |
107+
set -o xtrace
108+
set -o errexit
109+
set -o verbose
110+
111+
export GOROOT="${go_root}"
112+
export PATH="./bin:$GOROOT/bin:$PATH"
113+
golangci-lint run --out-format junit-xml > lint-tests.xml
114114
"generate notices":
115115
- command: shell.exec
116116
type: test
@@ -130,18 +130,32 @@ functions:
130130
popd
131131
cd src/github.com/mongodb/mongocli
132132
go-licenses save "github.com/mongodb/mongocli" --save_path=third_party_notices
133-
"install gon":
133+
"install gotestsum":
134134
- command: shell.exec
135135
type: setup
136136
params:
137-
working_dir: src/github.com/mongodb/mongocli
137+
working_dir: src/github.com/mongodb/mongocli/bin
138138
script: |
139139
set -o xtrace
140140
set -o errexit
141141
set -o verbose
142142
143-
mkdir -p bin
144-
cd bin
143+
curl -sfL https://github.com/gotestyourself/gotestsum/releases/download/v0.4.2/gotestsum_0.4.2_linux_amd64.tar.gz | tar zx
144+
"install golangci-lint":
145+
- command: subprocess.exec
146+
type: setup
147+
params:
148+
working_dir: src/github.com/mongodb/mongocli
149+
command: make setup
150+
"install gon":
151+
- command: shell.exec
152+
type: setup
153+
params:
154+
working_dir: src/github.com/mongodb/mongocli/bin
155+
script: |
156+
set -o xtrace
157+
set -o errexit
158+
set -o verbose
145159
146160
curl -sL https://github.com/mitchellh/gon/releases/download/v0.2.3/gon_macos.zip | tar zx
147161
"install goreleaser":
@@ -256,7 +270,7 @@ functions:
256270
257271
env GOOS=windows GOARCH=amd64 go build -ldflags "-s -w -X github.com/mongodb/mongocli/internal/version.Version=$VERSION" -o mongocli.exe
258272
259-
mkdir {build,dist}
273+
mkdir -p build
260274
261275
go-msi make --msi "dist/mongocli_$VERSION.msi" --version $VERSION
262276
"rename pkg":
@@ -340,23 +354,40 @@ functions:
340354
--version ${server_version|1.0.0} \
341355
--arch x86_64 \
342356
--packages https://s3.amazonaws.com/mongodb-mongocli-build/${project}/dist/${revision}_${created_at}/${ext}.tgz
357+
358+
post:
359+
- command: attach.xunit_results
360+
params:
361+
files: ["src/github.com/mongodb/mongocli/*.xml"]
362+
343363
tasks:
344364
- name: compile
365+
tags: ["code_health"]
345366
commands:
346367
- func: "clone"
347368
- func: "build"
348-
- name: test
369+
- name: unit_test
370+
tags: ["code_health"]
349371
commands:
350372
- func: "clone"
373+
- func: "install gotestsum"
351374
- func: "test"
352375
- func: "generate html coverage"
353376
- func: "upload html coverage"
377+
- name: lint
378+
tags: ["code_health"]
379+
commands:
380+
- func: "clone"
381+
- func: "install golangci-lint"
382+
- func: "lint"
354383
- name: atlas_e2e
384+
tags: ["e2e"]
355385
commands:
356386
- func: "clone"
357387
- func: "build"
358388
- func: "atlas e2e"
359389
- name: cloud_manager_e2e
390+
tags: ["e2e"]
360391
commands:
361392
- func: "clone"
362393
- func: "build"
@@ -922,7 +953,8 @@ buildvariants:
922953
go_bin: "/opt/golang/go1.14/bin"
923954
tasks:
924955
- name: compile
925-
- name: test
956+
- name: unit_test
957+
- name: lint
926958
- name: e2e
927959
display_name: "E2E"
928960
run_on:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*.dll
55
*.so
66
*.dylib
7+
bin/**
8+
dist/**
79

810
# Test binary, built with `go test -c`
911
*.test
@@ -18,3 +20,4 @@ third_party_notices/
1820
# Evergreen generated files
1921
.gocache/
2022
gon.json
23+
*.xml

Makefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ BINARY_NAME=mongocli
66
DESTINATION=./bin/${BINARY_NAME}
77
GOLANGCI_VERSION=v1.27.0
88
COVERAGE=coverage.out
9-
COVERAGE_HTML=coverage.html
10-
119
VERSION=$(shell git describe --always --tags)
1210
LINKER_FLAGS=-X github.com/mongodb/mongocli/internal/version.Version=${VERSION}
1311

@@ -18,7 +16,6 @@ export GO111MODULE := on
1816
setup: ## Install dev tools
1917
@echo "==> Installing dependencies..."
2018
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(GOLANGCI_VERSION)
21-
curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh | sh
2219

2320
.PHONY: link-git-hooks
2421
link-git-hooks: ## Install git hooks
@@ -36,11 +33,6 @@ test: ## Run tests
3633
@echo "==> Running tests..."
3734
go test -race -cover -count=1 -coverprofile ${COVERAGE} ./internal...
3835

39-
.PHONY: coverage
40-
coverage: ## Generate coverage report
41-
@echo "==> generating coverage..."
42-
go tool cover -html=${COVERAGE} -o ${COVERAGE_HTML}
43-
4436
.PHONY: lint
4537
lint: ## Run linter
4638
@echo "==> Linting all packages..."

0 commit comments

Comments
 (0)