-
Notifications
You must be signed in to change notification settings - Fork 0
201 lines (167 loc) · 5.24 KB
/
Copy pathci.yml
File metadata and controls
201 lines (167 loc) · 5.24 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
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
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
format:
name: Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
- name: Check formatting
run: |
if [ -n "$(gofmt -l .)" ]; then
echo "Go files must be formatted with gofmt. Please run:"
echo " gofmt -w ."
gofmt -l .
exit 1
fi
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
- name: golangci-lint
uses: golangci/golangci-lint-action@v7
with:
version: v2.6.2
args: --timeout=5m ./cmd/... ./internal/... ./pkg/ast/... ./pkg/parser/... ./pkg/codegen/...
- name: golangci-lint (WASM)
uses: golangci/golangci-lint-action@v7
with:
version: v2.6.2
args: --timeout=5m ./examples/webgpu-chart/...
env:
GOOS: js
GOARCH: wasm
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
- name: Download dependencies
run: go mod download
- name: Run tests
run: |
# Test non-WASM packages (exclude runtime and examples which use syscall/js)
go test -v -race -coverprofile=coverage.txt -covermode=atomic \
./cmd/... \
./internal/... \
./pkg/ast/... \
./pkg/parser/... \
./pkg/codegen/...
- name: Upload coverage
uses: codecov/codecov-action@v4
with:
file: ./coverage.txt
fail_ci_if_error: false
test-wasm:
name: Test WASM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Download dependencies
run: go mod download
- name: Run WASM tests
working-directory: examples/webgpu-chart
run: |
echo "Running WASM tests for webgpu-chart example..."
# Use Go's WASM test runner
GOROOT="$(go env GOROOT)"
if [ -f "$GOROOT/lib/wasm/go_js_wasm_exec" ]; then
EXEC_PATH="$GOROOT/lib/wasm/go_js_wasm_exec"
elif [ -f "$GOROOT/misc/wasm/go_js_wasm_exec" ]; then
EXEC_PATH="$GOROOT/misc/wasm/go_js_wasm_exec"
else
echo "Error: go_js_wasm_exec not found"
exit 1
fi
echo "Using test runner: $EXEC_PATH"
GOOS=js GOARCH=wasm go test -v -exec="$EXEC_PATH" ./...
- name: Verify test coverage
run: |
# Count test functions in WASM test files
TEST_COUNT=$(grep -r "^func Test" examples/webgpu-chart/*_test.go | wc -l)
echo "Found $TEST_COUNT test functions"
if [ "$TEST_COUNT" -lt 10 ]; then
echo "Warning: Expected at least 10 test functions, found $TEST_COUNT"
exit 1
fi
echo "✓ Test coverage verification passed"
build:
name: Build CLI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
- name: Build CLI
run: go build -v -o guix ./cmd/guix
- name: Test CLI
run: |
./guix generate -p examples/counter --verbose
if [ ! -f examples/counter/counter_gen.go ]; then
echo "Failed to generate counter example"
exit 1
fi
build-wasm:
name: Build WASM Examples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25'
- name: Build CLI
run: go build -o guix ./cmd/guix
- name: Generate components
run: ./guix generate -p examples/counter
- name: Copy wasm_exec.js
run: |
GOROOT="$(go env GOROOT)"
# Try lib/wasm first (Go 1.24+), then misc/wasm (older versions)
if [ -f "$GOROOT/lib/wasm/wasm_exec.js" ]; then
cp "$GOROOT/lib/wasm/wasm_exec.js" examples/counter/
elif [ -f "$GOROOT/misc/wasm/wasm_exec.js" ]; then
cp "$GOROOT/misc/wasm/wasm_exec.js" examples/counter/
else
echo "wasm_exec.js not found in GOROOT, downloading from GitHub"
curl -o examples/counter/wasm_exec.js https://raw.githubusercontent.com/golang/go/go1.25.0/lib/wasm/wasm_exec.js
fi
- name: Build WASM
working-directory: examples/counter
run: GOOS=js GOARCH=wasm go build -o main.wasm .
- name: Verify WASM build
run: |
if [ ! -f examples/counter/main.wasm ]; then
echo "WASM build failed"
exit 1
fi
echo "WASM size: $(du -h examples/counter/main.wasm)"