diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index cd6af4f1ff63da40d06395d80e9a7970edad256f..357c314adb7a3dfb511ab87f4dfb19d7cb92996e 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -28,7 +28,7 @@ CI must pass on your changes for them to be merged. ### CI CI will ensure your code is formatted, lints and passes tests. -It will collect coverage and report it to [codecov](https://codecov.io/gh/nhooyr/websocket) +It will collect coverage and report it to [coveralls](https://coveralls.io/github/nhooyr/websocket) and also upload a html `coverage` artifact that you can download to browse coverage. You can run CI locally. @@ -42,7 +42,4 @@ See [ci/image/Dockerfile](../ci/image/Dockerfile) for the installation of the CI For coverage details locally, see `ci/out/coverage.html` after running `make test`. -You can also run tests normally with `go test`. `make test` just passes a default set of flags to -`go test` to collect coverage and runs the WASM tests. - -Coverage percentage from codecov and the CI scripts will be different because they are calculated differently. +You can run tests normally with `go test`. `make test` wraps around `go test` to collect coverage. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37282e1bf14f7be539c422b1029864f21a071219..d13e90285dfe5d40d639b2a1699ac5e3eced8c48 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@v1 - run: make test env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }} - name: Upload coverage.html uses: actions/upload-artifact@master with: diff --git a/Makefile b/Makefile index ce92ab5ba82b546c53e7aa13d91296cd11d50bcc..62633e3938ef727f01e987a5979a9260b22cdccf 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,10 @@ all: fmt lint test .PHONY: * +.ONESHELL: +SHELL = bash +.SHELLFLAGS = -ceuo pipefail + include ci/fmt.mk include ci/lint.mk include ci/test.mk diff --git a/README.md b/README.md index 9dd5d0a8a23e2b23fc6cc1b621f6dc46b88aaca0..4a425a1658711cfa4654477a7f43e4bab80df517 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # websocket -[](https://github.com/nhooyr/websocket/releases) +[](https://github.com/nhooyr/websocket/releases) [](https://godoc.org/nhooyr.io/websocket) -[](https://codecov.io/gh/nhooyr/websocket) +[](https://coveralls.io/github/nhooyr/websocket) [](https://github.com/nhooyr/websocket/actions) websocket is a minimal and idiomatic WebSocket library for Go. diff --git a/ci/.codecov.yml b/ci/.codecov.yml deleted file mode 100644 index fa7c5f0aaf70065a23fc30c345a5c7c3ed814b80..0000000000000000000000000000000000000000 --- a/ci/.codecov.yml +++ /dev/null @@ -1,10 +0,0 @@ -comment: off -coverage: - status: - # Prevent small changes in coverage from failing CI. - project: - default: - threshold: 15% - patch: - default: - threshold: 100% diff --git a/ci/fmt.mk b/ci/fmt.mk index 16a3b24e365e2175cf97ff66c5f2bd42c90928f0..8e61bc243c608d0eea502d90861c2650d9d34223 100644 --- a/ci/fmt.mk +++ b/ci/fmt.mk @@ -1,6 +1,12 @@ -fmt: modtidy gofmt goimports prettier shfmt +fmt: modtidy gofmt goimports prettier ifdef CI - ./ci/fmtcheck.sh + if [[ $$(git ls-files --other --modified --exclude-standard) != "" ]]; then + echo "Files need generation or are formatted incorrectly:" + git -c color.ui=always status | grep --color=no '\e\[31m' + echo "Please run the following locally:" + echo " make fmt" + exit 1 + fi endif modtidy: gen @@ -12,11 +18,8 @@ gofmt: gen goimports: gen goimports -w "-local=$$(go list -m)" . -prettier: gen - prettier --write --print-width=120 --no-semi --trailing-comma=all --loglevel=warn $$(git ls-files "*.yaml" "*.yml" "*.md" "*.ts") - -shfmt: gen - shfmt -i 2 -w -s -sr . +prettier: + prettier --write --print-width=120 --no-semi --trailing-comma=all --loglevel=warn $$(git ls-files "*.yml" "*.md") gen: go generate ./... diff --git a/ci/fmtcheck.sh b/ci/fmtcheck.sh deleted file mode 100755 index 6e452a382da25ffedb6dc012214d37baa8614371..0000000000000000000000000000000000000000 --- a/ci/fmtcheck.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -if [[ $(git ls-files --other --modified --exclude-standard) != "" ]]; then - echo "Files need generation or are formatted incorrectly." - git status - echo "Please run the following locally:" - echo " make fmt" - exit 1 -fi diff --git a/ci/image/Dockerfile b/ci/image/Dockerfile index 7fd5544a0018672a6394762a03f892bad64dd461..183c9e43f851ab72d7bd82eca1d2b29401645b6b 100644 --- a/ci/image/Dockerfile +++ b/ci/image/Dockerfile @@ -3,7 +3,6 @@ FROM golang:1 RUN apt-get update RUN apt-get install -y chromium RUN apt-get install -y npm -RUN apt-get install -y shellcheck ENV GOPATH=/root/gopath ENV PATH=$GOPATH/bin:$PATH @@ -13,14 +12,13 @@ ENV CI=true ENV MAKEFLAGS="--jobs=8 --output-sync=target" COPY ./ci/image/gitignore /root/.config/git/ignore -RUN git config --system color.ui always RUN npm install -g prettier RUN go get golang.org/x/tools/cmd/stringer RUN go get golang.org/x/tools/cmd/goimports -RUN go get mvdan.cc/sh/cmd/shfmt RUN go get golang.org/x/lint/golint RUN go get github.com/agnivade/wasmbrowsertest +RUN go get github.com/mattn/goveralls # Cache go modules and build cache. COPY . /tmp/websocket diff --git a/ci/lint.mk b/ci/lint.mk index f68add4176bb4ec5db3ff4174dd1c00bae44c83d..a656ea8db7374fd4d0b178abb71f8730ab9600a0 100644 --- a/ci/lint.mk +++ b/ci/lint.mk @@ -1,4 +1,4 @@ -lint: govet golint govet-wasm golint-wasm shellcheck +lint: govet golint govet-wasm golint-wasm govet: go vet ./... @@ -11,6 +11,3 @@ golint: golint-wasm: GOOS=js GOARCH=wasm golint -set_exit_status ./... - -shellcheck: - shellcheck -x $$(git ls-files "*.sh") diff --git a/ci/test.mk b/ci/test.mk index 8d46c94a61a0022078952928e76d2022a0094f4c..cebada778e4ac37cb5ad1aa0988da77af80abeb6 100644 --- a/ci/test.mk +++ b/ci/test.mk @@ -1,18 +1,17 @@ -test: gotest - -gotest: _gotest htmlcov +test: gotest ci/out/coverage.html ifdef CI -gotest: codecov +test: coveralls endif -htmlcov: _gotest +ci/out/coverage.html: gotest go tool cover -html=ci/out/coverage.prof -o=ci/out/coverage.html -codecov: _gotest - curl -s https://codecov.io/bash | bash -s -- -Z -f ci/out/coverage.prof +coveralls: gotest + echo "--- coveralls" + goveralls -coverprofile=ci/out/coverage.prof -service=github-actions -_gotest: - go test -parallel=32 -coverprofile=ci/out/coverage.prof -coverpkg=./... $$TESTFLAGS ./... +gotest: + go test -parallel=32 -covermode=count -coverprofile=ci/out/coverage.prof -coverpkg=./... $${TESTFLAGS-} ./... sed -i '/_stringer\.go/d' ci/out/coverage.prof sed -i '/wsecho\.go/d' ci/out/coverage.prof sed -i '/assert\.go/d' ci/out/coverage.prof