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
2
2
jobs :
3
3
fmt :
4
4
docker :
5
- - image : golang:1
5
+ - image : nhooyr/websocket-ci
6
6
steps :
7
7
- checkout
8
8
- restore_cache :
19
19
20
20
lint :
21
21
docker :
22
- - image : golang:1
22
+ - image : nhooyr/websocket-ci
23
23
steps :
24
24
- checkout
25
25
- restore_cache :
36
36
37
37
test :
38
38
docker :
39
- - image : golang:1
39
+ - image : nhooyr/websocket-ci
40
40
steps :
41
41
- checkout
42
42
- restore_cache :
46
46
- go-
47
47
- run : ./ci/test.sh
48
48
- 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
50
69
- save_cache :
51
70
paths :
52
71
- /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
4
4
cd " $( dirname " ${0} " ) "
5
5
source ./lib.sh
6
6
7
- go test -- vet=off - -run=^$ -bench=. -o=ci/out/websocket.test \
7
+ go test -vet=off -run=^$ -bench=. -o=ci/out/websocket.test \
8
8
-cpuprofile=ci/out/cpu.prof \
9
9
-memprofile=ci/out/mem.prof \
10
10
-blockprofile=ci/out/block.prof \
Original file line number Diff line number Diff line change @@ -4,35 +4,45 @@ set -euo pipefail
4
4
cd " $( dirname " ${0} " ) "
5
5
source ./lib.sh
6
6
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
11
12
12
- go generate ./...
13
+ go generate ./...
14
+ }
13
15
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
+ }
25
29
26
30
unstaged_files () {
27
31
git ls-files --other --modified --exclude-standard
28
32
}
29
33
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 2
2
3
3
set -euo pipefail
4
4
5
- if [[ ${CI:- } ]]; then
6
- export GOFLAGS=-mod=readonly
7
- export DEBIAN_FRONTEND=noninteractive
8
- fi
9
-
10
5
cd " $( git rev-parse --show-toplevel) "
Original file line number Diff line number Diff line change @@ -4,11 +4,6 @@ set -euo pipefail
4
4
cd " $( dirname " ${0} " ) "
5
5
source ./lib.sh
6
6
7
- if [[ ${CI:- } ]]; then
8
- apt-get update -qq
9
- apt-get install -qq shellcheck > /dev/null
10
- fi
11
-
12
7
# shellcheck disable=SC2046
13
8
shellcheck -e SC1091 -x $( git ls-files " *.sh" )
14
9
go vet ./...
Original file line number Diff line number Diff line change @@ -4,14 +4,6 @@ set -euo pipefail
4
4
cd " $( dirname " ${0} " ) "
5
5
source ./lib.sh
6
6
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
-
15
7
# If you'd like to modify the args to go test, just run go test directly, this script is meant
16
8
# for running tests at the end to get coverage and test under the race detector.
17
9
go test -race -vet=off -coverprofile=ci/out/coverage.prof -coverpkg=./... ./...
You can’t perform that action at this time.
0 commit comments