diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 04f1fba..c66fc01 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -34,7 +34,7 @@ jobs: run: pre-commit install - name: Run all pre-commit hooks run: SKIP=golangci-lint pre-commit run --all-files - build: + test: runs-on: ubuntu-24.04 steps: - name: Checkout code @@ -65,7 +65,13 @@ jobs: - name: Run go tests env: STORAGE_EMULATOR_HOST: http://0.0.0.0:4443 - run: go test ./... + run: go test ./... -coverprofile=./cover.out -covermode=atomic + - name: check test coverage + uses: vladopajic/go-test-coverage@v2 + with: + profile: ./cover.out + local-prefix: "github.com/Optable/optable-pair-cli" + threshold-total: 70 - name: Cleanup if: always() run: docker stop fake-gcs-server && docker rm fake-gcs-server diff --git a/Makefile b/Makefile index d418e95..619b6e2 100644 --- a/Makefile +++ b/Makefile @@ -99,3 +99,8 @@ clean-fake-gcs-server: .PHONY: test test: start-fake-gcs-server STORAGE_EMULATOR_HOST=$(STORAGE_EMULATOR_HOST) $(GO) test -v ./... + +.PHONY: coverage +coverage: start-fake-gcs-server + STORAGE_EMULATOR_HOST=$(STORAGE_EMULATOR_HOST) $(GO) test -coverprofile coverage.out ./... + $(GO) tool cover -html=coverage.out diff --git a/go.mod b/go.mod index 056cb40..7550e04 100644 --- a/go.mod +++ b/go.mod @@ -49,6 +49,8 @@ require ( golang.org/x/sys v0.24.0 // indirect golang.org/x/text v0.17.0 // indirect golang.org/x/time v0.6.0 // indirect + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect + golang.org/x/tools/cmd/cover v0.1.0-deprecated // indirect golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 // indirect google.golang.org/genproto v0.0.0-20240812133136-8ffd90a71988 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240812133136-8ffd90a71988 // indirect diff --git a/go.sum b/go.sum index c41a7d3..18a0857 100644 --- a/go.sum +++ b/go.sum @@ -257,6 +257,10 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/tools/cmd/cover v0.1.0-deprecated h1:Rwy+mWYz6loAF+LnG1jHG/JWMHRMMC2/1XX3Ejkx9lA= +golang.org/x/tools/cmd/cover v0.1.0-deprecated/go.mod h1:hMDiIvlpN1NoVgmjLjUJE9tMHyxHjFX7RuQ+rW12mSA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 h1:LLhsEBxRTBLuKlQxFBYUOU8xyFgXv6cOTp2HASDlsDk=