mirror of
https://github.com/nats-io/nats.go.git
synced 2025-09-26 20:41:41 +08:00
[IMPROVED] Move CI to github actions (#1623)
Signed-off-by: Piotr Piotrowski <piotr@synadia.com>
This commit is contained in:
68
.github/workflows/ci.yaml
vendored
Normal file
68
.github/workflows/ci.yaml
vendored
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
name: Testing
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
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: Install deps
|
||||||
|
shell: bash --noprofile --norc -x -eo pipefail {0}
|
||||||
|
run: |
|
||||||
|
go get -t ./...
|
||||||
|
go install honnef.co/go/tools/cmd/staticcheck@latest
|
||||||
|
go install github.com/client9/misspell/cmd/misspell@latest
|
||||||
|
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
||||||
|
|
||||||
|
- 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 ./...
|
||||||
|
find . -type f -name "*.go" | xargs misspell -error -locale US
|
||||||
|
golangci-lint run --timeout 5m0s ./jetstream/...
|
||||||
|
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
go: [ "1.21", "1.22" ]
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
|
- name: Install deps
|
||||||
|
shell: bash --noprofile --norc -x -eo pipefail {0}
|
||||||
|
run: |
|
||||||
|
go install github.com/mattn/goveralls@latest
|
||||||
|
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.22" ]; then
|
||||||
|
./scripts/cov.sh CI
|
||||||
|
else
|
||||||
|
go test -modfile=go_test.mod -race -v -p=1 ./... --failfast -vet=off -tags=internal_testing
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Coveralls
|
||||||
|
if: matrix.go == '1.22'
|
||||||
|
uses: coverallsapp/github-action@v2
|
||||||
|
with:
|
||||||
|
file: acc.out
|
27
.github/workflows/latest-server.yaml
vendored
Normal file
27
.github/workflows/latest-server.yaml
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
name: Test nats-server@main
|
||||||
|
on:
|
||||||
|
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
|
@@ -33,4 +33,4 @@ jobs:
|
|||||||
before_script:
|
before_script:
|
||||||
- go get -modfile go_test.mod github.com/nats-io/nats-server/v2@main
|
- go get -modfile go_test.mod github.com/nats-io/nats-server/v2@main
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- name: "Go: 1.22.x (nats-server@main)"
|
- name: "Go: 1.22.x (nats-server@main)"
|
@@ -94,10 +94,11 @@ func checkErrChannel(t *testing.T, errCh chan error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestVersionMatchesTag(t *testing.T) {
|
func TestVersionMatchesTag(t *testing.T) {
|
||||||
tag := os.Getenv("TRAVIS_TAG")
|
refType := os.Getenv("GITHUB_REF_TYPE")
|
||||||
if tag == "" {
|
if refType != "tag" {
|
||||||
t.SkipNow()
|
t.SkipNow()
|
||||||
}
|
}
|
||||||
|
tag := os.Getenv("GITHUB_REF_NAME")
|
||||||
// We expect a tag of the form vX.Y.Z. If that's not the case,
|
// We expect a tag of the form vX.Y.Z. If that's not the case,
|
||||||
// we need someone to have a look. So fail if first letter is not
|
// we need someone to have a look. So fail if first letter is not
|
||||||
// a `v`
|
// a `v`
|
||||||
|
@@ -5,14 +5,15 @@ rm -rf ./cov
|
|||||||
mkdir 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/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/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/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 -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
|
gocovmerge ./cov/*.out > acc.out
|
||||||
rm -rf ./cov
|
rm -rf ./cov
|
||||||
|
|
||||||
# Without argument, launch browser results. We are going to push to coveralls only
|
# 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
|
# from ci.yml and after success of the build (and result of pushing will not affect
|
||||||
# build result).
|
# build result).
|
||||||
if [[ $1 == "" ]]; then
|
if [[ $1 == "" ]]; then
|
||||||
go tool cover -html=acc.out
|
go tool cover -html=acc.out
|
||||||
|
Reference in New Issue
Block a user