Skip to content

Commit 451ecab

Browse files
committed
Improve ci/fmt.sh and ci/test.sh
1 parent cb7c788 commit 451ecab

File tree

9 files changed

+82
-25
lines changed

9 files changed

+82
-25
lines changed

ci/fmt.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ unstaged_files() {
3434
check() {
3535
if [[ ${CI:-} && $(unstaged_files) != "" ]]; then
3636
echo
37-
echo "Files either need generation or are formatted incorrectly."
37+
echo "Files need generation or are formatted incorrectly."
3838
echo "Please run:"
3939
echo "./ci/fmt.sh"
4040
echo
4141
git status
42+
git diff
4243
exit 1
4344
fi
4445
}

ci/image/Dockerfile

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
FROM golang:1
22

33
ENV DEBIAN_FRONTEND=noninteractive
4-
ENV GOPATH /root/gopath
5-
ENV GOFLAGS -mod=readonly
4+
ENV GOPATH=/root/gopath
5+
ENV GOFLAGS="-mod=readonly"
6+
ENV PAGER=cat
67

78
RUN apt-get update && \
89
apt-get install -y shellcheck python-pip npm && \
910
pip2 install autobahntestsuite && \
1011
npm install -g prettier
1112

13+
RUN git config --global color.ui always

ci/run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ cd "$(git rev-parse --show-toplevel)"
88

99
./ci/fmt.sh
1010
./ci/lint.sh
11-
./ci/test.sh
11+
./ci/test.sh

ci/test.sh

+12-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@ cd "$(dirname "${0}")"
55
cd "$(git rev-parse --show-toplevel)"
66

77
mkdir -p ci/out/websocket
8-
testFlags=(-race "-vet=off" "-bench=." "-coverprofile=ci/out/coverage.prof" "-coverpkg=./...")
9-
if [[ ${CI-} ]]; then
10-
# https://circleci.com/docs/2.0/collect-test-data/
11-
go test "${testFlags[@]}" -v ./... 2>&1 | tee /dev/stderr |
12-
go run github.com/jstemmer/go-junit-report > ci/out/websocket/testReport.xml
13-
else
14-
go test "${testFlags[@]}" ./...
15-
fi
8+
testFlags=(
9+
-race
10+
"-vet=off"
11+
"-bench=."
12+
"-coverprofile=ci/out/coverage.prof"
13+
"-coverpkg=./..."
14+
)
15+
# https://circleci.com/docs/2.0/collect-test-data/
16+
go run gotest.tools/gotestsum \
17+
--junitfile ci/out/websocket/testReport.xml \
18+
--format=short-verbose \
19+
-- "${testFlags[@]}"
1620

1721
go tool cover -html=ci/out/coverage.prof -o=ci/out/coverage.html
1822
if [[ ${CI:-} ]]; then

docs/CONTRIBUTING.md

+3-7
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,16 @@ You can run tests normally with `go test`.
2222
You'll need the [Autobahn Test suite pip package](https://github.com/crossbario/autobahn-testsuite).
2323
In the future this dependency will be removed. See [#117](https://github.com/nhooyr/websocket/issues/117).
2424

25-
Please ensure CI passes for your changes. If necessary, you may run CI locally. The various steps are located
26-
in `ci/*.sh`.
25+
Please ensure CI passes for your changes. If necessary, you may run CI locally.
26+
The various steps are located in `ci/*.sh`.
2727

2828
`ci/fmt.sh` requires node (specifically prettier).
2929
`ci/lint.sh` requires [shellcheck](https://github.com/koalaman/shellcheck#installing).
3030
`ci/test.sh` requires the [Autobahn Test suite pip package](https://github.com/crossbario/autobahn-testsuite).
31-
`ci/bench.sh` requires only Go.
3231
`ci/run.sh` runs everything in the above order and requires all of their dependencies.
3332

34-
See [../ci/image/Dockerfile](../ci/image/Dockerfile) for the installation of the CI dependencies on ubuntu.
33+
See [../ci/image/Dockerfile](../ci/image/Dockerfile) for the installation of the CI dependencies on Ubuntu.
3534

3635
For CI coverage, you can use either [codecov](https://codecov.io/gh/nhooyr/websocket) or click the
3736
`coverage.html` artifact on the test step in CI.
3837
For coverage details locally, please see `ci/out/coverage.html` after running `ci/run.sh` or `ci/test.sh`.
39-
40-
Benchmark profiles generated by `bench.sh` are available as artifacts on the bench step so that they
41-
may be analyzed.

go.mod

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ go 1.12
55
require (
66
github.com/golang/protobuf v1.3.1
77
github.com/google/go-cmp v0.2.0
8-
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024
98
github.com/kr/pretty v0.1.0 // indirect
109
go.coder.com/go-tools v0.0.0-20190317003359-0c6a35b74a16
1110
golang.org/x/lint v0.0.0-20190409202823-959b441ac422
@@ -14,5 +13,8 @@ require (
1413
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
1514
golang.org/x/tools v0.0.0-20190429184909-35c670923e21
1615
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522
16+
gotest.tools/gotestsum v0.3.5
1717
mvdan.cc/sh v2.6.4+incompatible
1818
)
19+
20+
replace gotest.tools/gotestsum => github.com/nhooyr/gotestsum v0.3.6-0.20190821172136-aaabbb33254b

go.sum

+55-2
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,63 @@
1+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
2+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/fatih/color v1.6.0 h1:66qjqZk8kalYAvDRtM1AdAJQI0tj4Wrue3Eq3B3pmFU=
4+
github.com/fatih/color v1.6.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
5+
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
6+
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
7+
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
18
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
29
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
310
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
411
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
5-
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024 h1:rBMNdlhTLzJjJSDIjNEXX1Pz3Hmwmz91v+zycvx9PJc=
6-
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
12+
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
13+
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
14+
github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo=
15+
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
716
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
817
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
918
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
1019
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
1120
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
21+
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
22+
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
23+
github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI=
24+
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
25+
github.com/nhooyr/gotestsum v0.3.6-0.20190821172136-aaabbb33254b h1:t6DbmxEtGMM72Uhs638nBOyK7tjsrDwoMfYO1EfQdFE=
26+
github.com/nhooyr/gotestsum v0.3.6-0.20190821172136-aaabbb33254b/go.mod h1:Mnf3e5FUzXbkCfynWBGOwLssY7gTQgCHObK9tMpAriY=
27+
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
28+
github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w=
29+
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
30+
github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU=
31+
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
32+
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
33+
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
34+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
35+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
36+
github.com/sirupsen/logrus v1.0.5 h1:8c8b5uO0zS4X6RPl/sd1ENwSkIc0/H2PaHxE3udaE8I=
37+
github.com/sirupsen/logrus v1.0.5/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
38+
github.com/spf13/pflag v1.0.1 h1:aCvUg6QPl3ibpQUxyLkrEkCHtPqYJL4x9AuhqVqFis4=
39+
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
40+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
41+
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
42+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
1243
go.coder.com/go-tools v0.0.0-20190317003359-0c6a35b74a16 h1:3gGa1bM0nG7Ruhu5b7wKnoOOwAD/fJ8iyyAcpOzDG3A=
1344
go.coder.com/go-tools v0.0.0-20190317003359-0c6a35b74a16/go.mod h1:iKV5yK9t+J5nG9O3uF6KYdPEz3dyfMyB15MN1rbQ8Qw=
45+
golang.org/x/crypto v0.0.0-20180426230345-b49d69b5da94/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
46+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
1447
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
1548
golang.org/x/lint v0.0.0-20190409202823-959b441ac422 h1:QzoH/1pFpZguR8NrRHLcO6jKqfv2zpuSqZLgdm7ZmjI=
1649
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
50+
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
51+
golang.org/x/net v0.0.0-20181102091132-c10e9556a7bc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
1752
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
1853
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
1954
golang.org/x/net v0.0.0-20190424112056-4829fb13d2c6 h1:FP8hkuE6yUEaJnK7O2eTuejKWwW+Rhfj80dQ2JcKxCU=
2055
golang.org/x/net v0.0.0-20190424112056-4829fb13d2c6/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
56+
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
57+
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
2158
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
59+
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
60+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
2261
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
2362
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
2463
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -32,5 +71,19 @@ golang.org/x/tools v0.0.0-20190429184909-35c670923e21 h1:Kjcw+D2LTzLmxOHrMK9uvYP
3271
golang.org/x/tools v0.0.0-20190429184909-35c670923e21/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
3372
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522 h1:bhOzK9QyoD0ogCnFro1m2mz41+Ib0oOhfJnBp5MR4K4=
3473
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
74+
gopkg.in/airbrake/gobrake.v2 v2.0.9 h1:7z2uVWwn7oVeeugY1DtlPAy5H+KYgB1KeKTnqjNatLo=
75+
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
76+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
77+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
78+
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
79+
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
80+
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 h1:OAj3g0cR6Dx/R07QgQe8wkA9RNjB2u4i700xBkIT4e0=
81+
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo=
82+
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
83+
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
84+
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
85+
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
86+
gotest.tools v2.1.0+incompatible h1:5USw7CrJBYKqjg9R7QlA6jzqZKEAtvW82aNmsxxGPxw=
87+
gotest.tools v2.1.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
3588
mvdan.cc/sh v2.6.4+incompatible h1:eD6tDeh0pw+/TOTI1BBEryZ02rD2nMcFsgcvde7jffM=
3689
mvdan.cc/sh v2.6.4+incompatible/go.mod h1:IeeQbZq+x2SUGBensq/jge5lLQbS3XT2ktyp3wrt4x8=

tools.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ package tools
44

55
// See https://github.com/go-modules-by-example/index/blob/master/010_tools/README.md
66
import (
7-
_ "github.com/jstemmer/go-junit-report"
87
_ "go.coder.com/go-tools/cmd/goimports"
98
_ "golang.org/x/lint/golint"
109
_ "golang.org/x/tools/cmd/stringer"
10+
_ "gotest.tools/gotestsum"
1111
_ "mvdan.cc/sh/cmd/shfmt"
1212
)

websocket.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -672,14 +672,13 @@ func (w *messageWriter) close() error {
672672
if w.closed() {
673673
return xerrors.Errorf("cannot use closed writer")
674674
}
675-
w.closed()
675+
w.c.activeWriter = nil
676676

677677
_, err := w.c.writeFrame(w.c.writeMsgCtx, true, w.c.writeMsgOpcode, nil)
678678
if err != nil {
679679
return xerrors.Errorf("failed to write fin frame: %w", err)
680680
}
681681

682-
w.c.activeWriter = nil
683682
w.c.releaseLock(w.c.writeMsgLock)
684683
return nil
685684
}

0 commit comments

Comments
 (0)