Repository navigation
149 lines (143 loc) · 6.19 KB
/
Copy pathplayground.yml
File metadata and controls
149 lines (143 loc) · 6.19 KB
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
# The playground (playground/, a nested Go module): go-ndarray compiled to
# WebAssembly inside a go-widgets canvas app. Three gates:
#
# test gofmt, vet, the native suite under -race at 100% statement
# coverage (cmd/playground-wasm is the js-only shell and is
# excluded), the engine suite run AS WebAssembly under node
# (where GOMAXPROCS is 1 and go-ndarray must start no helper
# goroutine), and the wasm build, whose size is reported.
# ui-guards mvvmlint (no direct widget-state writes) and bricolint (no
# hand-drawn UI), each with a negative control proving it bites.
# browser-proof the BUILT page (Hugo + the wasm) in headless Chrome, light
# and dark forced, 1x and 2x, plus a phone (390x844 at 3x,
# mobile, touch): real clicks and keys, asserted on the app's
# state AND on canvas pixels, and the canvas must fit the
# viewport width. The Ruby tab: go-embedded-ruby is fetched
# only once the tab is opened (requests counted), and the
# README example run in Ruby prints go-ndarray's shape and
# values. A missing browser is a failure here, never a skip.
name: playground
on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
env:
GOWORK: "off"
GOTOOLCHAIN: local
jobs:
test:
name: test, coverage, wasm
runs-on: ubuntu-latest
defaults:
run:
working-directory: playground
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: "1.27.4"
cache-dependency-path: playground/go.sum
- uses: actions/setup-node@v7
with:
node-version: "24"
- name: gofmt
run: test -z "$(gofmt -l .)" || { gofmt -l .; exit 1; }
- name: vet (native and js/wasm)
run: go vet ./... && GOOS=js GOARCH=wasm go vet ./...
- name: test (-race)
run: go test -race -count=1 ./...
- name: 100% statement coverage
run: |
go test -count=1 -coverprofile=coverage.out . ./engine ./vm
go tool cover -func=coverage.out | tee coverage.txt | tail -1
bad=$(awk '$NF!="100.0%"' coverage.txt)
[ -z "$bad" ] || { echo "::error::below 100%:"; echo "$bad"; exit 1; }
- name: engine suite as WebAssembly (node)
run: GOOS=js GOARCH=wasm go test -count=1 -v -run 'TestHelperGoroutines|TestOperations|TestErrors|TestLayout' -exec="$(go env GOROOT)/lib/wasm/go_js_wasm_exec" ./engine
- name: wasm build and size
run: |
GOOS=js GOARCH=wasm go build -trimpath -o /tmp/playground.wasm ./cmd/playground-wasm
raw=$(stat -c %s /tmp/playground.wasm); gz=$(gzip -9 -c /tmp/playground.wasm | wc -c)
echo "playground.wasm: $raw bytes, $gz gzipped" | tee -a "$GITHUB_STEP_SUMMARY"
ui-guards:
name: mvvmlint + bricolint
runs-on: ubuntu-latest
defaults:
run:
working-directory: playground
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: "1.27.4"
cache-dependency-path: playground/go.sum
- name: install the guards
run: |
go install github.com/go-widgets/mvvmlint/cmd/mvvmlint@latest
go install github.com/go-widgets/bricolint/cmd/bricolint@v0.1.0
- name: MVVM only (mvvmlint)
run: go vet -vettool="$(go env GOPATH)/bin/mvvmlint" ./...
- name: no hand-drawn UI (bricolint)
run: go vet -vettool="$(go env GOPATH)/bin/bricolint" ./...
- name: negative controls (each guard must bite)
run: BRICOLINT="$(go env GOPATH)/bin/bricolint" MVVMLINT="$(go env GOPATH)/bin/mvvmlint" bash hack/lint-negative-controls.sh
browser-proof:
name: browser proof (headless Chrome)
runs-on: ubuntu-latest
defaults:
run:
working-directory: playground
env:
PLAYGROUND_REQUIRE_BROWSER: "1"
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: "1.27.4"
cache-dependency-path: |
playground/go.sum
playground/rubywasm/go.sum
- uses: actions/setup-node@v7
with:
node-version: "24"
- uses: peaceiris/actions-hugo@v3
with:
hugo-version: "0.169.0"
extended: true
- name: install headless Chrome
id: chrome
uses: browser-actions/setup-chrome@48ad923757ca74d66703209fe939badbdf80f2f4 # v2.2.0
with:
chrome-version: stable
install-dependencies: true
- name: install puppeteer-core
run: npm install --no-save --prefix "${{ runner.temp }}/pptr" puppeteer-core@24.43.1
# The Ruby tab's interpreter, built as the deploy builds it, once for both
# Ruby checks below.
- name: build go-embedded-ruby (js/wasm)
working-directory: playground/rubywasm
run: |
GOOS=js GOARCH=wasm go build -tags rbgo_core -trimpath -ldflags "-s -w" -o "$RUNNER_TEMP/rbgo.wasm" github.com/go-embedded-ruby/ruby/cmd/wasm
raw=$(stat -c %s "$RUNNER_TEMP/rbgo.wasm"); gz=$(gzip -9 -c "$RUNNER_TEMP/rbgo.wasm" | wc -c)
echo "rbgo.wasm ($(go list -m -f '{{.Version}}' github.com/go-embedded-ruby/ruby)): $raw bytes, $gz gzipped" | tee -a "$GITHUB_STEP_SUMMARY"
- name: run the proof
env:
CHROME: ${{ steps.chrome.outputs.chrome-path }}
PLAYGROUND_NODE_PATH: ${{ runner.temp }}/pptr/node_modules
PLAYGROUND_CAPTURE_DIR: ${{ runner.temp }}/captures
PLAYGROUND_RUBY_WASM: ${{ runner.temp }}/rbgo.wasm
# TestRubyAgreesWithGo runs every operation's Ruby program on the
# interpreter. The proof downloads its ~23 MB twice in Chrome: give the
# run more than go test's 10 minutes.
run: go test -count=1 -timeout 30m -v -run 'TestBrowserProof|TestRubyAgreesWithGo' . ./engine
- name: keep the screenshots
if: always()
uses: actions/upload-artifact@v7
with:
name: playground-captures
path: ${{ runner.temp }}/captures
if-no-files-found: ignore