From cf917ddab91697b61b47ae23f96befcc1d7cb2e5 Mon Sep 17 00:00:00 2001 From: Albert <26584478+albertteoh@users.noreply.github.com> Date: Mon, 25 Dec 2023 04:55:57 +1100 Subject: [PATCH] Publish test report (#5030) ## Which problem is this PR solving? - Resolves #2859 ## Description of the changes - Publish unit test results using https://github.com/EnricoMi/publish-unit-test-result-action ## How was this change tested? - Tested in my fork: https://github.com/albertteoh/jaeger/actions/runs/7312986726 ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits --------- Signed-off-by: Albert Teoh Co-authored-by: Albert Teoh --- .github/workflows/ci-unit-tests-go-tip.yml | 10 +++++++--- .github/workflows/ci-unit-tests.yml | 7 +++++++ .gitignore | 1 + Makefile | 11 ++++++++--- model/keyvalue_test.go | 21 +++++++++++---------- 5 files changed, 34 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci-unit-tests-go-tip.yml b/.github/workflows/ci-unit-tests-go-tip.yml index 3fa37e9d34f..01382e9a5b8 100644 --- a/.github/workflows/ci-unit-tests-go-tip.yml +++ b/.github/workflows/ci-unit-tests-go-tip.yml @@ -22,11 +22,15 @@ jobs: - name: Install Go Tip uses: ./.github/actions/setup-go-tip - - name: Install tools - run: make install-test-tools - - name: Run unit tests run: make test-ci + - name: Publish Unit Test Summary 📑 + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + check_name: Unit Tests Summary + junit_files: junit-report.xml + - name: Lint run: echo skip linting on Go tip diff --git a/.github/workflows/ci-unit-tests.yml b/.github/workflows/ci-unit-tests.yml index 5a076395873..8ca5d998b46 100644 --- a/.github/workflows/ci-unit-tests.yml +++ b/.github/workflows/ci-unit-tests.yml @@ -34,6 +34,13 @@ jobs: - name: Run unit tests run: make test-ci + - name: Publish Unit Test Summary 📑 + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + check_name: Unit Tests Summary + junit_files: junit-report.xml + - name: Setup CODECOV_TOKEN uses: ./.github/actions/setup-codecov diff --git a/.gitignore b/.gitignore index cab27dfbc85..a66dcb760cd 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,4 @@ deploy-staging/ sha256sum.combined.txt resource.syso .gocache +test-results.json diff --git a/Makefile b/Makefile index 08fd2e6acfb..3858c2ce101 100644 --- a/Makefile +++ b/Makefile @@ -154,7 +154,7 @@ index-rollover-integration-test: docker-images-elastic .PHONY: cover cover: nocover - $(GOTEST) -tags=memory_storage_integration -timeout 5m -coverprofile cover.out ./... + $(GOTEST) -tags=memory_storage_integration -timeout 5m -coverprofile cover.out ./... > test-results.json go tool cover -html=cover.out -o cover.html .PHONY: nocover @@ -494,6 +494,7 @@ draft-release: install-test-tools: $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2 $(GO) install mvdan.cc/gofumpt@latest + $(GO) install github.com/jstemmer/go-junit-report/v2@latest .PHONY: install-build-tools install-build-tools: @@ -507,8 +508,12 @@ install-tools: install-test-tools install-build-tools install-ci: install-test-tools install-build-tools .PHONY: test-ci -test-ci: GOTEST := $(GOTEST_QUIET) -test-ci: build-examples cover +test-ci: GOTEST := $(GOTEST_QUIET) -json +test-ci: install-test-tools build-examples cover test-report + +.PHONY: test-report +test-report: + cat test-results.json | go-junit-report -parser gojson > junit-report.xml .PHONY: thrift thrift: idl/thrift/jaeger.thrift thrift-image diff --git a/model/keyvalue_test.go b/model/keyvalue_test.go index d7af48fe232..9db74e4d8b4 100644 --- a/model/keyvalue_test.go +++ b/model/keyvalue_test.go @@ -115,24 +115,25 @@ func TestKeyValueAsStringAndValue(t *testing.T) { expectedBinaryStr := `42656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565730a0942656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565730a0942656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565730a0942656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565730a0942656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f6472696775657320` expectedBinaryStrLossy := `42656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565730a0942656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565732042656e6465722042656e64696e6720526f647269677565730a0942656e6465722042656e64696e6720526f647269677565732042656e64...` testCases := []struct { + name string kv model.KeyValue str string strLossy string val interface{} }{ - {kv: model.String("x", "Bender is great!"), str: "Bender is great!", val: "Bender is great!"}, - {kv: model.Bool("x", false), str: "false", val: false}, - {kv: model.Bool("x", true), str: "true", val: true}, - {kv: model.Int64("x", 3000), str: "3000", val: int64(3000)}, - {kv: model.Int64("x", -1947), str: "-1947", val: int64(-1947)}, - {kv: model.Float64("x", 3.14159265359), str: "3.141592654", val: float64(3.14159265359)}, - {kv: model.Binary("x", []byte("Bender")), str: "42656e646572", val: []byte("Bender")}, - {kv: model.Binary("x", []byte(longString)), str: expectedBinaryStr, val: []byte(longString)}, - {kv: model.Binary("x", []byte(longString)), strLossy: expectedBinaryStrLossy, val: []byte(longString)}, + {name: "Bender is great!", kv: model.String("x", "Bender is great!"), str: "Bender is great!", val: "Bender is great!"}, + {name: "false", kv: model.Bool("x", false), str: "false", val: false}, + {name: "true", kv: model.Bool("x", true), str: "true", val: true}, + {name: "3000", kv: model.Int64("x", 3000), str: "3000", val: int64(3000)}, + {name: "-1947", kv: model.Int64("x", -1947), str: "-1947", val: int64(-1947)}, + {name: "3.141592654", kv: model.Float64("x", 3.14159265359), str: "3.141592654", val: float64(3.14159265359)}, + {name: "42656e646572", kv: model.Binary("x", []byte("Bender")), str: "42656e646572", val: []byte("Bender")}, + {name: "binary string", kv: model.Binary("x", []byte(longString)), str: expectedBinaryStr, val: []byte(longString)}, + {name: "binary string (lossy)", kv: model.Binary("x", []byte(longString)), strLossy: expectedBinaryStrLossy, val: []byte(longString)}, } for _, tt := range testCases { testCase := tt // capture loop var - t.Run(testCase.str, func(t *testing.T) { + t.Run(testCase.name, func(t *testing.T) { if testCase.strLossy != "" { assert.Equal(t, testCase.strLossy, testCase.kv.AsStringLossy()) } else {