Skip to content

Commit a2abcd4

Browse files
committed
Switch to arch linux for CI
Race detector doesn't work on alpine. See golang/go#14481
1 parent 1e60655 commit a2abcd4

File tree

9 files changed

+66
-46
lines changed

9 files changed

+66
-46
lines changed

.circleci/config.yml

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ jobs:
77
- checkout
88
- restore_cache:
99
keys:
10-
- go-{{ checksum "go.sum" }}
10+
- go-v1-{{ checksum "go.sum" }}
1111
# Fallback to using the latest cache if no exact match is found.
12-
- go-
12+
- go-v1-
1313
- run: ./ci/fmt.sh
1414
- save_cache:
1515
paths:
16-
- /go
16+
- /root/go
1717
- /root/.cache/go-build
18-
key: go-{{ checksum "go.sum" }}
18+
key: go-v1-{{ checksum "go.sum" }}
1919

2020
lint:
2121
docker:
@@ -24,15 +24,15 @@ jobs:
2424
- checkout
2525
- restore_cache:
2626
keys:
27-
- go-{{ checksum "go.sum" }}
27+
- go-v1-{{ checksum "go.sum" }}
2828
# Fallback to using the latest cache if no exact match is found.
29-
- go-
29+
- go-v1-
3030
- run: ./ci/lint.sh
3131
- save_cache:
3232
paths:
33-
- /go
33+
- /root/go
3434
- /root/.cache/go-build
35-
key: go-{{ checksum "go.sum" }}
35+
key: go-v1-{{ checksum "go.sum" }}
3636

3737
test:
3838
docker:
@@ -41,17 +41,20 @@ jobs:
4141
- checkout
4242
- restore_cache:
4343
keys:
44-
- go-{{ checksum "go.sum" }}
44+
- go-v1-{{ checksum "go.sum" }}
4545
# Fallback to using the latest cache if no exact match is found.
46-
- go-
46+
- go-v1-
4747
- run: ./ci/test.sh
4848
- store_artifacts:
4949
path: ci/out
50+
destination: out
5051
- save_cache:
5152
paths:
52-
- /go
53+
- /root/go
5354
- /root/.cache/go-build
54-
key: go-{{ checksum "go.sum" }}
55+
key: go-v1-{{ checksum "go.sum" }}
56+
- store_test_results:
57+
path: ci/out
5558

5659
bench:
5760
docker:
@@ -60,17 +63,18 @@ jobs:
6063
- checkout
6164
- restore_cache:
6265
keys:
63-
- go-{{ checksum "go.sum" }}
66+
- go-v1-{{ checksum "go.sum" }}
6467
# Fallback to using the latest cache if no exact match is found.
65-
- go-
68+
- go-v1-
6669
- run: ./ci/bench.sh
6770
- store_artifacts:
6871
path: ci/out
72+
destination: out
6973
- save_cache:
7074
paths:
71-
- /go
75+
- /root/go
7276
- /root/.cache/go-build
73-
key: go-{{ checksum "go.sum" }}
77+
key: go-v1-{{ checksum "go.sum" }}
7478

7579
workflows:
7680
version: 2
@@ -85,4 +89,4 @@ workflows:
8589
- test
8690
bench:
8791
jobs:
88-
- bench
92+
- bench

ci/bench.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,25 @@ cd "$(dirname "${0}")"
55
cd "$(git rev-parse --show-toplevel)"
66

77
mkdir -p ci/out
8-
go test -vet=off -run=^$ -bench=. -o=ci/out/websocket.test \
9-
-cpuprofile=ci/out/cpu.prof \
10-
-memprofile=ci/out/mem.prof \
11-
-blockprofile=ci/out/block.prof \
12-
-mutexprofile=ci/out/mutex.prof \
8+
benchArgs=(
9+
"-vet=off"
10+
"-run=^$"
11+
"-bench=."
12+
"-o=ci/out/websocket.test"
13+
"-cpuprofile=ci/out/cpu.prof"
14+
"-memprofile=ci/out/mem.prof"
15+
"-blockprofile=ci/out/block.prof"
16+
"-mutexprofile=ci/out/mutex.prof"
1317
.
18+
)
19+
20+
if [[ ${CI-} ]]; then
21+
# https://circleci.com/docs/2.0/collect-test-data/
22+
go test "${benchArgs[@]}" | tee /dev/stderr |
23+
go run github.com/jstemmer/go-junit-report > ci/out/testReport.xml
24+
else
25+
go test "${benchArgs[@]}"
26+
fi
1427

1528
echo
1629
echo "Profiles are in ./ci/out/*.prof

ci/image/Dockerfile

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
FROM golang:1-alpine
1+
FROM archlinux/base
22

3-
RUN apk add --update bash git
3+
RUN pacman -Syu --noconfirm
44

5-
# Autobahn Test suite.
6-
RUN apk add py2-pip python2-dev gcc libffi-dev libc-dev openssl-dev && \
7-
pip install autobahntestsuite
5+
RUN pacman -S --noconfirm go git shellcheck tar openssh gzip ca-certificates
86

9-
# prettier.
10-
RUN apk add npm && npm install -g prettier
7+
RUN pacman -S --noconfirm gcc python2-pip && \
8+
pip2 install autobahntestsuite
119

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
10+
RUN pacman -S --noconfirm npm && \
11+
npm install -g prettier
12+
13+
ENV GOFLAGS -mod=readonly

ci/lint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ cd "$(dirname "${0}")"
55
cd "$(git rev-parse --show-toplevel)"
66

77
# shellcheck disable=SC2046
8-
shellcheck -e SC1091 -x $(git ls-files "*.sh")
8+
shellcheck -x $(git ls-files "*.sh")
99
go vet ./...
1010
go run golang.org/x/lint/golint -set_exit_status ./...

ci/test.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ cd "$(dirname "${0}")"
55
cd "$(git rev-parse --show-toplevel)"
66

77
mkdir -p ci/out
8-
# If you'd like to modify the args to go test, just run go test directly, this script is meant
9-
# for running tests at the end to get coverage and test under the race detector.
10-
go test -race -vet=off -coverprofile=ci/out/coverage.prof -coverpkg=./... ./...
8+
testFlags=(-race "-vet=off" "-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/testReport.xml
13+
else
14+
go test "${testFlags[@]}" ./...
15+
fi
16+
go tool cover -html=ci/out/coverage.prof -o=ci/out/coverage.html
1117

1218
if [[ ${CI:-} ]]; then
1319
bash <(curl -s https://codecov.io/bash) -f ci/out/coverage.prof
14-
else
15-
go tool cover -html=ci/out/coverage.prof -o=ci/out/coverage.html
1620
fi

docs/CONTRIBUTING.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ For remote coverage, you can use either [codecov](https://codecov.io/gh/nhooyr/w
3434

3535
You can also run any of the CI steps individually. All of them are scripts in the `ci` directory.
3636

37-
See [../ci/lint.sh](../ci/lint.sh) and [../ci/test.sh](../ci/test.sh) for the
38-
installation of shellcheck, node and the Autobahn test suite on Debian or Ubuntu.
37+
See [../ci/image/Dockerfile](../ci/image/Dockerfile) for the
38+
installation of the CI dependencies on arch linux.
3939

40-
For Go, please refer to the [offical docs](https://golang.org/doc/install).
41-
42-
You can benchmark the library with `./ci/benchmark.sh`. You only need Go to run that script. Benchmark
43-
profiles generated by that script are also available as artifacts on the bench step.
40+
You can benchmark the library with `./ci/benchmark.sh`. You only need Go to run that script.
41+
Benchmark profiles generated by that script are also available as artifacts on the bench step.

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ 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
89
github.com/kr/pretty v0.1.0 // indirect
910
go.coder.com/go-tools v0.0.0-20190317003359-0c6a35b74a16
1011
golang.org/x/lint v0.0.0-20190409202823-959b441ac422

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg
22
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
33
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
44
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=
57
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
68
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
79
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=

tools.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ 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"
78
_ "go.coder.com/go-tools/cmd/goimports"
89
_ "golang.org/x/lint/golint"
910
_ "golang.org/x/tools/cmd/stringer"

0 commit comments

Comments
 (0)