forked from nats-io/nats-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Remove code coverage from Travis and add it to a GitHub Action that will be run as a nightly. - Use tag builds to exclude some tests, such as the "norace" or JS tests. Since "go test" does not support "negative" regexs, there is no other way. Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
- Loading branch information
Showing
14 changed files
with
3,457 additions
and
3,271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: NATS Server Code Coverage | ||
on: | ||
workflow_dispatch: {} | ||
|
||
schedule: | ||
- cron: "40 4 * * *" | ||
|
||
jobs: | ||
nightly_coverage: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
GOPATH: /home/runner/work/nats-server | ||
GO111MODULE: "on" | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v1 | ||
with: | ||
path: src/github.com/nats-io/nats-server | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17.x | ||
|
||
- name: Run code coverage | ||
shell: bash --noprofile --norc -x -eo pipefail {0} | ||
# Do not make the build fail even if code coverage reported | ||
# a test failure. | ||
run: | | ||
./scripts/cov.sh upload | ||
- name: Convert coverage.out to coverage.lcov | ||
uses: jandelgado/gcov2lcov-action@v1.0.8 | ||
with: | ||
infile: acc.out | ||
|
||
- name: Coveralls | ||
uses: coverallsapp/github-action@1.1.3 | ||
with: | ||
github-token: ${{ secrets.github_token }} | ||
path-to-lcov: coverage.lcov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
if [ "$1" = "compile" ]; then | ||
|
||
# We will compile and run some vet, spelling and some other checks. | ||
|
||
go install honnef.co/go/tools/cmd/staticcheck@v0.2.2; | ||
go install github.com/client9/misspell/cmd/misspell@latest; | ||
GO_LIST=$(go list ./...); | ||
go build; | ||
$(exit $(go fmt $GO_LIST | wc -l)); | ||
go vet $GO_LIST; | ||
find . -type f -name "*.go" | xargs misspell -error -locale US; | ||
staticcheck $GO_LIST | ||
if [ "$TRAVIS_TAG" != "" ]; then | ||
go test -race -v -run=TestVersionMatchesTag ./server -count=1 -vet=off | ||
fi | ||
|
||
elif [ "$1" = "no_race_tests" ]; then | ||
|
||
# Run tests without the `-race` flag. By convention, those tests start | ||
# with `TestNoRace`. | ||
|
||
go test -v -p=1 -run=TestNoRace ./... -count=1 -vet=off -timeout=30m -failfast | ||
|
||
elif [ "$1" = "js_tests" ]; then | ||
|
||
# Run JetStream non-clustere tests. By convention, all JS tests start | ||
# with `TestJetStream`. We exclude the clustered tests by using the | ||
# `skip_js_cluster_tests` build tag. | ||
|
||
go test -race -v -run=TestJetStream ./server -tags=skip_js_cluster_tests -count=1 -vet=off -timeout=30m -failfast | ||
|
||
elif [ "$1" = "js_cluster_tests" ]; then | ||
|
||
# Run JetStream clustered tests. By convention, all JS clustered tests | ||
# start with `TestJetStreamCluster`. | ||
|
||
go test -race -v -run=TestJetStreamCluster ./server -count=1 -vet=off -timeout=30m -failfast | ||
|
||
elif [ "$1" = "srv_pkg_non_js_tests" ]; then | ||
|
||
# Run all non JetStream tests in the server package. We exclude the | ||
# JS tests by using the `skip_js_tests` build tag. | ||
|
||
go test -race -v -p=1 ./server/... -tags=skip_js_tests -count=1 -vet=off -timeout=30m -failfast | ||
|
||
elif [ "$1" = "non_srv_pkg_tests" ]; then | ||
|
||
# Run all tests of all non server package. | ||
|
||
go test -race -v -p=1 $(go list ./... | grep -v "/server") -count=1 -vet=off -timeout=30m -failfast | ||
|
||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
#!/bin/bash -e | ||
#!/bin/bash | ||
# Run from directory above via ./scripts/cov.sh | ||
|
||
# Do not set the -e flag because we don't a flapper to prevent the push to coverall. | ||
|
||
export GO111MODULE="on" | ||
|
||
go get github.com/mattn/goveralls | ||
go get github.com/wadey/gocovmerge | ||
go install github.com/wadey/gocovmerge@latest | ||
|
||
rm -rf ./cov | ||
mkdir cov | ||
go test -v -failfast -covermode=atomic -coverprofile=./cov/conf.out -run='Test[^NoRace]' ./conf -timeout=20m | ||
go test -v -failfast -covermode=atomic -coverprofile=./cov/log.out -run='Test[^NoRace]' ./logger -timeout=20m | ||
go test -v -failfast -covermode=atomic -coverprofile=./cov/server.out -run='Test[^NoRace]' ./server -timeout=20m | ||
go test -v -failfast -covermode=atomic -coverprofile=./cov/test.out -coverpkg=./server -run='Test[^NoRace]' ./test -timeout=20m | ||
# Since it is difficult to get a full run without a flapper, do not use `-failfast`. | ||
# It is better to have one flapper or two and still get the report than have | ||
# to re-run the whole code coverage. One or two failed tests should not affect | ||
# so much the code coverage. | ||
go test -v -covermode=atomic -coverprofile=./cov/conf.out ./conf -timeout=20m -tags=skip_no_race_tests | ||
go test -v -covermode=atomic -coverprofile=./cov/log.out ./logger -timeout=20m -tags=skip_no_race_tests | ||
go test -v -covermode=atomic -coverprofile=./cov/server.out ./server -timeout=20m -tags=skip_no_race_tests | ||
go test -v -covermode=atomic -coverprofile=./cov/test.out -coverpkg=./server ./test -timeout=20m -tags=skip_no_race_tests | ||
gocovmerge ./cov/*.out > acc.out | ||
rm -rf ./cov | ||
|
||
# Without argument, launch browser results. We are going to push to coveralls only | ||
# from Travis.yml and after success of the build (and result of pushing will not affect | ||
# build result). | ||
# If no argument passed, launch a browser to see the results. | ||
if [[ $1 == "" ]]; then | ||
go tool cover -html=acc.out | ||
fi |
Oops, something went wrong.