From 68f7a60f67006ce002699c16efdd54d66f73596a Mon Sep 17 00:00:00 2001 From: Ankit Patel <8731662+ankitpatel96@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:09:21 -0500 Subject: [PATCH 1/9] Make gotest-with-junit --- Makefile | 4 ++++ Makefile.Common | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/Makefile b/Makefile index 3051426403a..9712e22433b 100644 --- a/Makefile +++ b/Makefile @@ -56,6 +56,10 @@ gotest-with-cover: @$(MAKE) for-all-target TARGET="test-with-cover" $(GOCMD) tool covdata textfmt -i=./coverage/unit -o ./coverage.txt +.PHONY: gotest-with-junit +gotest-with-junit: + @$(MAKE) for-all-target TARGET="test-with-junit" + .PHONY: gotestifylint-fix gotestifylint-fix: $(MAKE) for-all-target TARGET="testifylint-fix" diff --git a/Makefile.Common b/Makefile.Common index 610c909eb4f..6202b6a5e75 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -4,6 +4,8 @@ ALL_PKGS := $(sort $(shell go list ./...)) # COVER_PKGS is the list of packages to include in the coverage COVER_PKGS := $(shell go list ./... | tr "\n" ",") +CURR_MOD := $(shell go list -m | tr '/' '-' ) + GOTEST_TIMEOUT?=240s GOTEST_OPT?= -race -timeout $(GOTEST_TIMEOUT) GOCMD?= go @@ -56,6 +58,11 @@ test-with-cover: $(GOTESTSUM) mkdir -p $(PWD)/coverage/unit $(GOTESTSUM) --packages="./..." -- $(GOTEST_OPT) -cover -covermode=atomic -coverpkg $(COVER_PKGS) -args -test.gocoverdir="$(PWD)/coverage/unit" +.PHONY: test-with-junit +test-with-junit: $(GOTESTSUM) + mkdir -p $(TOOLS_MOD_DIR)/testresults + $(GOTESTSUM) --packages="./..." --junitfile $(TOOLS_MOD_DIR)/testresults/$(CURR_MOD)-junit.xml -- $(GOTEST_OPT) ./... + .PHONY: benchmark benchmark: $(GOTESTSUM) $(GOTESTSUM) --packages="$(ALL_PKGS)" -- -bench=. -run=notests ./... | tee benchmark.txt From bb8aaee1b867be9c1f97645c519aa5afc6ab477f Mon Sep 17 00:00:00 2001 From: Ankit Patel <8731662+ankitpatel96@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:21:47 -0500 Subject: [PATCH 2/9] makefile --- Makefile.Common | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile.Common b/Makefile.Common index 6202b6a5e75..6e79b5d046f 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -22,6 +22,8 @@ TOOLS_PKG_NAMES := $(shell grep -E $(TOOLS_MOD_REGEX) < $(TOOLS_MOD_DIR)/tools.g TOOLS_BIN_NAMES := $(addprefix $(TOOLS_BIN_DIR)/, $(notdir $(shell echo $(TOOLS_PKG_NAMES)))) CHLOGGEN_CONFIG := .chloggen/config.yaml +JUNIT_OUT_DIR ?= $(TOOLS_MOD_DIR)/testresults/ + ADDLICENSE := $(TOOLS_BIN_DIR)/addlicense APIDIFF := $(TOOLS_BIN_DIR)/apidiff CHECKFILE := $(TOOLS_BIN_DIR)/checkfile @@ -61,7 +63,7 @@ test-with-cover: $(GOTESTSUM) .PHONY: test-with-junit test-with-junit: $(GOTESTSUM) mkdir -p $(TOOLS_MOD_DIR)/testresults - $(GOTESTSUM) --packages="./..." --junitfile $(TOOLS_MOD_DIR)/testresults/$(CURR_MOD)-junit.xml -- $(GOTEST_OPT) ./... + $(GOTESTSUM) --packages="./..." --junitfile $(JUNIT_OUT_DIR)/$(CURR_MOD)-junit.xml -- $(GOTEST_OPT) ./... .PHONY: benchmark benchmark: $(GOTESTSUM) From 9d86e1357643fb71acb4b83e94c8f7328e80a716 Mon Sep 17 00:00:00 2001 From: Ankit Patel <8731662+ankitpatel96@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:22:45 -0500 Subject: [PATCH 3/9] tweak slash --- Makefile.Common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.Common b/Makefile.Common index 6e79b5d046f..313210538d1 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -22,7 +22,7 @@ TOOLS_PKG_NAMES := $(shell grep -E $(TOOLS_MOD_REGEX) < $(TOOLS_MOD_DIR)/tools.g TOOLS_BIN_NAMES := $(addprefix $(TOOLS_BIN_DIR)/, $(notdir $(shell echo $(TOOLS_PKG_NAMES)))) CHLOGGEN_CONFIG := .chloggen/config.yaml -JUNIT_OUT_DIR ?= $(TOOLS_MOD_DIR)/testresults/ +JUNIT_OUT_DIR ?= $(TOOLS_MOD_DIR)/testresults ADDLICENSE := $(TOOLS_BIN_DIR)/addlicense APIDIFF := $(TOOLS_BIN_DIR)/apidiff From b0084e3e3ea9aaa925703e0d6ba37552972711e1 Mon Sep 17 00:00:00 2001 From: Ankit Patel <8731662+ankitpatel96@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:28:02 -0500 Subject: [PATCH 4/9] use junit in CI --- .github/workflows/build-and-test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index d2e5f23cb3c..9a9930fc97a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -168,8 +168,10 @@ jobs: path: ~/.cache/go-build key: unittest-${{ runner.os }}-${{ matrix.runner }}-go-build-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} - name: Run Unit Tests + env: + JUNIT_OUT_DIR: internal/tools/testresults/ run: | - make -j4 gotest + JUNIT_OUT_DIR=${{ env.JUNIT_OUT_DIR }} make -j4 gotest-with-junit unittest: if: always() runs-on: ubuntu-latest From 5e7b0736ebb1204d86646d99ae16bf44a08c3d18 Mon Sep 17 00:00:00 2001 From: Ankit Patel <8731662+ankitpatel96@users.noreply.github.com> Date: Thu, 19 Dec 2024 17:31:59 -0500 Subject: [PATCH 5/9] tweak slashes --- .github/workflows/build-and-test.yml | 2 +- Makefile.Common | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 9a9930fc97a..6ce2c62e635 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -169,7 +169,7 @@ jobs: key: unittest-${{ runner.os }}-${{ matrix.runner }}-go-build-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} - name: Run Unit Tests env: - JUNIT_OUT_DIR: internal/tools/testresults/ + JUNIT_OUT_DIR: internal/tools/testresults run: | JUNIT_OUT_DIR=${{ env.JUNIT_OUT_DIR }} make -j4 gotest-with-junit unittest: diff --git a/Makefile.Common b/Makefile.Common index 313210538d1..3057e734ba2 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -21,7 +21,7 @@ TOOLS_MOD_REGEX := "\s+_\s+\".*\"" TOOLS_PKG_NAMES := $(shell grep -E $(TOOLS_MOD_REGEX) < $(TOOLS_MOD_DIR)/tools.go | tr -d " _\"" | grep -vE '/v[0-9]+$$') TOOLS_BIN_NAMES := $(addprefix $(TOOLS_BIN_DIR)/, $(notdir $(shell echo $(TOOLS_PKG_NAMES)))) CHLOGGEN_CONFIG := .chloggen/config.yaml - +# no trailing slash JUNIT_OUT_DIR ?= $(TOOLS_MOD_DIR)/testresults ADDLICENSE := $(TOOLS_BIN_DIR)/addlicense From 691cdee9d6bfcef347fc511fd92b0e885b39ad91 Mon Sep 17 00:00:00 2001 From: Ankit Patel <8731662+ankitpatel96@users.noreply.github.com> Date: Thu, 19 Dec 2024 21:57:29 -0500 Subject: [PATCH 6/9] fix mkdir --- Makefile.Common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.Common b/Makefile.Common index 3057e734ba2..c003cfab3d0 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -62,7 +62,7 @@ test-with-cover: $(GOTESTSUM) .PHONY: test-with-junit test-with-junit: $(GOTESTSUM) - mkdir -p $(TOOLS_MOD_DIR)/testresults + mkdir -p $(JUNIT_OUT_DIR) $(GOTESTSUM) --packages="./..." --junitfile $(JUNIT_OUT_DIR)/$(CURR_MOD)-junit.xml -- $(GOTEST_OPT) ./... .PHONY: benchmark From 658697b5c2bd59c3b9a15d00ae790301fae699e7 Mon Sep 17 00:00:00 2001 From: Ankit Patel <8731662+ankitpatel96@users.noreply.github.com> Date: Fri, 20 Dec 2024 17:00:08 -0500 Subject: [PATCH 7/9] junit out dir --- .github/workflows/build-and-test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 6ce2c62e635..75f7a8633de 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -168,10 +168,10 @@ jobs: path: ~/.cache/go-build key: unittest-${{ runner.os }}-${{ matrix.runner }}-go-build-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} - name: Run Unit Tests - env: - JUNIT_OUT_DIR: internal/tools/testresults run: | - JUNIT_OUT_DIR=${{ env.JUNIT_OUT_DIR }} make -j4 gotest-with-junit + JUNIT_OUT_DIR=${{ github.workspace }}/internal/tools/testresults make -j4 gotest-with-junit + - name: list files + run: git ls-files . --exclude-standard --others unittest: if: always() runs-on: ubuntu-latest From 8d7eed3fe595843e0bc8dbdf614e147e931e757f Mon Sep 17 00:00:00 2001 From: Ankit Patel <8731662+ankitpatel96@users.noreply.github.com> Date: Fri, 20 Dec 2024 17:01:26 -0500 Subject: [PATCH 8/9] wait a sec dont need this at all --- .github/workflows/build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 75f7a8633de..48c362b6553 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -169,7 +169,7 @@ jobs: key: unittest-${{ runner.os }}-${{ matrix.runner }}-go-build-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} - name: Run Unit Tests run: | - JUNIT_OUT_DIR=${{ github.workspace }}/internal/tools/testresults make -j4 gotest-with-junit + make -j4 gotest-with-junit - name: list files run: git ls-files . --exclude-standard --others unittest: From c837df795dce95ffd92d3c27d2961cb666664cf9 Mon Sep 17 00:00:00 2001 From: Ankit Patel <8731662+ankitpatel96@users.noreply.github.com> Date: Fri, 20 Dec 2024 17:14:12 -0500 Subject: [PATCH 9/9] upload test artifacts --- .github/workflows/build-and-test.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 48c362b6553..870a47f6d53 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -170,8 +170,11 @@ jobs: - name: Run Unit Tests run: | make -j4 gotest-with-junit - - name: list files - run: git ls-files . --exclude-standard --others + - uses: actions/upload-artifact@v4 + with: + name: test-results-${{ runner.os }}-${{ matrix.runner }}-${{ matrix.go-version }} + path: internal/tools/testresults/ + retention-days: 4 unittest: if: always() runs-on: ubuntu-latest