-
Notifications
You must be signed in to change notification settings - Fork 0
141 lines (118 loc) · 3.53 KB
/
Copy pathci.yml
File metadata and controls
141 lines (118 loc) · 3.53 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
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/...
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
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)"