Skip to content

Commit 1f8fd5d

Browse files
[no-relnote] Enable CodeCov
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
1 parent be6a36c commit 1f8fd5d

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

.github/workflows/golang.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,54 +30,73 @@ jobs:
3030
steps:
3131
- uses: actions/checkout@v4
3232
name: Checkout code
33+
3334
- name: Get Golang version
3435
id: vars
3536
run: |
3637
GOLANG_VERSION=$(./hack/golang-version.sh)
3738
echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION := }" >> $GITHUB_ENV
39+
3840
- name: Install Go
3941
uses: actions/setup-go@v5
4042
with:
4143
go-version: ${{ env.GOLANG_VERSION }}
44+
4245
- name: Lint
4346
uses: golangci/golangci-lint-action@v8
4447
with:
4548
version: latest
4649
args: -v --timeout 5m
4750
skip-cache: true
51+
4852
- name: Check golang modules
4953
run: |
5054
make check-vendor
5155
make -C deployments/devel check-modules
56+
5257
test:
5358
name: Unit test
5459
runs-on: ubuntu-latest
5560
steps:
5661
- name: Checkout code
5762
uses: actions/checkout@v4
63+
5864
- name: Get Golang version
5965
id: vars
6066
run: |
6167
GOLANG_VERSION=$(./hack/golang-version.sh)
6268
echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION := }" >> $GITHUB_ENV
69+
6370
- name: Install Go
6471
uses: actions/setup-go@v5
6572
with:
6673
go-version: ${{ env.GOLANG_VERSION }}
67-
- run: make test
74+
75+
- name: Generate coverage report
76+
run: make cov-report
77+
78+
- name: Upload to Coveralls
79+
uses: coverallsapp/github-action@v2
80+
with:
81+
github-token: ${{ secrets.GITHUB_TOKEN }}
82+
path-to-lcov: lcov.info
83+
6884
build:
6985
name: Build
7086
runs-on: ubuntu-latest
7187
steps:
7288
- name: Checkout code
7389
uses: actions/checkout@v4
90+
7491
- name: Get Golang version
7592
id: vars
7693
run: |
7794
GOLANG_VERSION=$(./hack/golang-version.sh)
7895
echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION ?= }" >> $GITHUB_ENV
96+
7997
- name: Install Go
8098
uses: actions/setup-go@v5
8199
with:
82100
go-version: ${{ env.GOLANG_VERSION }}
101+
83102
- run: make build

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ CMDS := $(patsubst ./cmd/%/,%,$(sort $(dir $(wildcard ./cmd/*/))))
3939
CMD_TARGETS := $(patsubst %,cmd-%, $(CMDS))
4040

4141
CHECK_TARGETS := lint
42-
MAKE_TARGETS := binaries build check fmt test examples cmds coverage generate licenses vendor check-vendor $(CHECK_TARGETS)
42+
MAKE_TARGETS := binaries build check fmt test cov-report examples cmds coverage generate licenses vendor check-vendor $(CHECK_TARGETS)
4343

4444
TARGETS := $(MAKE_TARGETS) $(EXAMPLE_TARGETS) $(CMD_TARGETS)
4545

@@ -128,6 +128,12 @@ coverage: test
128128
cat $(COVERAGE_FILE) | grep -v "_mock.go" > $(COVERAGE_FILE).no-mocks
129129
go tool cover -func=$(COVERAGE_FILE).no-mocks
130130

131+
cov-report: gcov2lcov test ## Build test coverage report in lcov format
132+
$(GCOV2LCOV) -infile cover.out -outfile lcov.info
133+
134+
gcov2lcov: ## Download gcov2lcov locally if necessary.
135+
$(call go-install-tool,$(GCOV2LCOV),github.com/jandelgado/gcov2lcov@$(GCOV2LCOV_VERSION))
136+
131137
generate:
132138
go generate $(MODULE)/...
133139

0 commit comments

Comments
 (0)