Skip to content

Switch to coveralls.io from codecov.io #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
name: ci
on: [push]
on: [push, pull_request]

jobs:
fmt:
runs-on: ubuntu-latest
container: nhooyr/websocket-ci@sha256:ea94e078d2d589d654a2c759d952bf4199c754d80dadb20696dc3902359027cb
container: nhooyr/websocket-ci@sha256:8a8fd73fdea33585d50a33619c4936adfd016246a2ed6bbfbf06def24b518a6a
steps:
- uses: actions/checkout@v1
- run: make fmt
lint:
runs-on: ubuntu-latest
container: nhooyr/websocket-ci@sha256:ea94e078d2d589d654a2c759d952bf4199c754d80dadb20696dc3902359027cb
container: nhooyr/websocket-ci@sha256:8a8fd73fdea33585d50a33619c4936adfd016246a2ed6bbfbf06def24b518a6a
steps:
- uses: actions/checkout@v1
- run: make lint
test:
runs-on: ubuntu-latest
container: nhooyr/websocket-ci@sha256:ea94e078d2d589d654a2c759d952bf4199c754d80dadb20696dc3902359027cb
container: nhooyr/websocket-ci@sha256:8a8fd73fdea33585d50a33619c4936adfd016246a2ed6bbfbf06def24b518a6a
steps:
- uses: actions/checkout@v1
- run: make test
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
COVERALLS_TOKEN: ${{ secrets.github_token }}
- name: Upload coverage.html
uses: actions/upload-artifact@master
with:
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ all: fmt lint test

.PHONY: *

.ONESHELL:
SHELL = bash
.SHELLFLAGS = -ceuo pipefail

include ci/fmt.mk
include ci/lint.mk
include ci/test.mk

ci-image:
docker build -f ./ci/image/Dockerfile -t nhooyr/websocket-ci .
docker build -f ./ci/Dockerfile -t nhooyr/websocket-ci .
docker push nhooyr/websocket-ci
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# websocket

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

websocket is a minimal and idiomatic WebSocket library for Go.
Expand Down
10 changes: 0 additions & 10 deletions ci/.codecov.yml

This file was deleted.

7 changes: 2 additions & 5 deletions ci/image/Dockerfile → ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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
RUN apt-get install -y jq

ENV GOPATH=/root/gopath
ENV PATH=$GOPATH/bin:$PATH
Expand All @@ -12,15 +12,12 @@ ENV PAGER=cat
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
Expand Down
17 changes: 10 additions & 7 deletions ci/fmt.mk
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 ./...
11 changes: 0 additions & 11 deletions ci/fmtcheck.sh

This file was deleted.

5 changes: 0 additions & 5 deletions ci/image/gitignore

This file was deleted.

5 changes: 1 addition & 4 deletions ci/lint.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
lint: govet golint govet-wasm golint-wasm shellcheck
lint: govet golint govet-wasm golint-wasm

govet:
go vet ./...
Expand All @@ -11,6 +11,3 @@ golint:

golint-wasm:
GOOS=js GOARCH=wasm golint -set_exit_status ./...

shellcheck:
shellcheck -x $$(git ls-files "*.sh")
25 changes: 15 additions & 10 deletions ci/test.mk
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
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

_gotest:
go test -parallel=32 -coverprofile=ci/out/coverage.prof -coverpkg=./... $$TESTFLAGS ./...
coveralls: gotest
# https://github.com/coverallsapp/github-action/blob/master/src/run.ts
echo "--- coveralls"
export GIT_BRANCH="$$GITHUB_REF"
export BUILD_NUMBER="$$GITHUB_SHA"
if [[ $$GITHUB_EVENT_NAME == pull_request ]]; then
export CI_PULL_REQUEST="$$(jq .number "$$GITHUB_EVENT_PATH")"
BUILD_NUMBER="$$BUILD_NUMBER-PR-$$CI_PULL_REQUEST"
fi
goveralls -coverprofile=ci/out/coverage.prof -service=github
gotest:
go test -covermode=count -coverprofile=ci/out/coverage.prof -coverpkg=./... $${GOTESTFLAGS-} ./...
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
Expand Down
9 changes: 1 addition & 8 deletions conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1023,14 +1023,7 @@ func TestAutobahn(t *testing.T) {
t.Run(name, func(t *testing.T) {
t.Parallel()

t.Run("server", func(t *testing.T) {
t.Parallel()
run2(t, false)
})
t.Run("client", func(t *testing.T) {
t.Parallel()
run2(t, true)
})
run2(t, true)
})
}

Expand Down