Skip to content

Back to GH Actions #237

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 1 commit into from
May 10, 2020
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
39 changes: 39 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: ci

on: [push, pull_request]

jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Run ./ci/fmt.sh
uses: ./ci/container
with:
args: ./ci/fmt.sh

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Run ./ci/lint.sh
uses: ./ci/container
with:
args: ./ci/lint.sh

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Run ./ci/test.sh
uses: ./ci/container
with:
args: ./ci/test.sh
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: 9b3ee4dc-8297-4774-b4b9-a61561fbbce7
- name: Upload coverage.html
uses: actions/upload-artifact@v2
with:
name: coverage.html
path: ./ci/out/coverage.html
40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

7 changes: 0 additions & 7 deletions Makefile

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# websocket

[![godoc](https://godoc.org/nhooyr.io/websocket?status.svg)](https://pkg.go.dev/nhooyr.io/websocket)
[![coverage](https://img.shields.io/badge/coverage-88%25-success)](https://nhooyrio-websocket-coverage.netlify.app)

websocket is a minimal and idiomatic WebSocket library for Go.

Expand All @@ -10,12 +11,11 @@ websocket is a minimal and idiomatic WebSocket library for Go.
go get nhooyr.io/websocket
```

## Features
## Highlights

- Minimal and idiomatic API
- First class [context.Context](https://blog.golang.org/context) support
- Fully passes the WebSocket [autobahn-testsuite](https://github.com/crossbario/autobahn-testsuite)
- Thorough tests with [90% coverage](https://coveralls.io/github/nhooyr/websocket)
- [Single dependency](https://pkg.go.dev/nhooyr.io/websocket?tab=imports)
- JSON and protobuf helpers in the [wsjson](https://pkg.go.dev/nhooyr.io/websocket/wsjson) and [wspb](https://pkg.go.dev/nhooyr.io/websocket/wspb) subpackages
- Zero alloc reads and writes
Expand Down
14 changes: 14 additions & 0 deletions ci/container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM golang

RUN apt-get update
RUN apt-get install -y npm shellcheck chromium

ENV GO111MODULE=on
RUN go get golang.org/x/tools/cmd/goimports
RUN go get mvdan.cc/sh/v3/cmd/shfmt
RUN go get golang.org/x/tools/cmd/stringer
RUN go get golang.org/x/lint/golint
RUN go get github.com/agnivade/wasmbrowsertest

RUN npm install -g prettier
RUN npm install -g netlify-cli
23 changes: 0 additions & 23 deletions ci/ensure_fmt.sh

This file was deleted.

22 changes: 0 additions & 22 deletions ci/fmt.mk

This file was deleted.

38 changes: 38 additions & 0 deletions ci/fmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -euo pipefail

main() {
cd "$(dirname "$0")/.."

go mod tidy
gofmt -w -s .
goimports -w "-local=$(go list -m)" .

prettier \
--write \
--print-width=120 \
--no-semi \
--trailing-comma=all \
--loglevel=warn \
--arrow-parens=avoid \
$(git ls-files "*.yml" "*.md" "*.js" "*.css" "*.html")
shfmt -i 2 -w -s -sr $(git ls-files "*.sh")

stringer -type=opcode,MessageType,StatusCode -output=stringer.go

if [[ ${CI-} ]]; then
ensure_fmt
fi
}

ensure_fmt() {
if [[ $(git ls-files --other --modified --exclude-standard) ]]; then
git -c color.ui=always --no-pager diff
echo
echo "Please run the following locally:"
echo " ./ci/fmt.sh"
exit 1
fi
}

main "$@"
16 changes: 0 additions & 16 deletions ci/lint.mk

This file was deleted.

16 changes: 16 additions & 0 deletions ci/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -euo pipefail

main() {
cd "$(dirname "$0")/.."

go vet ./...
GOOS=js GOARCH=wasm go vet ./...

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

shellcheck --exclude=SC2046 $(git ls-files "*.sh")
}

main "$@"
17 changes: 0 additions & 17 deletions ci/test.mk

This file was deleted.

25 changes: 25 additions & 0 deletions ci/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -euo pipefail

main() {
cd "$(dirname "$0")/.."

go test -timeout=30m -covermode=atomic -coverprofile=ci/out/coverage.prof -coverpkg=./... "$@" ./...
sed -i '/stringer\.go/d' ci/out/coverage.prof
sed -i '/nhooyr.io\/websocket\/internal\/test/d' ci/out/coverage.prof
sed -i '/examples/d' ci/out/coverage.prof

# Last line is the total coverage.
go tool cover -func ci/out/coverage.prof | tail -n1

go tool cover -html=ci/out/coverage.prof -o=ci/out/coverage.html

if [[ ${CI} && ${GITHUB_REF-} == *master ]]; then
local deployDir
deployDir="$(mktemp -d)"
cp ci/out/coverage.html "$deployDir/index.html"
netlify deploy --prod "--dir=$deployDir"
fi
}

main "$@"
4 changes: 0 additions & 4 deletions conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,6 @@ func TestConn(t *testing.T) {
func TestWasm(t *testing.T) {
t.Parallel()

if os.Getenv("CI") != "" {
t.Skip("skipping on CI")
}

s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
c, err := websocket.Accept(w, r, &websocket.AcceptOptions{
Subprotocols: []string{"echo"},
Expand Down