File tree Expand file tree Collapse file tree 7 files changed +75
-48
lines changed
Expand file tree Collapse file tree 7 files changed +75
-48
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ version: 2
22jobs :
33 fmt :
44 docker :
5- - image : golang:1
5+ - image : nhooyr/websocket-ci
66 steps :
77 - checkout
88 - restore_cache :
1919
2020 lint :
2121 docker :
22- - image : golang:1
22+ - image : nhooyr/websocket-ci
2323 steps :
2424 - checkout
2525 - restore_cache :
3636
3737 test :
3838 docker :
39- - image : golang:1
39+ - image : nhooyr/websocket-ci
4040 steps :
4141 - checkout
4242 - restore_cache :
4646 - go-
4747 - run : ./ci/test.sh
4848 - store_artifacts :
49- path : out
49+ path : ci/out
50+ - save_cache :
51+ paths :
52+ - /go
53+ - /root/.cache/go-build
54+ key : go-{{ checksum "go.sum" }}
55+
56+ bench :
57+ docker :
58+ - image : nhooyr/websocket-ci
59+ steps :
60+ - checkout
61+ - restore_cache :
62+ keys :
63+ - go-{{ checksum "go.sum" }}
64+ # Fallback to using the latest cache if no exact match is found.
65+ - go-
66+ - run : ./ci/bench.sh
67+ - store_artifacts :
68+ path : ci/out
5069 - save_cache :
5170 paths :
5271 - /go
Original file line number Diff line number Diff line change 1+ FROM golang:1-alpine
2+
3+ RUN apk add --update bash git
4+
5+ # Autobahn Test suite.
6+ RUN apk add py2-pip python2-dev gcc libffi-dev libc-dev openssl-dev && \
7+ pip install autobahntestsuite
8+
9+ # prettier.
10+ RUN apk add npm && npm install -g prettier
11+
12+ # shellcheck
13+ RUN apk add xz curl && \
14+ curl -o /tmp/shellcheck.tar.xz -L https://storage.googleapis.com/shellcheck/shellcheck-stable.linux.x86_64.tar.xz && \
15+ tar -xf /tmp/shellcheck.tar.xz && \
16+ ln -s "${PWD}/shellcheck-stable/shellcheck" /usr/local/bin/shellcheck
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ set -euo pipefail
44cd " $( dirname " ${0} " ) "
55source ./lib.sh
66
7- go test -- vet=off - -run=^$ -bench=. -o=ci/out/websocket.test \
7+ go test -vet=off -run=^$ -bench=. -o=ci/out/websocket.test \
88 -cpuprofile=ci/out/cpu.prof \
99 -memprofile=ci/out/mem.prof \
1010 -blockprofile=ci/out/block.prof \
Original file line number Diff line number Diff line change @@ -4,35 +4,45 @@ set -euo pipefail
44cd " $( dirname " ${0} " ) "
55source ./lib.sh
66
7- # Unfortunately, this is the only way to ensure go.mod and go.sum are correct.
8- # See https://github.com/golang/go/issues/27005
9- go list ./... > /dev/null
10- go mod tidy
7+ gen () {
8+ # Unfortunately, this is the only way to ensure go.mod and go.sum are correct.
9+ # See https://github.com/golang/go/issues/27005
10+ go list ./... > /dev/null
11+ go mod tidy
1112
12- go generate ./...
13+ go generate ./...
14+ }
1315
14- gofmt -w -s .
15- go run go.coder.com/go-tools/cmd/goimports -w " -local=$( go list -m) " .
16- go run mvdan.cc/sh/cmd/shfmt -i 2 -w -s -sr .
17- # shellcheck disable=SC2046
18- npx prettier \
19- --write \
20- --print-width 120 \
21- --no-semi \
22- --trailing-comma all \
23- --loglevel silent \
24- $( git ls-files " *.yaml" " *.yml" " *.md" )
16+ fmt () {
17+ gofmt -w -s .
18+ go run go.coder.com/go-tools/cmd/goimports -w " -local=$( go list -m) " .
19+ go run mvdan.cc/sh/cmd/shfmt -i 2 -w -s -sr .
20+ # shellcheck disable=SC2046
21+ npx prettier \
22+ --write \
23+ --print-width 120 \
24+ --no-semi \
25+ --trailing-comma all \
26+ --loglevel silent \
27+ $( git ls-files " *.yaml" " *.yml" " *.md" )
28+ }
2529
2630unstaged_files () {
2731 git ls-files --other --modified --exclude-standard
2832}
2933
30- if [[ ${CI:- } && $( unstaged_files) != " " ]]; then
31- echo
32- echo " Files either need generation or are formatted incorrectly."
33- echo " Please run:"
34- echo " ./ci/fmt.sh"
35- echo
36- git status
37- exit 1
38- fi
34+ check () {
35+ if [[ ${CI:- } && $( unstaged_files) != " " ]]; then
36+ echo
37+ echo " Files either need generation or are formatted incorrectly."
38+ echo " Please run:"
39+ echo " ./ci/fmt.sh"
40+ echo
41+ git status
42+ exit 1
43+ fi
44+ }
45+
46+ gen
47+ fmt
48+ check
Original file line number Diff line number Diff line change 22
33set -euo pipefail
44
5- if [[ ${CI:- } ]]; then
6- export GOFLAGS=-mod=readonly
7- export DEBIAN_FRONTEND=noninteractive
8- fi
9-
105cd " $( git rev-parse --show-toplevel) "
Original file line number Diff line number Diff line change @@ -4,11 +4,6 @@ set -euo pipefail
44cd " $( dirname " ${0} " ) "
55source ./lib.sh
66
7- if [[ ${CI:- } ]]; then
8- apt-get update -qq
9- apt-get install -qq shellcheck > /dev/null
10- fi
11-
127# shellcheck disable=SC2046
138shellcheck -e SC1091 -x $( git ls-files " *.sh" )
149go vet ./...
Original file line number Diff line number Diff line change @@ -4,14 +4,6 @@ set -euo pipefail
44cd " $( dirname " ${0} " ) "
55source ./lib.sh
66
7- if [[ ${CI:- } ]]; then
8- apt-get update -qq
9- apt-get install -qq python-pip > /dev/null
10- # Need to add pip install directory to $PATH.
11- export PATH=" /home/circleci/.local/bin:$PATH "
12- pip install -qqq autobahntestsuite
13- fi
14-
157# If you'd like to modify the args to go test, just run go test directly, this script is meant
168# for running tests at the end to get coverage and test under the race detector.
179go test -race -vet=off -coverprofile=ci/out/coverage.prof -coverpkg=./... ./...
You can’t perform that action at this time.
0 commit comments