Skip to content

Commit

Permalink
codecov v4 (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinsonneau authored Apr 12, 2024
1 parent a5ad247 commit e47e0ce
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
run: go mod vendor
- name: upload coverage to codecov.io
if: ${{ matrix.go == '1.21' }}
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
files: /tmp/coverage.out
files: ./cover.out
flags: unittests
fail_ci_if_error: true
24 changes: 24 additions & 0 deletions .github/workflows/push_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,27 @@ jobs:
if [[ "main" == "$WF_VERSION" ]]; then
MULTIARCH_TARGETS="${{ env.WF_MULTIARCH_TARGETS }}" IMAGE_ORG=${{ env.WF_ORG }} VERSION=latest make images
fi
codecov:
name: Codecov upload
runs-on: ubuntu-latest
strategy:
matrix:
go: ['1.21']
steps:
- name: install make
run: sudo apt-get install make
- name: set up go 1.x
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- name: checkout
uses: actions/checkout@v3
- name: Test
run: make tests-unit coverage-report
- name: Report coverage
uses: codecov/codecov-action@v4
with:
files: ./cover.out
flags: unittests
fail_ci_if_error: false
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/flowlogs-pipeline
/confgenerator
/bin/

cover.out
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,24 @@ clean: ## Clean
rm -f "${FLP_BIN_FILE}"
go clean ./...

# note: to review coverage execute: go tool cover -html=/tmp/coverage.out
TEST_OPTS := -race -coverpkg=./... -covermode=atomic -coverprofile=/tmp/coverage.out
TEST_OPTS := -race -coverpkg=./... -covermode=atomic -coverprofile cover.out
.PHONY: tests-unit
tests-unit: validate_go ## Unit tests
# tests may rely on non-thread safe libs such as go-ipfix => no -race flag
go test $$(go list ./... | grep /testnorace)
# enabling CGO is required for -race flag
CGO_ENABLED=1 go test -p 1 $(TEST_OPTS) $$(go list ./... | grep -v /e2e | grep -v /testnorace)

.PHONY: coverage-report
coverage-report: ## Generate coverage report
@echo "### Generating coverage report"
go tool cover --func=./cover.out

.PHONY: coverage-report-html
coverage-report-html: ## Generate HTML coverage report
@echo "### Generating HTML coverage report"
go tool cover --html=./cover.out

.PHONY: tests-fast
tests-fast: TEST_OPTS=
tests-fast: tests-unit ## Fast unit tests (no race tests / coverage)
Expand Down

0 comments on commit e47e0ce

Please sign in to comment.