Skip to content

Commit

Permalink
circleci: record junit test results (#959)
Browse files Browse the repository at this point in the history
circleci: record test meta data

This PR enables circle CI's Collecting Test Metadata feature by
producing JUnit XML. It's modeled after their Language Guide: Go docs.

The motivation behind this is to get insights into flaky tests and to
avoid having to scroll through the huge test result log output when a
test fails.
  • Loading branch information
felixge authored Jun 30, 2021
1 parent bfaa50c commit 37b76b6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
43 changes: 41 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,33 @@ jobs:
test-core:
resource_class: xlarge
environment: # environment variables for the build itself
TEST_RESULTS: /tmp/test-results # path to where test results will be saved
<<: *plain-go114

steps:
- checkout
- run: mkdir -p $TEST_RESULTS
- restore_cache: # restores saved cache if no changes are detected since last run
keys:
- go-mod-v4-{{ checksum "go.sum" }}
- run:
name: Testing
command: go test -v -race -coverprofile=coverage.txt -covermode=atomic `go list ./... | grep -v /contrib/`
command: |
PACKAGE_NAMES=$(go list ./... | grep -v /contrib/ | circleci tests split --split-by=timings --timings-type=classname)
gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report.xml -- $PACKAGE_NAMES -v -race -coverprofile=coverage.txt -covermode=atomic
- save_cache:
key: go-mod-v4-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"

- store_artifacts: # upload test summary for display in Artifacts
path: /tmp/test-results
destination: raw-test-output

- store_test_results: # upload test results for display in Test Summary
path: /tmp/test-results

- run:
name: Upload coverage report to Codecov
Expand All @@ -85,6 +105,8 @@ jobs:

test-contrib:
resource_class: xlarge
environment: # environment variables for the build itself
TEST_RESULTS: /tmp/test-results # path to where test results will be saved
working_directory: /home/circleci/dd-trace-go.v1
docker:
- image: circleci/golang:1.14
Expand Down Expand Up @@ -130,6 +152,10 @@ jobs:

steps:
- checkout
- run: mkdir -p $TEST_RESULTS
- restore_cache: # restores saved cache if no changes are detected since last run
keys:
- go-mod-v4-{{ checksum "go.sum" }}

- restore_cache:
keys:
Expand Down Expand Up @@ -198,7 +224,20 @@ jobs:
- run:
name: Testing integrations
command: |
INTEGRATION=1 go test -v -race -coverprofile=coverage.txt -covermode=atomic `go list ./contrib/... | grep -v -e grpc.v12 -e google.golang.org/api`
PACKAGE_NAMES=$(go list ./contrib/... | grep -v -e grpc.v12 -e google.golang.org/api | circleci tests split --split-by=timings --timings-type=classname)
gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report.xml -- $PACKAGE_NAMES -v -race -coverprofile=coverage.txt -covermode=atomic
- save_cache:
key: go-mod-v4-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"

- store_artifacts: # upload test summary for display in Artifacts
path: /tmp/test-results
destination: raw-test-output

- store_test_results: # upload test results for display in Test Summary
path: /tmp/test-results

- run:
name: Testing outlier google.golang.org/api
Expand Down
1 change: 0 additions & 1 deletion contrib/gofiber/fiber.v2/fiber.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func Middleware(opts ...Option) func(c *fiber.Ctx) error {
opts = append(opts, cfg.spanOpts...)
span, _ := tracer.StartSpanFromContext(c.Context(), "http.request", opts...)

fmt.Printf("Starting Span")
defer span.Finish()

resourceName := c.Path()
Expand Down

0 comments on commit 37b76b6

Please sign in to comment.