diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7242f7b..28f3d46 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,7 +30,12 @@ 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 + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 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 ed8df6c..86e8721 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 @@ -33,8 +36,13 @@ build: ## Build the binary $(GOBUILD) $(LDFLAGS) -o $(BINARY_NAME) ./cmd/stackrox-mcp .PHONY: test -test: ## Run unit tests with coverage - $(GOTEST) -v -cover -coverprofile=$(COVERAGE_OUT) ./... +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 -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