Skip to content

Commit

Permalink
Add code coverage tests to the Github Actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
khaf committed May 14, 2024
1 parent 575d8ff commit d772f13
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 5 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,16 @@ jobs:
run: cd tools/cli | go build -o cli .
- name: Build example files
run: find examples -name "*.go" -type f -print0 | xargs -0 -n1 go build
# - name: Build with Reflection code removed
# run: go run github.com/onsi/ginkgo/v2/ginkgo build -tags="as_performance" .
# - name: Build for Google App Engine (unsafe package removed)
# run: go run github.com/onsi/ginkgo/v2/ginkgo -tags="app_engine" .
- name: Build with Reflection code removed
run: go run github.com/onsi/ginkgo/v2/ginkgo build -tags="as_performance" .
- name: Build for Google App Engine (unsafe package removed)
run: go run github.com/onsi/ginkgo/v2/ginkgo build -tags="app_engine" .
- name: Run the tests
run: go run github.com/onsi/ginkgo/v2/ginkgo -cover -race -keep-going -succinct -randomize-suites -skip="HyperLogLog"
run: go run github.com/onsi/ginkgo/v2/ginkgo -coverprofile=./cover_native.out -covermode=atomic -coverpkg=./... -race -keep-going -succinct -randomize-suites -skip="HyperLogLog"
- name: Combine Cover Profiles
run: go run github.com/wadey/gocovmerge cover_*.out > cover_all.out
- name: Check Code Coverage
uses: vladopajic/go-test-coverage@v2
with:
# Configure action using config file (option 1)
config: ./.testcoverage.yml
69 changes: 69 additions & 0 deletions .testcoverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# (mandatory)
# Path to coverprofile 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_all.out

# (optional; but recommended to set)
# When specified reported file paths will not contain local prefix in the output
local-prefix: "github.com/aerospike/aerospike-client-go/v7"

# Holds coverage thresholds percentages, values should be in range [0-100]
threshold:
# (optional; default 0)
# The minimum coverage that each file should have
file: 0

# (optional; default 0)
# The minimum coverage that each package should have
package: 10

# (optional; default 0)
# The minimum total coverage project should have
total: 10

# 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)
#- threshold: 100
# path: ^pkg/lib/foo$

# 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
- proto/*
- ^pkg/* # exclude package `pkg/bar`
- client_builder.go
- info_policy.go
- commit_policy.go
- generation_policy.go
- privilege.go
- read_mode_ap.go
- read_mode_sc.go
- record_exists_action.go
- replica_policy.go
- generics.go
- proxy_auth_interceptor.go
- proxy_client.go
- proxy_client_reflect.go
- proxy_query_partition_command.go
- proxy_scan_command.go
- login_command.go
- types/histogram/histogram.go
- types/rand/xor_shift128.go
- internal/atomic/array.go
# NOTES:
# - symbol `/` in all path regexps will be replaced by current OS file path separator
# to properly work on Windows
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/wadey/gocovmerge v0.0.0-20160331181800-b5bfa59ec0ad // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/wadey/gocovmerge v0.0.0-20160331181800-b5bfa59ec0ad h1:W0LEBv82YCGEtcmPA3uNZBI33/qF//HAAs3MawDjRa0=
github.com/wadey/gocovmerge v0.0.0-20160331181800-b5bfa59ec0ad/go.mod h1:Hy8o65+MXnS6EwGElrSRjUzQDLXreJlzYLlWiHtt8hM=
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
Expand Down

0 comments on commit d772f13

Please sign in to comment.