This repository has been archived by the owner on Jan 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
357 lines (345 loc) · 12.3 KB
/
all.yaml
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
name: CI
on:
# Enable manually triggering this workflow via the API or web UI
workflow_dispatch:
push:
branches:
- main
tags:
- v*
pull_request:
defaults:
run:
shell: bash
env:
APP_NAME: "xk6-browser"
jobs:
deps:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17.x
- name: Check code generation
run: |
go install github.com/alvaroloes/[email protected]
go install github.com/mailru/easyjson/[email protected]
test -z "$(go generate ./... && git status --porcelain)"
lint:
runs-on: ubuntu-latest
env:
GOLANG_CI_VERSION: "1.39.0"
GO111MODULE: 'on'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17.x
- name: Install golangci-lint
working-directory: /tmp
run: go install "github.com/golangci/golangci-lint/cmd/golangci-lint@v$GOLANG_CI_VERSION"
- name: Run linters
run: |
BASEREV=$(git merge-base HEAD origin/main)
echo "Base revision: $BASEREV"
golangci-lint run --timeout=3m --out-format=tab --new-from-rev "$BASEREV" ./...
test-prev:
strategy:
fail-fast: false
matrix:
go-version: [1.16.x]
#platform: [ubuntu-latest, macos-latest, windows-latest]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Install chrome dependencies
if: runner.os == 'Linux'
run: "${GITHUB_WORKSPACE}/.github/bin/install_chrome_deps_linux.sh"
- name: Setup chrome
uses: browser-actions/setup-chrome@latest
with:
chrome-version: stable
- name: Chrome version
if: runner.os != 'Windows'
run: chrome --version
- name: Chrome version
if: runner.os == 'Windows'
shell: powershell
# chrome --version doesn't work on Windows :-/
# See https://bugs.chromium.org/p/chromium/issues/detail?id=158372
run: (get-command chrome.exe).Version
- name: Run tests
run: |
set -x
go version
export GOMAXPROCS=2
go test -v -p 2 -race -timeout 60s ./...
test-tip:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.x
- name: Install Go tip
run: |
go install golang.org/dl/gotip@latest
gotip download
echo "GOROOT=$HOME/sdk/gotip" >> "$GITHUB_ENV"
echo "GOPATH=$HOME/go" >> "$GITHUB_ENV"
echo "$HOME/go/bin" >> "$GITHUB_PATH"
echo "$HOME/sdk/gotip/bin" >> "$GITHUB_PATH"
- name: Install chrome dependencies
if: runner.os == 'Linux'
run: "${GITHUB_WORKSPACE}/.github/bin/install_chrome_deps_linux.sh"
- name: Setup chrome
uses: browser-actions/setup-chrome@latest
with:
chrome-version: stable
- name: Chrome version
if: runner.os != 'Windows'
run: chrome --version
- name: Chrome version
if: runner.os == 'Windows'
shell: powershell
# chrome --version doesn't work on Windows :-/
# See https://bugs.chromium.org/p/chromium/issues/detail?id=158372
run: (get-command chrome.exe).Version
- name: Run tests
run: |
set -x
which go
go version
export GOMAXPROCS=2
go test -v -p 2 -race -timeout 60s ./...
test-current-cov:
strategy:
fail-fast: false
matrix:
go-version: [1.17.x]
#platform: [ubuntu-latest, macos-latest, windows-latest]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Install chrome dependencies
if: runner.os == 'Linux'
run: "${GITHUB_WORKSPACE}/.github/bin/install_chrome_deps_linux.sh"
- name: Setup chrome
uses: browser-actions/setup-chrome@latest
with:
chrome-version: stable
- name: Chrome version
if: runner.os != 'Windows'
run: chrome --version
- name: Chrome version
if: runner.os == 'Windows'
shell: powershell
# chrome --version doesn't work on Windows :-/
# See https://bugs.chromium.org/p/chromium/issues/detail?id=158372
run: (get-command chrome.exe).Version
- name: Run tests with code coverage
run: |
go version
export GOMAXPROCS=2
echo "mode: set" > coverage.txt
for pkg in $(go list ./... | grep -v vendor); do
list=$(go list -test -f '{{ join .Deps "\n"}}' $pkg | grep github.com/grafana/xk6-browser | grep -v vendor || true)
if [ -n "$list" ]; then
list=$(echo "$list" | cut -f1 -d ' ' | sort -u | paste -sd, -)
fi
go test -v -p 2 -race -timeout 60s --coverpkg="$list" -coverprofile=$(echo $pkg | tr / -).coverage $pkg
done
grep -h -v "^mode:" *.coverage >> coverage.txt
rm -f *.coverage
- name: Generate coverage HTML report
run: go tool cover -html=coverage.txt -o coverage.html
- name: Upload coverage report
uses: actions/upload-artifact@v2
with:
name: test-coverage-report-${{ matrix.platform }}
path: coverage.html
configure:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Get version
id: get_version
run: |
VERSION="${GITHUB_REF##*/}"
echo "VERSION=${VERSION}"
echo "::set-output name=version::${VERSION}"
build:
runs-on: ubuntu-latest
needs: [configure, deps, lint, test-current-cov]
if: startsWith(github.ref, 'refs/tags/v')
env:
VERSION: ${{ needs.configure.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17.x
- name: Install package builders
env:
GO111MODULE: 'off'
run: |
gopath="$(go env GOPATH)"
go get github.com/Masterminds/glide
go get -d github.com/mh-cbon/go-bin-deb \
&& (cd "$gopath/src/github.com/mh-cbon/go-bin-deb" \
&& glide install \
&& go install)
go get -d github.com/mh-cbon/go-bin-rpm \
&& (cd "$gopath/src/github.com/mh-cbon/go-bin-rpm" \
&& glide install \
&& go install)
sudo apt-get update -y
sudo apt-get install -y fakeroot rpm
- name: Generate Windows binary metadata
run: |
(cd && GO111MODULE=on go get github.com/josephspurrier/goversioninfo/cmd/[email protected])
IFS=. read -a version <<< "$(echo $VERSION | sed 's:[^0-9\.]::g')"
# Need a blank versioninfo.json for the CLI overrides to work.
echo '{}' > versioninfo.json
goversioninfo -64 \
-platform-specific=true \
-charset="1200" \
-company="Load Impact AB" \
-copyright="© Load Impact AB. Licensed under AGPL." \
-description="A modern load testing tool, using Go and JavaScript" \
-icon=packaging/xk6-browser.ico \
-internal-name="xk6-browser" \
-original-name="xk6-browser.exe" \
-product-name="xk6-browser" \
-translation="0x0409" \
-ver-major="${version[0]}" \
-ver-minor="${version[1]}" \
-ver-patch="${version[2]}" \
-product-version="${VERSION#v}"
- name: Build
run: |
go version
./build-release.sh
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: binaries
path: dist/
retention-days: 7
package-windows:
runs-on: windows-latest
defaults:
run:
shell: powershell
needs: [deps, lint, test-current-cov, configure, build]
if: startsWith(github.ref, 'refs/tags/v')
env:
VERSION: ${{ needs.configure.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install pandoc
uses: crazy-max/ghaction-chocolatey@b6061d587628735be315d74358228b83a7dba9a7
with:
args: install -y pandoc
- name: Install wix tools
run: |
curl -O wix311-binaries.zip https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip
Expand-Archive -Path .\wix311-binaries.zip -DestinationPath .\wix311\
echo "$pwd\wix311" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Download binaries
uses: actions/download-artifact@v2
with:
name: binaries
path: dist
- name: Unzip Windows binary
run: |
Expand-Archive -Path ".\dist\xk6-browser-$env:VERSION-windows-amd64.zip" -DestinationPath .\packaging\
move .\packaging\xk6-browser-$env:VERSION-windows-amd64\xk6-browser.exe .\packaging\
rmdir .\packaging\xk6-browser-$env:VERSION-windows-amd64\
- name: Add signtool to PATH
run: echo "${env:ProgramFiles(x86)}\Windows Kits\10\bin\x64" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Convert base64 certificate to PFX
run: |
$bytes = [Convert]::FromBase64String("${{ secrets.WIN_SIGN_CERT }}")
[IO.File]::WriteAllBytes("xk6-browser.pfx", $bytes)
- name: Sign Windows binary
run: signtool sign /f xk6-browser.pfx /p "${{ secrets.WIN_SIGN_PASS }}" /tr "http://timestamp.digicert.com" /td sha256 /fd sha256 "packaging\xk6-browser.exe"
- name: Create MSI package
run: |
$env:VERSION = $env:VERSION -replace 'v(\d+\.\d+\.\d+).*','$1'
pandoc -s -f markdown -t rtf -o packaging\LICENSE.rtf LICENSE.md
cd .\packaging
candle.exe -arch x64 "-dVERSION=$env:VERSION" xk6-browser.wxs
light.exe -ext WixUIExtension xk6-browser.wixobj
- name: Sign MSI package
run: signtool sign /f xk6-browser.pfx /p "${{ secrets.WIN_SIGN_PASS }}" /tr "http://timestamp.digicert.com" /td sha256 /fd sha256 "packaging\xk6-browser.msi"
- name: Cleanup signing artifacts
run: del xk6-browser.pfx
- name: Rename MSI package
# To keep it consistent with the other artifacts
run: move "packaging\xk6-browser.msi" "packaging\xk6-browser-$env:VERSION-windows-amd64.msi"
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: binaries-windows
path: |
packaging/xk6-browser-*.msi
packaging/xk6-browser.*.nupkg
retention-days: 7
publish-github:
runs-on: ubuntu-latest
needs: [configure, deps, lint, test-current-cov, build, package-windows]
if: startsWith(github.ref, 'refs/tags/v')
env:
VERSION: ${{ needs.configure.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Download binaries
uses: actions/download-artifact@v2
with:
name: binaries
path: dist
- name: Download Windows binaries
uses: actions/download-artifact@v2
with:
name: binaries-windows
path: dist
- name: Generate checksum file
run: cd dist && sha256sum * > "xk6-browser-${VERSION}-checksums.txt"
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x
assets=()
for asset in ./dist/*; do
assets+=("-a" "$asset")
done
hub release create "${assets[@]}" -m "$VERSION" -m "$(cat ./release\ notes/${VERSION}.md)" "$VERSION"