Skip to content

Commit 8c7a0e2

Browse files
authored
Add Codecov (#1626)
Problem: We don't have a history of our code coverage and we want to see how it changes over time and with every PR. We also want to have a badge that shows the overall coverage. Solution: Use Codecov to upload coverage and get diffs in every PR that changes code. Also add a badge in the README to show the coverage.
1 parent ad80b76 commit 8c7a0e2

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

.codecov.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
informational: true
6+
comment:
7+
require_changes: true

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ jobs:
6767
- name: Run Tests
6868
run: make unit-test
6969

70+
- name: Upload coverage reports to Codecov
71+
uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab # v4.1.0
72+
with:
73+
token: ${{ secrets.CODECOV_TOKEN }}
74+
7075
- name: Upload Coverage Report
7176
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
7277
with:

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ lint: ## Run golangci-lint against code
140140
.PHONY: unit-test
141141
unit-test: ## Run unit tests for the go code
142142
# We have to run the tests in the cmd package using `go test` because of a bug with the CLI library cobra. See https://github.com/spf13/cobra/issues/2104.
143-
go test ./cmd/... -race -coverprofile cmd-cover.out
144-
go run github.com/onsi/ginkgo/v2/ginkgo --randomize-all --randomize-suites --race --keep-going --fail-on-pending --trace --cover --coverprofile=cover.out -r internal
145-
go tool cover -html=cover.out -o cover.html
146-
go tool cover -html=cmd-cover.out -o cmd-cover.html
143+
go test ./cmd/... -race -shuffle=on -coverprofile=cmd-coverage.out -covermode=atomic
144+
go run github.com/onsi/ginkgo/v2/ginkgo --randomize-all --randomize-suites --race --keep-going --fail-on-pending --trace --covermode=atomic --coverprofile=coverage.out -r internal
145+
go tool cover -html=coverage.out -o cover.html
146+
go tool cover -html=cmd-coverage.out -o cmd-cover.html
147147

148148
.PHONY: njs-unit-test
149149
njs-unit-test: ## Run unit tests for the njs httpmatches module

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![Continuous Integration](https://github.com/nginxinc/nginx-gateway-fabric/actions/workflows/ci.yml/badge.svg)](https://github.com/nginxinc/nginx-gateway-fabric/actions/workflows/ci.yml)
44
[![Conformance Testing](https://github.com/nginxinc/nginx-gateway-fabric/actions/workflows/conformance.yml/badge.svg)](https://github.com/nginxinc/nginx-gateway-fabric/actions/workflows/conformance.yml)
55
[![Go Report Card](https://goreportcard.com/badge/github.com/nginxinc/nginx-gateway-fabric)](https://goreportcard.com/report/github.com/nginxinc/nginx-gateway-fabric)
6+
[![codecov](https://codecov.io/gh/nginxinc/nginx-gateway-fabric/graph/badge.svg?token=32ULC8F13Z)](https://codecov.io/gh/nginxinc/nginx-gateway-fabric)
67
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/nginxinc/nginx-gateway-fabric?logo=github&sort=semver)](https://github.com/nginxinc/nginx-gateway-fabric/releases/latest)
78
[![Slack](https://img.shields.io/badge/slack-%23nginx--gateway--fabric-green?logo=slack)](https://nginxcommunity.slack.com/channels/nginx-gateway-fabric)
89
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)

0 commit comments

Comments
 (0)