forked from gopherjs/gopherjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
circle.yml
275 lines (264 loc) · 8.9 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# 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 lints, 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
- darwin_smoke:
requires:
- build
- windows_smoke:
requires:
- build
parameters:
go_version:
type: string
default: "1.18.10"
nvm_version:
type: string
default: "0.38.0"
node_version:
type: string
default: "12"
orbs:
win: circleci/windows@4.0.0
go: circleci/go@1.7.1
node: circleci/node@5.0.1
jobs:
build:
executor: gopherjs
steps:
- setup_and_install_gopherjs
- 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
windows_smoke:
executor:
name: win/default
shell: powershell.exe
steps:
- checkout
- run:
name: Install Go
command: |
choco install golang --version="<< pipeline.parameters.go_version >>" -my
go version
(Get-Command go).Path
[Environment]::SetEnvironmentVariable(
"Path",
[Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine) + ";C:\Users\circleci\go\bin",
[EnvironmentVariableTarget]::Machine)
- install_deps:
optional: false
- run:
name: Install GopherJS
command:
go install -v .
(Get-Command gopherjs).Path
- run:
name: Test GopherJS
command: go test -v -short ./...
- run:
name: Smoke tests
command: |
$env:NODE_PATH=$(npm root)
$env:SOURCE_MAP_SUPPORT=false
gopherjs build -v net/http
gopherjs test -v --short fmt sort ./tests
darwin_smoke:
macos:
xcode: 13.3.0 # Mac OS 12.2.1
steps:
- checkout
- setup_environment
- install_deps:
optional: false
- run:
name: Install GopherJS
command: go install -v .
- run:
name: Test GopherJS
command: go test -v -short ./...
- run:
name: Smoke tests
command: |
gopherjs build -v net/http
gopherjs test -v --short fmt log os ./tests
commands:
setup_environment:
description: Set up Go, NVM and Node.js
steps:
- go/install:
version: << pipeline.parameters.go_version >>
- node/install:
node-version: << pipeline.parameters.node_version >>
- run:
name: Set up environment
command: |
echo 'export PATH="$PATH:$HOME/go/bin"' >> $BASH_ENV
echo 'export GO111MODULE=on' >> $BASH_ENV
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
go version
node -v
go install -v github.com/nevkontakte/go-junit-report@forked # For CircleCI test reports.
install_deps:
description: Install Go and Node dependency packages
parameters:
optional:
default: true
type: boolean
description: Install node-syscall module and its dependencies.
steps:
- when:
condition:
not: << parameters.optional >>
steps:
- run:
name: Install required Node.js packages
command: |
# Extra flags to avoid installing node-syscall.
npm install --no-optional --no-package-lock
- when:
condition: << parameters.optional >>
steps:
- run:
name: Install required Node.js packages (including optional)
command: |
npm ci # Install our dependencies from package.json.
- go/mod-download
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