Skip to content

Commit c261d49

Browse files
authored
Merge pull request #108 from nhooyr/circleci
Switch to CircleCI
2 parents 01602c9 + 002abf1 commit c261d49

File tree

18 files changed

+185
-220
lines changed

18 files changed

+185
-220
lines changed

.circleci/config.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
version: 2
2+
jobs:
3+
fmt:
4+
docker:
5+
- image: golang:1
6+
steps:
7+
- checkout
8+
- restore_cache:
9+
keys:
10+
- go-{{ checksum "go.sum" }}
11+
# Fallback to using the latest cache if no exact match is found.
12+
- go-
13+
- run: ./ci/fmt.sh
14+
- save_cache:
15+
paths:
16+
- /go
17+
- /root/.cache/go-build
18+
key: go-{{ checksum "go.sum" }}
19+
20+
lint:
21+
docker:
22+
- image: golang:1
23+
steps:
24+
- checkout
25+
- restore_cache:
26+
keys:
27+
- go-{{ checksum "go.sum" }}
28+
# Fallback to using the latest cache if no exact match is found.
29+
- go-
30+
- run: ./ci/lint.sh
31+
- save_cache:
32+
paths:
33+
- /go
34+
- /root/.cache/go-build
35+
key: go-{{ checksum "go.sum" }}
36+
37+
test:
38+
docker:
39+
- image: golang:1
40+
steps:
41+
- checkout
42+
- restore_cache:
43+
keys:
44+
- go-{{ checksum "go.sum" }}
45+
# Fallback to using the latest cache if no exact match is found.
46+
- go-
47+
- run: ./ci/test.sh
48+
- save_cache:
49+
paths:
50+
- /go
51+
- /root/.cache/go-build
52+
key: go-{{ checksum "go.sum" }}
53+
54+
workflows:
55+
version: 2
56+
fmt:
57+
jobs:
58+
- fmt
59+
lint:
60+
jobs:
61+
- lint
62+
test:
63+
jobs:
64+
- test

.github/main.workflow

Lines changed: 0 additions & 21 deletions
This file was deleted.

ci/.codecov.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
comment: off
12
coverage:
23
status:
34
# Prevent small changes in coverage from failing CI.

ci/bench.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
cd "$(dirname "${0}")"
5+
source ./lib.sh
6+
7+
go test --vet=off --run=^$ -bench=. -o=ci/out/websocket.test \
8+
-cpuprofile=ci/out/cpu.prof \
9+
-memprofile=ci/out/mem.prof \
10+
-blockprofile=ci/out/block.prof \
11+
-mutexprofile=ci/out/mutex.prof \
12+
.
13+
14+
echo
15+
echo "Profiles are in ./ci/out/*.prof
16+
Keep in mind that every profiler Go provides is enabled so that may skew the benchmarks."

ci/bench/Dockerfile

Lines changed: 0 additions & 10 deletions
This file was deleted.

ci/bench/entrypoint.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

ci/fmt.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
cd "$(dirname "${0}")"
5+
source ./lib.sh
6+
7+
unstaged_files() {
8+
git ls-files --other --modified --exclude-standard
9+
}
10+
11+
gen() {
12+
# Unfortunately, this is the only way to ensure go.mod and go.sum are correct.
13+
# See https://github.com/golang/go/issues/27005
14+
go list ./... > /dev/null
15+
go mod tidy
16+
17+
go generate ./...
18+
}
19+
20+
fmt() {
21+
gofmt -w -s .
22+
go run go.coder.com/go-tools/cmd/goimports -w "-local=$(go list -m)" .
23+
go run mvdan.cc/sh/cmd/shfmt -i 2 -w -s -sr .
24+
}
25+
26+
gen
27+
fmt
28+
29+
if [[ $CI && $(unstaged_files) != "" ]]; then
30+
echo
31+
echo "Files either need generation or are formatted incorrectly."
32+
echo "Please run:"
33+
echo "./ci/fmt.sh"
34+
echo
35+
git status
36+
exit 1
37+
fi

ci/fmt/Dockerfile

Lines changed: 0 additions & 10 deletions
This file was deleted.

ci/fmt/entrypoint.sh

Lines changed: 0 additions & 36 deletions
This file was deleted.

ci/lib.sh

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
#!/usr/bin/env bash
22

3-
set -euxo pipefail || exit 1
4-
5-
export GO111MODULE=on
6-
export PAGER=cat
7-
8-
# shellcheck disable=SC2034
9-
# CI is used by the scripts that source this file.
10-
export CI=${GITHUB_ACTION-}
3+
set -euo pipefail
114

5+
# Ensures $CI can be used if it's set or not.
6+
export CI=${CI:-}
127
if [[ $CI ]]; then
13-
export GOFLAGS=-mod=readonly
8+
export GOFLAGS=-mod=readonly
9+
export DEBIAN_FRONTEND=noninteractive
1410
fi
11+
12+
cd "$(git rev-parse --show-toplevel)"

0 commit comments

Comments
 (0)