Skip to content

Commit cb0c4ac

Browse files
authored
Merge pull request #162 from nhooyr/coveralls
Switch to coveralls.io from codecov.io
2 parents 0d98321 + 9b9d7b4 commit cb0c4ac

File tree

12 files changed

+43
-73
lines changed

12 files changed

+43
-73
lines changed

.github/CONTRIBUTING.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ CI must pass on your changes for them to be merged.
2828
### CI
2929

3030
CI will ensure your code is formatted, lints and passes tests.
31-
It will collect coverage and report it to [codecov](https://codecov.io/gh/nhooyr/websocket)
31+
It will collect coverage and report it to [coveralls](https://coveralls.io/github/nhooyr/websocket)
3232
and also upload a html `coverage` artifact that you can download to browse coverage.
3333

3434
You can run CI locally.
@@ -42,7 +42,4 @@ See [ci/image/Dockerfile](../ci/image/Dockerfile) for the installation of the CI
4242

4343
For coverage details locally, see `ci/out/coverage.html` after running `make test`.
4444

45-
You can also run tests normally with `go test`. `make test` just passes a default set of flags to
46-
`go test` to collect coverage and runs the WASM tests.
47-
48-
Coverage percentage from codecov and the CI scripts will be different because they are calculated differently.
45+
You can run tests normally with `go test`. `make test` wraps around `go test` to collect coverage.

.github/workflows/ci.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
name: ci
2-
on: [push]
2+
on: [push, pull_request]
33

44
jobs:
55
fmt:
66
runs-on: ubuntu-latest
7-
container: nhooyr/websocket-ci@sha256:ea94e078d2d589d654a2c759d952bf4199c754d80dadb20696dc3902359027cb
7+
container: nhooyr/websocket-ci@sha256:8a8fd73fdea33585d50a33619c4936adfd016246a2ed6bbfbf06def24b518a6a
88
steps:
99
- uses: actions/checkout@v1
1010
- run: make fmt
1111
lint:
1212
runs-on: ubuntu-latest
13-
container: nhooyr/websocket-ci@sha256:ea94e078d2d589d654a2c759d952bf4199c754d80dadb20696dc3902359027cb
13+
container: nhooyr/websocket-ci@sha256:8a8fd73fdea33585d50a33619c4936adfd016246a2ed6bbfbf06def24b518a6a
1414
steps:
1515
- uses: actions/checkout@v1
1616
- run: make lint
1717
test:
1818
runs-on: ubuntu-latest
19-
container: nhooyr/websocket-ci@sha256:ea94e078d2d589d654a2c759d952bf4199c754d80dadb20696dc3902359027cb
19+
container: nhooyr/websocket-ci@sha256:8a8fd73fdea33585d50a33619c4936adfd016246a2ed6bbfbf06def24b518a6a
2020
steps:
2121
- uses: actions/checkout@v1
2222
- run: make test
2323
env:
24-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
24+
COVERALLS_TOKEN: ${{ secrets.github_token }}
2525
- name: Upload coverage.html
2626
uses: actions/upload-artifact@master
2727
with:

Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ all: fmt lint test
44

55
.PHONY: *
66

7+
.ONESHELL:
8+
SHELL = bash
9+
.SHELLFLAGS = -ceuo pipefail
10+
711
include ci/fmt.mk
812
include ci/lint.mk
913
include ci/test.mk
1014

1115
ci-image:
12-
docker build -f ./ci/image/Dockerfile -t nhooyr/websocket-ci .
16+
docker build -f ./ci/Dockerfile -t nhooyr/websocket-ci .
1317
docker push nhooyr/websocket-ci

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# websocket
22

3-
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/nhooyr/websocket?color=6b9ded&sort=semver)](https://github.com/nhooyr/websocket/releases)
3+
[![GitHub Release](https://img.shields.io/github/v/release/nhooyr/websocket?color=6b9ded&sort=semver)](https://github.com/nhooyr/websocket/releases)
44
[![GoDoc](https://godoc.org/nhooyr.io/websocket?status.svg)](https://godoc.org/nhooyr.io/websocket)
5-
[![Codecov](https://img.shields.io/codecov/c/github/nhooyr/websocket.svg?color=65d6a4)](https://codecov.io/gh/nhooyr/websocket)
5+
[![Coveralls](https://img.shields.io/coveralls/github/nhooyr/websocket?color=65d6a4)](https://coveralls.io/github/nhooyr/websocket)
66
[![Actions Status](https://github.com/nhooyr/websocket/workflows/ci/badge.svg)](https://github.com/nhooyr/websocket/actions)
77

88
websocket is a minimal and idiomatic WebSocket library for Go.

ci/.codecov.yml

-10
This file was deleted.

ci/image/Dockerfile renamed to ci/Dockerfile

+2-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM golang:1
33
RUN apt-get update
44
RUN apt-get install -y chromium
55
RUN apt-get install -y npm
6-
RUN apt-get install -y shellcheck
6+
RUN apt-get install -y jq
77

88
ENV GOPATH=/root/gopath
99
ENV PATH=$GOPATH/bin:$PATH
@@ -12,15 +12,12 @@ ENV PAGER=cat
1212
ENV CI=true
1313
ENV MAKEFLAGS="--jobs=8 --output-sync=target"
1414

15-
COPY ./ci/image/gitignore /root/.config/git/ignore
16-
RUN git config --system color.ui always
17-
1815
RUN npm install -g prettier
1916
RUN go get golang.org/x/tools/cmd/stringer
2017
RUN go get golang.org/x/tools/cmd/goimports
21-
RUN go get mvdan.cc/sh/cmd/shfmt
2218
RUN go get golang.org/x/lint/golint
2319
RUN go get github.com/agnivade/wasmbrowsertest
20+
RUN go get github.com/mattn/goveralls
2421

2522
# Cache go modules and build cache.
2623
COPY . /tmp/websocket

ci/fmt.mk

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
fmt: modtidy gofmt goimports prettier shfmt
1+
fmt: modtidy gofmt goimports prettier
22
ifdef CI
3-
./ci/fmtcheck.sh
3+
if [[ $$(git ls-files --other --modified --exclude-standard) != "" ]]; then
4+
echo "Files need generation or are formatted incorrectly:"
5+
git -c color.ui=always status | grep --color=no '\e\[31m'
6+
echo "Please run the following locally:"
7+
echo " make fmt"
8+
exit 1
9+
fi
410
endif
511

612
modtidy: gen
@@ -12,11 +18,8 @@ gofmt: gen
1218
goimports: gen
1319
goimports -w "-local=$$(go list -m)" .
1420

15-
prettier: gen
16-
prettier --write --print-width=120 --no-semi --trailing-comma=all --loglevel=warn $$(git ls-files "*.yaml" "*.yml" "*.md" "*.ts")
17-
18-
shfmt: gen
19-
shfmt -i 2 -w -s -sr .
21+
prettier:
22+
prettier --write --print-width=120 --no-semi --trailing-comma=all --loglevel=warn $$(git ls-files "*.yml" "*.md")
2023

2124
gen:
2225
go generate ./...

ci/fmtcheck.sh

-11
This file was deleted.

ci/image/gitignore

-5
This file was deleted.

ci/lint.mk

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
lint: govet golint govet-wasm golint-wasm shellcheck
1+
lint: govet golint govet-wasm golint-wasm
22

33
govet:
44
go vet ./...
@@ -11,6 +11,3 @@ golint:
1111

1212
golint-wasm:
1313
GOOS=js GOARCH=wasm golint -set_exit_status ./...
14-
15-
shellcheck:
16-
shellcheck -x $$(git ls-files "*.sh")

ci/test.mk

+15-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
test: gotest
2-
3-
gotest: _gotest htmlcov
1+
test: gotest ci/out/coverage.html
42
ifdef CI
5-
gotest: codecov
3+
test: coveralls
64
endif
75

8-
htmlcov: _gotest
6+
ci/out/coverage.html: gotest
97
go tool cover -html=ci/out/coverage.prof -o=ci/out/coverage.html
108

11-
codecov: _gotest
12-
curl -s https://codecov.io/bash | bash -s -- -Z -f ci/out/coverage.prof
13-
14-
_gotest:
15-
go test -parallel=32 -coverprofile=ci/out/coverage.prof -coverpkg=./... $$TESTFLAGS ./...
9+
coveralls: gotest
10+
# https://github.com/coverallsapp/github-action/blob/master/src/run.ts
11+
echo "--- coveralls"
12+
export GIT_BRANCH="$$GITHUB_REF"
13+
export BUILD_NUMBER="$$GITHUB_SHA"
14+
if [[ $$GITHUB_EVENT_NAME == pull_request ]]; then
15+
export CI_PULL_REQUEST="$$(jq .number "$$GITHUB_EVENT_PATH")"
16+
BUILD_NUMBER="$$BUILD_NUMBER-PR-$$CI_PULL_REQUEST"
17+
fi
18+
goveralls -coverprofile=ci/out/coverage.prof -service=github
19+
gotest:
20+
go test -covermode=count -coverprofile=ci/out/coverage.prof -coverpkg=./... $${GOTESTFLAGS-} ./...
1621
sed -i '/_stringer\.go/d' ci/out/coverage.prof
1722
sed -i '/wsecho\.go/d' ci/out/coverage.prof
1823
sed -i '/assert\.go/d' ci/out/coverage.prof

conn_test.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -1023,14 +1023,7 @@ func TestAutobahn(t *testing.T) {
10231023
t.Run(name, func(t *testing.T) {
10241024
t.Parallel()
10251025

1026-
t.Run("server", func(t *testing.T) {
1027-
t.Parallel()
1028-
run2(t, false)
1029-
})
1030-
t.Run("client", func(t *testing.T) {
1031-
t.Parallel()
1032-
run2(t, true)
1033-
})
1026+
run2(t, true)
10341027
})
10351028
}
10361029

0 commit comments

Comments
 (0)