Skip to content

Commit 837056e

Browse files
authored
Merge pull request #1 from gaarutyunov/claude/build-guix-wasm-transpiler-01QhFauKDYD1k8srXxDx8td9
Implement complete Guix transpiler: Go-based UI language to WebAssembly
2 parents bda6ecf + 268b402 commit 837056e

34 files changed

Lines changed: 6734 additions & 2 deletions

.github/workflows/ci.yml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
format:
13+
name: Format Check
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v5
20+
with:
21+
go-version: '1.25'
22+
23+
- name: Check formatting
24+
run: |
25+
if [ -n "$(gofmt -l .)" ]; then
26+
echo "Go files must be formatted with gofmt. Please run:"
27+
echo " gofmt -w ."
28+
gofmt -l .
29+
exit 1
30+
fi
31+
32+
lint:
33+
name: Lint
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- name: Set up Go
39+
uses: actions/setup-go@v5
40+
with:
41+
go-version: '1.25'
42+
43+
- name: golangci-lint
44+
uses: golangci/golangci-lint-action@v7
45+
with:
46+
version: v2.6.2
47+
args: --timeout=5m ./cmd/... ./internal/... ./pkg/ast/... ./pkg/parser/... ./pkg/codegen/...
48+
49+
test:
50+
name: Test
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- name: Set up Go
56+
uses: actions/setup-go@v5
57+
with:
58+
go-version: '1.25'
59+
60+
- name: Download dependencies
61+
run: go mod download
62+
63+
- name: Run tests
64+
run: |
65+
# Test non-WASM packages (exclude runtime and examples which use syscall/js)
66+
go test -v -race -coverprofile=coverage.txt -covermode=atomic \
67+
./cmd/... \
68+
./internal/... \
69+
./pkg/ast/... \
70+
./pkg/parser/... \
71+
./pkg/codegen/...
72+
73+
- name: Upload coverage
74+
uses: codecov/codecov-action@v4
75+
with:
76+
file: ./coverage.txt
77+
fail_ci_if_error: false
78+
79+
build:
80+
name: Build CLI
81+
runs-on: ubuntu-latest
82+
steps:
83+
- uses: actions/checkout@v4
84+
85+
- name: Set up Go
86+
uses: actions/setup-go@v5
87+
with:
88+
go-version: '1.25'
89+
90+
- name: Build CLI
91+
run: go build -v -o guix ./cmd/guix
92+
93+
- name: Test CLI
94+
run: |
95+
./guix generate -p examples/counter --verbose
96+
if [ ! -f examples/counter/counter_gen.go ]; then
97+
echo "Failed to generate counter example"
98+
exit 1
99+
fi
100+
101+
build-wasm:
102+
name: Build WASM Examples
103+
runs-on: ubuntu-latest
104+
steps:
105+
- uses: actions/checkout@v4
106+
107+
- name: Set up Go
108+
uses: actions/setup-go@v5
109+
with:
110+
go-version: '1.25'
111+
112+
- name: Build CLI
113+
run: go build -o guix ./cmd/guix
114+
115+
- name: Generate components
116+
run: ./guix generate -p examples/counter
117+
118+
- name: Copy wasm_exec.js
119+
run: |
120+
GOROOT="$(go env GOROOT)"
121+
# Try lib/wasm first (Go 1.24+), then misc/wasm (older versions)
122+
if [ -f "$GOROOT/lib/wasm/wasm_exec.js" ]; then
123+
cp "$GOROOT/lib/wasm/wasm_exec.js" examples/counter/
124+
elif [ -f "$GOROOT/misc/wasm/wasm_exec.js" ]; then
125+
cp "$GOROOT/misc/wasm/wasm_exec.js" examples/counter/
126+
else
127+
echo "wasm_exec.js not found in GOROOT, downloading from GitHub"
128+
curl -o examples/counter/wasm_exec.js https://raw.githubusercontent.com/golang/go/go1.25.0/lib/wasm/wasm_exec.js
129+
fi
130+
131+
- name: Build WASM
132+
working-directory: examples/counter
133+
run: GOOS=js GOARCH=wasm go build -o main.wasm .
134+
135+
- name: Verify WASM build
136+
run: |
137+
if [ ! -f examples/counter/main.wasm ]; then
138+
echo "WASM build failed"
139+
exit 1
140+
fi
141+
echo "WASM size: $(du -h examples/counter/main.wasm)"

.github/workflows/e2e.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: E2E Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
playwright:
13+
name: Playwright Tests
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v5
20+
with:
21+
go-version: '1.25'
22+
23+
- name: Set up Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '20'
27+
28+
- name: Build CLI
29+
run: go build -o guix ./cmd/guix
30+
31+
- name: Generate and build counter example
32+
run: |
33+
./guix generate -p examples/counter
34+
cd examples/counter
35+
# Copy wasm_exec.js from Go installation
36+
GOROOT="$(go env GOROOT)"
37+
# Try lib/wasm first (Go 1.24+), then misc/wasm (older versions)
38+
if [ -f "$GOROOT/lib/wasm/wasm_exec.js" ]; then
39+
cp "$GOROOT/lib/wasm/wasm_exec.js" .
40+
elif [ -f "$GOROOT/misc/wasm/wasm_exec.js" ]; then
41+
cp "$GOROOT/misc/wasm/wasm_exec.js" .
42+
else
43+
echo "wasm_exec.js not found in GOROOT, downloading from GitHub"
44+
curl -o wasm_exec.js https://raw.githubusercontent.com/golang/go/go1.25.0/lib/wasm/wasm_exec.js
45+
fi
46+
GOOS=js GOARCH=wasm go build -o main.wasm .
47+
echo "Files after build:"
48+
ls -lah *.{html,js,wasm,go} 2>/dev/null || ls -lah
49+
50+
- name: Install Playwright
51+
working-directory: examples/counter
52+
run: |
53+
npm init -y
54+
npm install -D @playwright/test
55+
npx playwright install --with-deps chromium
56+
57+
- name: Run Playwright tests
58+
working-directory: examples/counter
59+
run: npx playwright test
60+
61+
- name: Upload test results
62+
if: always()
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: playwright-results
66+
path: examples/counter/test-results/
67+
retention-days: 7

.github/workflows/pages.yml

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
concurrency:
15+
group: "pages"
16+
cancel-in-progress: false
17+
18+
jobs:
19+
build:
20+
name: Build Examples
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Set up Go
26+
uses: actions/setup-go@v5
27+
with:
28+
go-version: '1.25'
29+
30+
- name: Build CLI
31+
run: go build -o guix ./cmd/guix
32+
33+
- name: Generate components
34+
run: ./guix generate -p examples/counter
35+
36+
- name: Copy wasm_exec.js
37+
run: |
38+
GOROOT="$(go env GOROOT)"
39+
# Try lib/wasm first (Go 1.24+), then misc/wasm (older versions)
40+
if [ -f "$GOROOT/lib/wasm/wasm_exec.js" ]; then
41+
cp "$GOROOT/lib/wasm/wasm_exec.js" examples/counter/
42+
elif [ -f "$GOROOT/misc/wasm/wasm_exec.js" ]; then
43+
cp "$GOROOT/misc/wasm/wasm_exec.js" examples/counter/
44+
else
45+
echo "wasm_exec.js not found in GOROOT, downloading from GitHub"
46+
curl -o examples/counter/wasm_exec.js https://raw.githubusercontent.com/golang/go/go1.25.0/lib/wasm/wasm_exec.js
47+
fi
48+
49+
- name: Build WASM
50+
working-directory: examples/counter
51+
run: GOOS=js GOARCH=wasm go build -o main.wasm .
52+
53+
- name: Create Pages structure
54+
run: |
55+
mkdir -p _site
56+
mkdir -p _site/counter
57+
cp examples/counter/index.html _site/counter/
58+
cp examples/counter/main.wasm _site/counter/
59+
cp examples/counter/wasm_exec.js _site/counter/
60+
61+
# Create index page with links to examples
62+
cat > _site/index.html << 'EOF'
63+
<!DOCTYPE html>
64+
<html lang="en">
65+
<head>
66+
<meta charset="UTF-8">
67+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
68+
<title>Guix Examples</title>
69+
<style>
70+
body {
71+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
72+
max-width: 800px;
73+
margin: 50px auto;
74+
padding: 20px;
75+
background: #f5f5f5;
76+
}
77+
.container {
78+
background: white;
79+
border-radius: 8px;
80+
padding: 30px;
81+
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
82+
}
83+
h1 { color: #333; margin-top: 0; }
84+
.examples {
85+
list-style: none;
86+
padding: 0;
87+
}
88+
.examples li {
89+
margin: 15px 0;
90+
}
91+
.examples a {
92+
display: block;
93+
padding: 15px;
94+
background: #007bff;
95+
color: white;
96+
text-decoration: none;
97+
border-radius: 4px;
98+
transition: background 0.2s;
99+
}
100+
.examples a:hover {
101+
background: #0056b3;
102+
}
103+
.info {
104+
background: #e3f2fd;
105+
padding: 15px;
106+
border-radius: 4px;
107+
margin: 20px 0;
108+
}
109+
code {
110+
background: #f5f5f5;
111+
padding: 2px 6px;
112+
border-radius: 3px;
113+
font-family: 'Courier New', monospace;
114+
}
115+
</style>
116+
</head>
117+
<body>
118+
<div class="container">
119+
<h1>🚀 Guix Examples</h1>
120+
<p><strong>Guix</strong> - Go-based UI language transpiling to WebAssembly</p>
121+
122+
<div class="info">
123+
<h3>About Guix</h3>
124+
<p>
125+
Guix lets you write UI components in Go-like syntax that compile to WebAssembly.
126+
Features include virtual DOM, reactive state, and type-safe event handling.
127+
</p>
128+
</div>
129+
130+
<h2>Live Examples</h2>
131+
<ul class="examples">
132+
<li>
133+
<a href="./counter/">
134+
<strong>Counter</strong> - Basic component with props and template interpolation
135+
</a>
136+
</li>
137+
</ul>
138+
139+
<div class="info">
140+
<h3>Learn More</h3>
141+
<p>
142+
Visit the <a href="https://github.com/gaarutyunov/guix">GitHub repository</a>
143+
for documentation, source code, and more examples.
144+
</p>
145+
</div>
146+
</div>
147+
</body>
148+
</html>
149+
EOF
150+
151+
- name: Setup Pages
152+
uses: actions/configure-pages@v4
153+
154+
- name: Upload artifact
155+
uses: actions/upload-pages-artifact@v3
156+
with:
157+
path: '_site'
158+
159+
deploy:
160+
name: Deploy to GitHub Pages
161+
environment:
162+
name: github-pages
163+
url: ${{ steps.deployment.outputs.page_url }}
164+
runs-on: ubuntu-latest
165+
needs: build
166+
steps:
167+
- name: Deploy to GitHub Pages
168+
id: deployment
169+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)