Skip to content

Commit

Permalink
Modify CI to use the new modules
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr Piotrowski <[email protected]>
  • Loading branch information
piotrpio committed Jan 24, 2025
1 parent 29320cc commit 3428b6e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 110 deletions.
24 changes: 18 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,20 @@ jobs:
- name: Run linters
shell: bash --noprofile --norc -x -eo pipefail {0}
run: |
$(exit $(go fmt -modfile=go_test.mod ./... | wc -l))
go vet -modfile=go_test.mod ./...
GOFLAGS="-mod=mod -modfile=go_test.mod" staticcheck ./...
MODULE_DIRS=(
"."
"test"
"jetstream/test"
"micro/test"
)
for modDir in "${MODULE_DIRS[@]}"; do
$(exit $(cd "$modDir" && go fmt ./... | wc -l))
done
$(exit $(go fmt ./... | wc -l))
go vet ./... ./test/... ./jetstream/test/... ./micro/test/...
staticcheck ./... ./test/... ./jetstream/test/... ./micro/test/...
find . -type f -name "*.go" | xargs misspell -error -locale US
golangci-lint run --timeout 5m0s ./jetstream/...
golangci-lint run --timeout 5m0s ./jetstream/... ./jetstream/test/...
test:
runs-on: ubuntu-latest
Expand All @@ -60,11 +69,14 @@ jobs:
- 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
go test -v -run=TestNoRace -p=1 ./test/... --failfast -vet=off
if [ "${{ matrix.go }}" = "1.23" ]; then
./scripts/cov.sh CI
else
go test -modfile=go_test.mod -race -v -p=1 ./... --failfast -vet=off -tags=internal_testing
go test -race -v -p=1 ./... --failfast -vet=off -tags=internal_testing
go test -race -v -p=1 ./test/... --failfast -vet=off
go test -race -v -p=1 ./jetstream/test/... --failfast -vet=off
go test -race -v -p=1 ./micro/test/... --failfast -vet=off
fi
- name: Coveralls
Expand Down
15 changes: 3 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,6 @@ send your question to the [NATS Google Group](https://groups.google.com/forum/#!

## Testing

You should use `go_test.mod` to manage your testing dependencies. Please use the following command to update your
dependencies and avoid changing the main `go.mod` in a PR:

```shell
go mod tidy -modfile=go_test.mod
```

To the tests you can pass `-modfile=go_test.mod` flag to `go test` or instead you can also set `GOFLAGS="-modfile=go_test.mod"` as an environment variable:

```shell
go test ./... -modfile=go_test.mod
```
All tests utilizing `nats-server` should be placed in the appropriate package's
`test` directory. This is to ensure that the test dependencies are isolated from
the main package dependencies as each test package is its own module.
23 changes: 0 additions & 23 deletions go_test.mod

This file was deleted.

60 changes: 0 additions & 60 deletions go_test.sum

This file was deleted.

15 changes: 9 additions & 6 deletions scripts/cov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@

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/...
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
go test --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/nats.out . -tags=skip_no_race_tests
go test --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 --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/jetstream.out -coverpkg=github.com/nats-io/nats.go/jetstream ./jetstream/...
go test --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/jetstream_test.out -coverpkg=github.com/nats-io/nats.go/jetstream ./jetstream/test/...
go test --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/service.out -coverpkg=github.com/nats-io/nats.go/micro ./micro/...
go test --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/service_test.out -coverpkg=github.com/nats-io/nats.go/micro ./micro/test/...
go test --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 --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
go test --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/internal.out -coverpkg=github.com/nats-io/nats.go/internal/... ./internal/...
gocovmerge ./cov/*.out > acc.out
rm -rf ./cov

Expand Down
6 changes: 3 additions & 3 deletions test/configs/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM golang:1.22
WORKDIR /usr/src/nats.go
COPY . /usr/src/nats.go
RUN go mod tidy -modfile go_test.mod
RUN go test -run TestNone -modfile go_test.mod -tags compat ./test/...
RUN go mod tidy
RUN go test -run TestNone -tags compat ./test/...
ENV NATS_URL=localhost:4222
ENTRYPOINT ["go", "test", "-v", "-modfile", "go_test.mod", "-tags", "compat", "./test/...", "-count", "1", "-parallel", "10", "-run"]
ENTRYPOINT ["go", "test", "-v", "-tags", "compat", "./test/...", "-count", "1", "-parallel", "10", "-run"]

0 comments on commit 3428b6e

Please sign in to comment.