Skip to content

Commit b3731b3

Browse files
committed
get code coverage in tests
1 parent 0a26454 commit b3731b3

File tree

6 files changed

+58
-1
lines changed

6 files changed

+58
-1
lines changed

.github/workflows/build-test.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,37 @@ jobs:
2323

2424
- name: Build
2525
run: make build
26+
27+
- uses: actions/upload-artifact@v2
28+
with:
29+
name: coverage.out
30+
path: coverage.out
31+
32+
coverage:
33+
runs-on: ubuntu-20.04
34+
needs: [ build ]
35+
steps:
36+
- uses: actions/checkout@v3
37+
38+
- name: Set up Go
39+
uses: actions/setup-go@v3
40+
with:
41+
go-version: 1.17
42+
43+
- name: download coverage.out
44+
uses: actions/download-artifact@v2
45+
with:
46+
name: coverage.out
47+
path: ./
48+
49+
- name: coverage conversion setup
50+
run: go install github.com/jandelgado/[email protected]
51+
52+
- name: coverage conversion
53+
run: gcov2lcov -infile=coverage.out -outfile=coverage.lcov
54+
55+
- name: code coverage comment
56+
uses: romeovs/[email protected]
57+
with:
58+
lcov-file: ./coverage.lcov
59+
github-token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Binaries for programs and plugins
22
bin/
33
dist/
4+
coverage.out

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ vet:
4646

4747
.PHONY: test
4848
test: lint vet
49-
go test ./... ./cmd/...
49+
go test -coverprofile=coverage.out ./... ./cmd/...
5050

5151
.PHONY: build
5252
build: bin/pvmigrate

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ require (
3535
github.com/pmezard/go-difflib v1.0.0 // indirect
3636
github.com/spf13/pflag v1.0.5 // indirect
3737
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
38+
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
3839
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
3940
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
4041
golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8 // indirect
4142
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
4243
golang.org/x/text v0.3.7 // indirect
4344
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
45+
golang.org/x/tools v0.1.5 // indirect
4446
google.golang.org/appengine v1.6.7 // indirect
4547
google.golang.org/protobuf v1.27.1 // indirect
4648
gopkg.in/inf.v0 v0.9.1 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,7 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu
522522
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
523523
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
524524
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
525+
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=
525526
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
526527
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
527528
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
@@ -751,6 +752,7 @@ golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4f
751752
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
752753
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
753754
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
755+
golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
754756
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
755757
golang.org/x/tools v0.1.6-0.20210820212750-d4cc65f0b2ff/go.mod h1:YD9qOF0M9xpSpdWTBbzEl5e/RnCefISl8E5Noe10jFM=
756758
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

pkg/version/version_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package version
2+
3+
import "testing"
4+
5+
func TestPrint(t *testing.T) {
6+
tests := []struct {
7+
name string
8+
}{
9+
{
10+
name: "this should not panic",
11+
},
12+
}
13+
for _, tt := range tests {
14+
t.Run(tt.name, func(t *testing.T) {
15+
Print()
16+
})
17+
}
18+
}

0 commit comments

Comments
 (0)