From 28395eebf22a1e9747b6eae804d98ad3b7705472 Mon Sep 17 00:00:00 2001 From: amanjpro Date: Thu, 12 Dec 2024 12:00:24 -0500 Subject: [PATCH 1/8] Add coverage target to make --- Makefile | 5 +++++ go.mod | 2 ++ go.sum | 4 ++++ 3 files changed, 11 insertions(+) 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= From df2bdad820960ae782edc8d06c1a868c10a85424 Mon Sep 17 00:00:00 2001 From: amanjpro Date: Thu, 12 Dec 2024 13:35:12 -0500 Subject: [PATCH 2/8] ci coverage --- .github/workflows/pr.yml | 6 ++++- .testcoverage.yml | 55 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 .testcoverage.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 04f1fba..2573b02 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -65,7 +65,11 @@ 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 -coverpkg=./... + - name: check test coverage + uses: vladopajic/go-test-coverage@v2 + with: + config: ./.testcoverage.yml - name: Cleanup if: always() run: docker stop fake-gcs-server && docker rm fake-gcs-server diff --git a/.testcoverage.yml b/.testcoverage.yml new file mode 100644 index 0000000..3ad750d --- /dev/null +++ b/.testcoverage.yml @@ -0,0 +1,55 @@ +# (mandatory) +# Path to coverage profile file (output of `go test -coverprofile` command). +# +# For cases where there are many coverage profiles, such as when running +# unit tests and integration tests separately, you can combine all those +# profiles into one. In this case, the profile should have a comma-separated list +# of profile files, e.g., 'cover_unit.out,cover_integration.out'. +profile: cover.out + +# (optional; but recommended to set) +# When specified reported file paths will not contain local prefix in the output. +local-prefix: "github.com/Optable/optable-pair-cli" + +# Holds coverage thresholds percentages, values should be in range [0-100]. +threshold: + # (optional; default 0) + # Minimum coverage percentage required for individual files. + file: 60 + + # (optional; default 0) + # Minimum coverage percentage required for each package. + package: 60 + + # (optional; default 0) + # Minimum overall project coverage percentage required. + total: 60 + +# Holds regexp rules which will override thresholds for matched files or packages +# using their paths. +# +# First rule from this list that matches file or package is going to apply +# new threshold to it. If project has multiple rules that match same path, +# override rules should be listed in order from specific to more general rules. +# override: +# # Increase coverage threshold to 100% for `foo` package +# # (default is 80, as configured above in this example). +# - path: ^pkg/lib/foo$ +# threshold: 100 + +# # Holds regexp rules which will exclude matched files or packages +# # from coverage statistics. +# exclude: +# # Exclude files or packages matching their paths +# paths: +# - \.pb\.go$ # excludes all protobuf generated files +# - ^pkg/bar # exclude package `pkg/bar` + +# File name of go-test-coverage breakdown file, which can be used to +# # analyze coverage difference. +# breakdown-file-name: '' +# +# diff: +# # File name of go-test-coverage breakdown file which will be used to +# # report coverage difference. +# base-breakdown-file-name: '' From 3df8714792ec725e1d2294b8dac56ee590b3d4d4 Mon Sep 17 00:00:00 2001 From: amanjpro Date: Thu, 12 Dec 2024 13:40:24 -0500 Subject: [PATCH 3/8] now --- .github/workflows/pr.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 2573b02..3a24448 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -69,7 +69,9 @@ jobs: - name: check test coverage uses: vladopajic/go-test-coverage@v2 with: - config: ./.testcoverage.yml + with: + profile: cover.out + threshold-total: 60 - name: Cleanup if: always() run: docker stop fake-gcs-server && docker rm fake-gcs-server From 3d926706eef11a1c6703a7ea72415b9b771852ec Mon Sep 17 00:00:00 2001 From: amanjpro Date: Thu, 12 Dec 2024 13:42:21 -0500 Subject: [PATCH 4/8] now --- .github/workflows/pr.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 3a24448..8a5b2d4 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -69,9 +69,8 @@ jobs: - name: check test coverage uses: vladopajic/go-test-coverage@v2 with: - with: - profile: cover.out - threshold-total: 60 + profile: cover.out + threshold-total: 60 - name: Cleanup if: always() run: docker stop fake-gcs-server && docker rm fake-gcs-server From 78f1d297d5854e8f2c526aaa7595c354ed259f41 Mon Sep 17 00:00:00 2001 From: amanjpro Date: Thu, 12 Dec 2024 13:51:25 -0500 Subject: [PATCH 5/8] another now --- .github/workflows/pr.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 8a5b2d4..04920b8 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -70,6 +70,7 @@ jobs: uses: vladopajic/go-test-coverage@v2 with: profile: cover.out + local-prefix: "github.com/Optable/optable-pair-cli" threshold-total: 60 - name: Cleanup if: always() From 3415d33058b3f825b73a4885d38d4cc1589cc1c9 Mon Sep 17 00:00:00 2001 From: amanjpro Date: Thu, 12 Dec 2024 14:02:22 -0500 Subject: [PATCH 6/8] now --- .github/workflows/pr.yml | 6 ++--- .testcoverage.yml | 55 ---------------------------------------- 2 files changed, 3 insertions(+), 58 deletions(-) delete mode 100644 .testcoverage.yml diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 04920b8..8e5a408 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,11 +65,11 @@ jobs: - name: Run go tests env: STORAGE_EMULATOR_HOST: http://0.0.0.0:4443 - run: go test ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./... + run: go test ./... -coverprofile=./cover.out -covermode=atomic - name: check test coverage uses: vladopajic/go-test-coverage@v2 with: - profile: cover.out + profile: ./cover.out local-prefix: "github.com/Optable/optable-pair-cli" threshold-total: 60 - name: Cleanup diff --git a/.testcoverage.yml b/.testcoverage.yml deleted file mode 100644 index 3ad750d..0000000 --- a/.testcoverage.yml +++ /dev/null @@ -1,55 +0,0 @@ -# (mandatory) -# Path to coverage profile file (output of `go test -coverprofile` command). -# -# For cases where there are many coverage profiles, such as when running -# unit tests and integration tests separately, you can combine all those -# profiles into one. In this case, the profile should have a comma-separated list -# of profile files, e.g., 'cover_unit.out,cover_integration.out'. -profile: cover.out - -# (optional; but recommended to set) -# When specified reported file paths will not contain local prefix in the output. -local-prefix: "github.com/Optable/optable-pair-cli" - -# Holds coverage thresholds percentages, values should be in range [0-100]. -threshold: - # (optional; default 0) - # Minimum coverage percentage required for individual files. - file: 60 - - # (optional; default 0) - # Minimum coverage percentage required for each package. - package: 60 - - # (optional; default 0) - # Minimum overall project coverage percentage required. - total: 60 - -# Holds regexp rules which will override thresholds for matched files or packages -# using their paths. -# -# First rule from this list that matches file or package is going to apply -# new threshold to it. If project has multiple rules that match same path, -# override rules should be listed in order from specific to more general rules. -# override: -# # Increase coverage threshold to 100% for `foo` package -# # (default is 80, as configured above in this example). -# - path: ^pkg/lib/foo$ -# threshold: 100 - -# # Holds regexp rules which will exclude matched files or packages -# # from coverage statistics. -# exclude: -# # Exclude files or packages matching their paths -# paths: -# - \.pb\.go$ # excludes all protobuf generated files -# - ^pkg/bar # exclude package `pkg/bar` - -# File name of go-test-coverage breakdown file, which can be used to -# # analyze coverage difference. -# breakdown-file-name: '' -# -# diff: -# # File name of go-test-coverage breakdown file which will be used to -# # report coverage difference. -# base-breakdown-file-name: '' From 6ab4f39153785f322ac0c7b5d3b8bd3cc3195f83 Mon Sep 17 00:00:00 2001 From: amanjpro Date: Thu, 12 Dec 2024 14:08:53 -0500 Subject: [PATCH 7/8] test --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 8e5a408..2aad1dd 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -71,7 +71,7 @@ jobs: with: profile: ./cover.out local-prefix: "github.com/Optable/optable-pair-cli" - threshold-total: 60 + threshold-total: 90 - name: Cleanup if: always() run: docker stop fake-gcs-server && docker rm fake-gcs-server From 1ad2ef4193b0eb33bb6e1422b416440821470579 Mon Sep 17 00:00:00 2001 From: amanjpro Date: Thu, 12 Dec 2024 14:10:34 -0500 Subject: [PATCH 8/8] 70% --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 2aad1dd..c66fc01 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -71,7 +71,7 @@ jobs: with: profile: ./cover.out local-prefix: "github.com/Optable/optable-pair-cli" - threshold-total: 90 + threshold-total: 70 - name: Cleanup if: always() run: docker stop fake-gcs-server && docker rm fake-gcs-server