Skip to content

Commit

Permalink
ci: Add codecov integration (#30)
Browse files Browse the repository at this point in the history
* ci: Add codecov integration

* ci: Remove gocovmerge dependency
  • Loading branch information
Jesse S authored Jan 18, 2024
1 parent d5dc76e commit 7ed9c93
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@ jobs:
env:
FEATKEY : /tmp
ASC_DOCKER_USER : ${{secrets.DOCKER_USER}}
ASC_DOCKER_PASS : ${{secrets.DOCKER_PASS}}
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
39 changes: 15 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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

0 comments on commit 7ed9c93

Please sign in to comment.