diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index 51576e3..4a72be5 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -23,3 +23,39 @@ jobs: - name: Build run: make build + + - uses: actions/upload-artifact@v2 + with: + name: coverage.out + path: coverage.out + + coverage: + runs-on: ubuntu-20.04 + needs: [ build ] + if: github.event_name == 'pull_request' + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.17 + + - name: download coverage.out + uses: actions/download-artifact@v2 + with: + name: coverage.out + path: ./ + + - name: coverage conversion setup + run: go install github.com/jandelgado/gcov2lcov@v1.0.5 + + - name: coverage conversion + run: gcov2lcov -infile=coverage.out -outfile=coverage.lcov + + - name: code coverage comment + uses: romeovs/lcov-reporter-action@v0.2.16 + with: + lcov-file: ./coverage.lcov + github-token: ${{ secrets.GITHUB_TOKEN }} + delete-old-comments: true diff --git a/.gitignore b/.gitignore index 508f759..e1d6ef6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ # Binaries for programs and plugins bin/ dist/ +coverage.out diff --git a/Makefile b/Makefile index fc40e4a..a19f5dd 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ vet: .PHONY: test test: lint vet - go test ./... ./cmd/... + go test -coverprofile=coverage.out ./... ./cmd/... .PHONY: build build: bin/pvmigrate diff --git a/go.mod b/go.mod index 936696b..a200146 100644 --- a/go.mod +++ b/go.mod @@ -35,12 +35,14 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/spf13/pflag v1.0.5 // indirect golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect + golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8 // indirect golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect + golang.org/x/tools v0.1.5 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.27.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect diff --git a/go.sum b/go.sum index bb28264..de553b7 100644 --- a/go.sum +++ b/go.sum @@ -522,6 +522,7 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= 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 golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.6-0.20210820212750-d4cc65f0b2ff/go.mod h1:YD9qOF0M9xpSpdWTBbzEl5e/RnCefISl8E5Noe10jFM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/pkg/version/version_test.go b/pkg/version/version_test.go new file mode 100644 index 0000000..0767093 --- /dev/null +++ b/pkg/version/version_test.go @@ -0,0 +1,18 @@ +package version + +import "testing" + +func TestPrint(t *testing.T) { + tests := []struct { + name string + }{ + { + name: "this should not panic", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + Print() + }) + } +}