From 9b6f2a9076ce89a1fe0d2411cdb6cbc4cbdf14c9 Mon Sep 17 00:00:00 2001 From: Tomasz Janiszewski Date: Mon, 24 Nov 2025 18:00:01 +0100 Subject: [PATCH 1/4] setup junit output Signed-off-by: Tomasz Janiszewski --- .github/workflows/test.yml | 6 ++++++ Makefile | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7242f7b..b8a9259 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,6 +32,12 @@ jobs: - name: Run tests with coverage run: make test + - name: Upload test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 with: diff --git a/Makefile b/Makefile index ed8df6c..531b5e9 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,9 @@ LDFLAGS=-ldflags "-X github.com/stackrox/stackrox-mcp/internal/server.version=$( # Coverage files COVERAGE_OUT=coverage.out +#jUnit files +JUNIT_OUT=junit.xml + # Lint files LINT_OUT=report.xml @@ -34,7 +37,8 @@ build: ## Build the binary .PHONY: test test: ## Run unit tests with coverage - $(GOTEST) -v -cover -coverprofile=$(COVERAGE_OUT) ./... + go install github.com/jstemmer/go-junit-report/v2@v2.1.0 + $(GOTEST) -v -cover -coverprofile=$(COVERAGE_OUT) ./... -json 2>&1 | go-junit-report -parser gojson > tests.xml .PHONY: coverage-html coverage-html: test ## Generate and open HTML coverage report From 171fc661e07bbcd19849e6341f7e5cddfb6e1540 Mon Sep 17 00:00:00 2001 From: Tomasz Janiszewski Date: Mon, 24 Nov 2025 19:05:16 +0100 Subject: [PATCH 2/4] Update Makefile Co-authored-by: Mladen Todorovic --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 531b5e9..c4d4e7b 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ LDFLAGS=-ldflags "-X github.com/stackrox/stackrox-mcp/internal/server.version=$( # Coverage files COVERAGE_OUT=coverage.out -#jUnit files +# JUnit files JUNIT_OUT=junit.xml # Lint files From f20d4eb3404f544ffdd01fb51ec849d3c8f4744e Mon Sep 17 00:00:00 2001 From: Tomasz Janiszewski Date: Tue, 25 Nov 2025 10:56:09 +0100 Subject: [PATCH 3/4] fix Signed-off-by: Tomasz Janiszewski --- .github/workflows/test.yml | 3 +-- .gitignore | 3 ++- Makefile | 8 ++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b8a9259..28f3d46 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,10 +30,9 @@ jobs: run: go mod download - name: Run tests with coverage - run: make test + run: make test-coverage-and-junit - name: Upload test results to Codecov - if: ${{ !cancelled() }} uses: codecov/test-results-action@v1 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.gitignore b/.gitignore index 47bd8a3..f054949 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,9 @@ # Claude Code .claude/ -# Test coverage output +# Test output /*.out +/*junit.xml # Build output /stackrox-mcp diff --git a/Makefile b/Makefile index c4d4e7b..629a78e 100644 --- a/Makefile +++ b/Makefile @@ -36,9 +36,13 @@ build: ## Build the binary $(GOBUILD) $(LDFLAGS) -o $(BINARY_NAME) ./cmd/stackrox-mcp .PHONY: test -test: ## Run unit tests with coverage +test: ## Run unit tests + $(GOTEST) -v ./... + +.PHONY: test-coverage-and-junit +test-coverage-and-junit: ## Run unit tests with coverage and junit output go install github.com/jstemmer/go-junit-report/v2@v2.1.0 - $(GOTEST) -v -cover -coverprofile=$(COVERAGE_OUT) ./... -json 2>&1 | go-junit-report -parser gojson > tests.xml + $(GOTEST) -v -cover -race -coverprofile=$(COVERAGE_OUT) ./... -json 2>&1 | tee go-junit-report -parser gojson > $(JUNIT_OUT) .PHONY: coverage-html coverage-html: test ## Generate and open HTML coverage report From d347acc797772dac6b36a216940cc24e9d7ffc9f Mon Sep 17 00:00:00 2001 From: Tomasz Janiszewski Date: Tue, 25 Nov 2025 11:11:46 +0100 Subject: [PATCH 4/4] Apply suggestions from code review --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 629a78e..86e8721 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ test: ## Run unit tests .PHONY: test-coverage-and-junit test-coverage-and-junit: ## Run unit tests with coverage and junit output go install github.com/jstemmer/go-junit-report/v2@v2.1.0 - $(GOTEST) -v -cover -race -coverprofile=$(COVERAGE_OUT) ./... -json 2>&1 | tee go-junit-report -parser gojson > $(JUNIT_OUT) + $(GOTEST) -v -cover -race -coverprofile=$(COVERAGE_OUT) ./... -json 2>&1 | go-junit-report -parser gojson > $(JUNIT_OUT) .PHONY: coverage-html coverage-html: test ## Generate and open HTML coverage report