Skip to content

Commit c8c2216

Browse files
authored
Merge pull request #958 from ArangoGutierrez/codecov
[no-relnote] Enable Coveralls for code coverage
2 parents ea9b872 + e955f65 commit c8c2216

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
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: Run unit tests and generate coverage report
76+
run: make coverage
77+
78+
- name: Upload to Coveralls
79+
uses: coverallsapp/github-action@v2
80+
with:
81+
github-token: ${{ secrets.GITHUB_TOKEN }}
82+
file: coverage.out
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ licenses:
122122

123123
COVERAGE_FILE := coverage.out
124124
test: build cmds
125-
go test -coverprofile=$(COVERAGE_FILE) $(MODULE)/...
125+
go test -coverprofile=$(COVERAGE_FILE).with-mocks $(MODULE)/...
126126

127127
coverage: test
128-
cat $(COVERAGE_FILE) | grep -v "_mock.go" > $(COVERAGE_FILE).no-mocks
129-
go tool cover -func=$(COVERAGE_FILE).no-mocks
128+
cat $(COVERAGE_FILE).with-mocks | grep -v "_mock.go" > $(COVERAGE_FILE)
129+
go tool cover -func=$(COVERAGE_FILE)
130130

131131
generate:
132132
go generate $(MODULE)/...

0 commit comments

Comments
 (0)