From d2da2f563ee82818e22153b1e0940e81beeaf0df Mon Sep 17 00:00:00 2001 From: Piotr Piotrowski Date: Mon, 29 Apr 2024 16:57:56 +0200 Subject: [PATCH] Add coverage report Signed-off-by: Piotr Piotrowski --- .github/workflows/ci.yaml | 16 ++++++++++++---- .github/workflows/latest-server.yaml | 28 ++++++++++++++++++++++++++++ scripts/cov.sh | 3 ++- 3 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/latest-server.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4e01af948..4a375645b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,7 +11,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: 1.22 + go-version: 'stable' - name: Install deps shell: bash --noprofile --norc -x -eo pipefail {0} @@ -44,6 +44,7 @@ jobs: uses: actions/setup-go@v5 with: go-version: ${{ matrix.go }} + - name: Install deps shell: bash --noprofile --norc -x -eo pipefail {0} run: | @@ -51,10 +52,17 @@ jobs: go install github.com/wadey/gocovmerge@latest - name: Test and coverage + shell: bash --noprofile --norc -x -eo pipefail {0} run: | go test -modfile=go_test.mod -v -run=TestNoRace -p=1 ./... --failfast -vet=off - if [ "${{ matrix.go }}" = "1.21" ]; then + if [ "${{ matrix.go }}" = "1.22" ]; then ./scripts/cov.sh CI - elif [ "${{ matrix.go }}" = "1.22" ]; then + else go test -modfile=go_test.mod -race -v -p=1 ./... --failfast -vet=off -tags=internal_testing - fi \ No newline at end of file + fi + + - name: Coveralls + if: matrix.go == '1.22' + uses: coverallsapp/github-action@v2 + with: + file: acc.out \ No newline at end of file diff --git a/.github/workflows/latest-server.yaml b/.github/workflows/latest-server.yaml new file mode 100644 index 000000000..b65c91eea --- /dev/null +++ b/.github/workflows/latest-server.yaml @@ -0,0 +1,28 @@ +name: Test nats-server@main +on: + pull_request: + schedule: + - cron: "30 8 * * *" + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: 'stable' + + - name: Get latest server + shell: bash --noprofile --norc -x -eo pipefail {0} + run: | + go get -modfile go_test.mod github.com/nats-io/nats-server/v2@main + + - name: Test + shell: bash --noprofile --norc -x -eo pipefail {0} + run: | + go test -modfile=go_test.mod -v -run=TestNoRace -p=1 ./... --failfast -vet=off + go test -modfile=go_test.mod -race -v -p=1 ./... --failfast -vet=off -tags=internal_testing \ No newline at end of file diff --git a/scripts/cov.sh b/scripts/cov.sh index 5d3dcb908..fa0fdc19d 100755 --- a/scripts/cov.sh +++ b/scripts/cov.sh @@ -5,7 +5,8 @@ rm -rf ./cov mkdir cov go test -modfile=go_test.mod --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/nats.out . -tags=skip_no_race_tests go test -modfile=go_test.mod --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/test.out -coverpkg=github.com/nats-io/nats.go ./test -tags=skip_no_race_tests,internal_testing -go test -modfile=go_test.mod --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/jetstream.out -coverpkg=github.com/nats-io/nats.go/jetstream ./jetstream/test -tags=skip_no_race_tests +go test -modfile=go_test.mod --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/jetstream.out -coverpkg=github.com/nats-io/nats.go/jetstream ./jetstream/... +go test -modfile=go_test.mod --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/service.out -coverpkg=github.com/nats-io/nats.go/micro ./micro/... go test -modfile=go_test.mod --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/builtin.out -coverpkg=github.com/nats-io/nats.go/encoders/builtin ./test -run EncBuiltin -tags=skip_no_race_tests go test -modfile=go_test.mod --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/protobuf.out -coverpkg=github.com/nats-io/nats.go/encoders/protobuf ./test -run EncProto -tags=skip_no_race_tests gocovmerge ./cov/*.out > acc.out