forked from gopherjs/gopherjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
circle.yml
222 lines (215 loc) · 7.86 KB
/
circle.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# CircleCI configuration for GopherJS.
#
# This configuration has one build_and_test workflow designed to run on all commits
# and pull requests. It consists of three jobs:
#
# - build: Builds and runs GopherJS unit tests, as well as lits, smoke tests, etc.
# This job is designed to provide quickest feedback on the most important
# functionality. It should not include anything heavyweight and should be kept
# under 2-3 minutes of runtime.
#
# - gopherjs_tests: Runs standard library and GopherJS package tests using GopherJS
# *itself*. This is the most comprehensive test suite we have and it is sharded
# into 4 parallel instances for faster execution.
#
# - gorepo_tests: Runs language tests from the Go compiler test suite. The objective
# of these tests is to ensure conformance of GopherJS to the upstream Go to the
# highest degree possible, considering differences in the runtime.
#
# If all tests passed, it is reasonably to assume that the version is more or less
# bug-free (although as of summer 2021 our test coverage is not ideal).
#
# For convenience of upgrades, NVM, Node.js and Go versions are specified as
# parameters at the top of the config. Increasing the version and ensuring that the
# workflow passes is sufficient to verify GopherJS compatibility with that version.
#
# Versions of Node modules GopherJS depends on are specified in package.json and can
# be changed there (remember to run `npm install` to update the lock file).
version: 2.1
executors:
gopherjs:
docker:
- image: cimg/base:stable
working_directory: ~/gopherjs
workflows:
version: 2
build_and_test:
jobs:
- build
- gopherjs_tests:
requires:
- build
- gorepo_tests:
requires:
- build
parameters:
go_version:
type: string
default: "1.17.3"
nvm_version:
type: string
default: "0.38.0"
node_version:
type: string
default: "12"
jobs:
build:
executor: gopherjs
steps:
- setup_and_install_gopherjs
- run:
name: Check minified prelude
command: |
set -e
go generate github.com/gopherjs/gopherjs/compiler/prelude
diff -u <(echo -n) <(git status --porcelain)
- run:
name: Check gofmt
command: diff -u <(echo -n) <(gofmt -d .)
- run:
name: Check go vet
command: |
set -e
# Go package in root directory.
go vet .
# All subdirectories except "doc", "tests", "node*".
for d in */; do echo ./$d...; done | grep -v ./doc | grep -v ./tests | grep -v ./node | xargs go vet
- run:
name: Check natives build tags
command: diff -u <(echo -n) <(go list ./compiler/natives/src/...) # All those packages should have // +build js.
- run:
name: Smoke tests
command: |
gopherjs build -v net/http # Should build successfully.
gopherjs test -v fmt log # Should catch problems with test execution and source maps.
- run:
name: go test ...
command: |
set +e
# Run all tests except gorepo, which will be run separately in parallel.
go test -v -race $(go list ./... | grep -v github.com/gopherjs/gopherjs/tests/gorepo) | tee /tmp/test-go.txt
status="$?"
# Convert test output into junit format for CircleCI.
mkdir -p ~/test-reports/
go-junit-report --full-class-name < /tmp/test-go.txt > ~/test-reports/go.xml
exit "$status"
- store_test_results:
path: ~/test-reports/
- run:
name: TodoMVC in GOPATH mode
command: |
set -e
export GO111MODULE=off
export GOPATH=/tmp/gopath
mkdir -p $GOPATH/src
go get -v github.com/gopherjs/todomvc
gopherjs build -v -o /tmp/todomvc_gopath.js github.com/gopherjs/todomvc
gopherjs test -v github.com/gopherjs/todomvc/...
find $GOPATH
- run:
name: TodoMVC in Go Modules mode
command: |
set -e
export GO111MODULE=on
export GOPATH=/tmp/gomod
mkdir -p $GOPATH/src
cd /tmp
git clone --depth=1 https://github.com/gopherjs/todomvc.git
cd /tmp/todomvc
gopherjs build -v -o /tmp/todomvc_gomod.js github.com/gopherjs/todomvc
gopherjs test -v github.com/gopherjs/todomvc/...
find $GOPATH
- run:
name: Compare GOPATH and Go Modules output
command: diff -u <(sed 's/todomvc_gomod.js.map/todomvc_ignored.js.map/' /tmp/todomvc_gomod.js) <(sed 's/todomvc_gopath.js.map/todomvc_ignored.js.map/' /tmp/todomvc_gopath.js)
gopherjs_tests:
executor: gopherjs
parallelism: 4
steps:
- setup_and_install_gopherjs
- run:
name: gopherjs test ...
command: |
set +e
ulimit -s 10000
PACKAGE_NAMES=$( \
GOOS=js GOARCH=wasm go list std github.com/gopherjs/gopherjs/js/... github.com/gopherjs/gopherjs/tests/... \
| grep -v -x -f .std_test_pkg_exclusions \
| circleci tests split --split-by=timings --timings-type=classname \
)
gopherjs test -p 2 --minify -v --short $PACKAGE_NAMES \
| tee /tmp/test-gopherjs.txt
status="$?"
set -e
# Convert test output into junit format for CircleCI.
mkdir -p ~/test-reports/
go-junit-report --full-class-name < /tmp/test-gopherjs.txt > ~/test-reports/gopherjs-${CIRCLE_NODE_INDEX}.xml
exit "$status"
no_output_timeout: "1h" # Packages like math/big take a while to run all tests.
- store_test_results:
path: ~/test-reports/
gorepo_tests:
executor: gopherjs
parallelism: 4
steps:
- setup_environment
- checkout
- install_deps
- install_gopherjs
- run:
name: Go Repository tests
command: |
go test -v github.com/gopherjs/gopherjs/tests/gorepo
commands:
setup_environment:
description: Set up Go, NVM and Node.js
steps:
- run:
name: Install Go
command: |
cd /usr/local
sudo rm -rf go
curl "https://storage.googleapis.com/golang/go<< pipeline.parameters.go_version >>.linux-amd64.tar.gz" | sudo tar -xz
echo 'export PATH="$PATH:/usr/local/go/bin:$HOME/go/bin"' >> $BASH_ENV
echo 'export GO111MODULE=on' >> $BASH_ENV
. $BASH_ENV
go version
go get -v github.com/nevkontakte/go-junit-report@forked # For CircleCI test reports.
- run:
name: Install NVM
command: |
git clone https://github.com/nvm-sh/nvm $HOME/.nvm
cd $HOME/.nvm && git checkout "v<< pipeline.parameters.nvm_version >>"
echo 'export NVM_DIR="${HOME}/.nvm"' >> "${BASH_ENV}"
echo '[ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh"' >> "${BASH_ENV}"
- run:
name: Install Node.js
command: |
nvm install "<< pipeline.parameters.node_version >>" && nvm alias default "<< pipeline.parameters.node_version >>"
node --version
install_deps:
description: Install Go and Node dependency packages
steps:
- run:
name: Install required Node.js packages
command: |
npm ci # Install our dependencies from package.json.
echo 'export SOURCE_MAP_SUPPORT=true' >> $BASH_ENV
# Make nodejs able to require installed modules from any working path.
echo export "NODE_PATH='$(npm root)'" >> "${BASH_ENV}"
- run:
name: Install required Go packages
command: go mod download -x
install_gopherjs:
description: Install GopherJS
steps:
- run:
name: Install GopherJS
command: go install -v && gopherjs version
setup_and_install_gopherjs:
description: A shorthand for setting up GopherJS environment and building the binary.
steps:
- setup_environment
- checkout
- install_deps
- install_gopherjs