diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..889b63e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,74 @@ +name: Build + +on: + push: + branches: + - develop + - master + pull_request: + +jobs: + + go-legacy-test: + runs-on: ubuntu-latest + strategy: + matrix: + go-version: [ '1.20', '1.21' ] + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go-version }} + - name: Go get + run: go get -t ./... + - name: Build + run: go build -v ./... + - name: Test + run: go test -v ./... + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22.4' + - name: Go get + run: go get -t ./... + - name: Build + run: go build -v ./... + - name: Test + run: go test -v -covermode=atomic -coverprofile=cover.out -coverpkg=. ./... + - name: Install goveralls + run: go install github.com/mattn/goveralls@latest + - name: Send coverage + env: + COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: goveralls -coverprofile=cover.out -service=github + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22.4' + - name: Install checks + run: | + go install honnef.co/go/tools/cmd/staticcheck@latest + go install github.com/client9/misspell/cmd/misspell@latest + - name: Go get + run: go get -t ./... + - name: Go vet + run: go vet $(go list ./... | grep -v /vendor/) + - name: Go mod + run: go mod tidy; git diff --exit-code go.mod go.sum + - name: Go fmt + run: go fmt $(go list ./... | grep -v /vendor/); git diff --exit-code + - name: Staticcheck + run: staticcheck -checks all,-ST1000 ./... + - name: Misspell + run: misspell -error -locale US . diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f6e813d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +name: Release + +on: + push: + tags: + - '*' + +# Make sure the GITHUB_TOKEN has permission to upload to our releases +permissions: + contents: write + +jobs: + + create_release: + name: Create Release + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + - name: Create release draft + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref_name }} + body: | + A new release + draft: true + prerelease: false diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 659ecf5..0000000 --- a/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: go -go: -- 1.16.x -- 1.15.x -- 1.14.x -install: -- go get -t ./... -- if [[ "$TRAVIS_GO_VERSION" =~ ^1\.16\. ]]; then ./scripts/install-checks.sh; fi -before_script: -- if [[ "$TRAVIS_GO_VERSION" =~ ^1\.16\. ]]; then ./scripts/check.sh; fi -- go build -- go build $(go list ./examples/...) -script: -- if [[ "$TRAVIS_GO_VERSION" =~ ^1\.16\. ]]; then ./scripts/cover.sh TRAVIS; else go test -i -race ./...; fi diff --git a/README.md b/README.md index 9314ed1..5c7e30a 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@

Resgate logo

RES Service for Go
Synchronize Your Clients

-License +License Report Card -Build Status +Build Status Coverage Reference

diff --git a/request.go b/request.go index 553ad40..d6a3c5f 100644 --- a/request.go +++ b/request.go @@ -267,7 +267,6 @@ func (r *Request) IsHTTP() bool { // See: https://resgate.io/docs/specification/res-service-protocol/#status-codes // // Only valid for auth, access, and call requests. - func (r *Request) SetResponseStatus(code int) { if !r.isHTTP { panic("call to SetResponseStatus when IsHTTP is false") diff --git a/scripts/check.sh b/scripts/check.sh index 21a04ca..3d576a6 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -9,8 +9,6 @@ fi echo "Checking with go vet..." go vet ./... echo "Checking with staticcheck..." -staticcheck ./... -echo "Checking with golint..." -golint -set_exit_status ./... +staticcheck -checks all,-ST1000 ./... echo "Checking with misspell..." misspell -error -locale US . diff --git a/scripts/cover.sh b/scripts/cover.sh index 614bced..3c65deb 100755 --- a/scripts/cover.sh +++ b/scripts/cover.sh @@ -1,12 +1,5 @@ #!/bin/bash -e # Run from directory above via ./scripts/cover.sh -go test -covermode=atomic -coverprofile=./cover.out -coverpkg=. ./... - -# If we have an arg, assume travis run and push to coveralls. Otherwise launch browser results -if [[ -n $1 ]]; then - $HOME/gopath/bin/goveralls -coverprofile=cover.out -service travis-ci - rm -rf ./cover.out -else - go tool cover -html=cover.out -fi +go test -v -covermode=atomic -coverprofile=./cover.out -coverpkg=. ./... +go tool cover -html=cover.out diff --git a/scripts/install-checks.sh b/scripts/install-checks.sh index 52b6644..7710f08 100755 --- a/scripts/install-checks.sh +++ b/scripts/install-checks.sh @@ -1,8 +1,4 @@ #!/bin/bash -e -pushd /tmp > /dev/null -go get -u github.com/mattn/goveralls -go get -u honnef.co/go/tools/cmd/staticcheck -go get -u golang.org/x/lint/golint -go get -u github.com/client9/misspell/cmd/misspell -popd > /dev/null +go install honnef.co/go/tools/cmd/staticcheck@latest +go install github.com/client9/misspell/cmd/misspell@latest diff --git a/scripts/lint.sh b/scripts/lint.sh index 06af4ba..e3e466b 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -2,6 +2,6 @@ # Run from directory above via ./scripts/lint.sh $(exit $(go fmt ./... | wc -l)) +go mod tidy go vet ./... -golint ./... misspell -error -locale US ./...