diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b9e2f1e..f5214fd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,4 +32,10 @@ jobs: env: FEATKEY : /tmp ASC_DOCKER_USER : ${{secrets.DOCKER_USER}} - ASC_DOCKER_PASS : ${{secrets.DOCKER_PASS}} \ No newline at end of file + ASC_DOCKER_PASS : ${{secrets.DOCKER_PASS}} + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{secrets.CODECOV_TOKEN}} + files: testdata/coverage/total.cov + verbose: false \ No newline at end of file diff --git a/Makefile b/Makefile index bf06883..33adb6d 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,10 @@ ROOT_DIR = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) VERSION = $(shell git describe --tags --always) GO_ENV_VARS = INSTALL_DIR = /usr/local/bin +TESTDATA_DIR = $(ROOT_DIR)/testdata +COVERAGE_DIR = $(TESTDATA_DIR)/coverage +COV_UNIT_DIR = $(COVERAGE_DIR)/unit +COV_INTEGRATION_DIR = $(COVERAGE_DIR)/integration ifdef GOOS GO_ENV_VARS = GOOS=$(GOOS) @@ -21,20 +25,14 @@ asconfig: dependencies .PHONY: clean clean: $(RM) bin/* - $(RM) -r testdata/coverage/* - $(RM) -r testdata/bin/* + $(RM) -r $(COVERAGE_DIR)/* + $(RM) -r $(TESTDATA_DIR)/bin/* $(MAKE) -C $(ROOT_DIR)/pkg/ $@ PHONY: dependencies dependencies: git submodule update --init -PHONY: coverage-dependencies -coverage-dependencies: - git submodule update --init - go get github.com/wadey/gocovmerge - go install github.com/wadey/gocovmerge - PHONY: install install: asconfig install -m 755 ./bin/asconfig $(INSTALL_DIR) @@ -62,27 +60,20 @@ tar: asconfig .PHONY: test test: integration unit -PHONY: integration +.PHONY: integration integration: dependencies - mkdir testdata/coverage/integration || true + mkdir -p $(COV_INTEGRATION_DIR) || true go test -tags=integration -timeout 30m - mkdir testdata/coverage/tmp_merged - go tool covdata merge -i=testdata/coverage/integration -o=testdata/coverage/tmp_merged - - go tool covdata textfmt -i=testdata/coverage/tmp_merged -o=testdata/coverage/integration.cov - rm -r testdata/coverage/tmp_merged - rm -r testdata/coverage/integration - -PHONY: unit +.PHONY: unit unit: dependencies - mkdir testdata/coverage || true - go test ./... -coverprofile testdata/coverage/unit.cov -coverpkg ./... -tags=unit + mkdir -p $(COV_UNIT_DIR) || true + go test -tags=unit -cover ./... -args -test.gocoverdir=$(COV_UNIT_DIR) -PHONY: coverage -coverage: coverage-dependencies integration unit - gocovmerge testdata/coverage/*.cov > testdata/coverage/total.cov +.PHONY: coverage +coverage: test + go tool covdata textfmt -i="$(COV_INTEGRATION_DIR),$(COV_UNIT_DIR)" -o=$(COVERAGE_DIR)/total.cov PHONY: view-coverage view-coverage: coverage - go tool cover -html=testdata/coverage/total.cov + go tool cover -html=$(COVERAGE_DIR)/total.cov