Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,20 @@ jobs:
- name: Run Unit Tests
if: startsWith( matrix.go-version, '1.23' ) != true
run: make gotest GROUP=${{ matrix.group }}
- name: Run Unit Tests With Coverage
if: startsWith( matrix.go-version, '1.23' ) # only run coverage on one version
run: make gotest-with-cover GROUP=${{ matrix.group }}
- name: Run Unit Tests With JUnit and Coverage
if: startsWith( matrix.go-version, '1.23' ) # only run junit/coverage on one version
run: make gotest-with-junit-and-cover GROUP=${{ matrix.group }}
- uses: actions/upload-artifact@v4
if: startsWith( matrix.go-version, '1.23' ) # only upload artifact for one version
with:
name: coverage-artifacts-${{ matrix.go-version }}-${{ matrix.runner }}-${{ matrix.group }}
path: ${{ matrix.group }}-coverage.txt
- uses: actions/upload-artifact@v4
if: startsWith( matrix.go-version, '1.23' ) # only upload artifact for one version
with:
name: test-results-${{ matrix.go-version }}-${{ matrix.runner }}-${{ matrix.group }}
path: internal/tools/testresults/
retention-days: 4
unittest:
if: ${{ github.actor != 'dependabot[bot]' && always() }}
runs-on: ubuntu-24.04
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ __debug_bin*
coverage/*
*-coverage.txt
integration-coverage.html
internal/tools/testresults/*

# Wix
*.wixobj
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ gotest:
gotest-with-cover:
@$(MAKE) $(FOR_GROUP_TARGET) TARGET="test-with-cover"
$(GOCMD) tool covdata textfmt -i=./coverage/unit -o ./$(GROUP)-coverage.txt

.PHONY: gotest-with-junit
gotest-with-junit:
@$(MAKE) for-all-target TARGET="test-with-junit"

.PHONY: gotest-with-junit-and-cover
gotest-with-junit-and-cover:
@$(MAKE) for-all-target TARGET="test-with-junit-and-cover"

.PHONY: gobuildtest
gobuildtest:
Expand Down
16 changes: 16 additions & 0 deletions Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ GOTESTARCH?=$(GOARCH)

DOCKERCMD ?= docker

CURR_MOD := $(shell go list -m | tr '/' '-' )

# In order to help reduce toil related to managing tooling for the open telemetry collector
# this section of the makefile looks at only requiring command definitions to be defined
# as part of $(TOOLS_MOD_DIR)/tools.go, following the existing practice.
Expand All @@ -42,6 +44,9 @@ TOOLS_BIN_DIR := $(SRC_ROOT)/.tools
TOOLS_BIN_NAMES := $(addprefix $(TOOLS_BIN_DIR)/, $(notdir $(TOOLS_PKG_NAMES)))
CHLOGGEN_CONFIG := .chloggen/config.yaml

# no trailing slash
JUNIT_OUT_DIR ?= $(TOOLS_MOD_DIR)/testresults

.PHONY: install-tools
install-tools: $(TOOLS_BIN_NAMES)

Expand Down Expand Up @@ -107,6 +112,17 @@ do-unit-tests-with-cover: $(GOTESTSUM)
$(GOTESTSUM) $(GOTESTSUM_OPT) --packages="./..." -- $(GOTEST_OPT_WITH_COVERAGE)
$(GOCMD) tool cover -html=coverage.txt -o coverage.html

.PHONY: test-with-junit
test-with-junit: $(GOTESTSUM)
mkdir -p $(JUNIT_OUT_DIR)
$(GOTESTSUM) $(GOTESTSUM_OPT) --packages="./..." --junitfile $(JUNIT_OUT_DIR)/$(CURR_MOD)-junit.xml -- $(GOTEST_OPT) ./...

.PHONY: test-with-junit-and-cover
test-with-junit-and-cover: $(GOTESTSUM)
mkdir -p $(JUNIT_OUT_DIR)
$(GOTESTSUM) $(GOTESTSUM_OPT) --packages="./..." --junitfile $(JUNIT_OUT_DIR)/$(CURR_MOD)-junit.xml -- $(GOTEST_OPT_WITH_COVERAGE) ./...
$(GOCMD) tool cover -html=coverage.txt -o coverage.html

.PHONY: buildtest
buildtest:
ifneq (,$(wildcard ./*.go))
Expand Down