Skip to content

Commit 5e1b1db

Browse files
committed
Add GitHub Actions CI/CD, E2E tests, and Pages deployment
This commit adds comprehensive automation and testing infrastructure: ## GitHub Actions Workflows ### CI Pipeline (.github/workflows/ci.yml) - **Format Check**: Ensures all Go code is properly formatted - **Lint**: Runs golangci-lint with comprehensive checks - **Test**: Executes unit tests with race detection and coverage - **Build**: Compiles CLI tool and validates code generation - **Build WASM**: Builds WebAssembly examples to verify end-to-end ### E2E Testing (.github/workflows/e2e.yml) - **Playwright Tests**: Browser automation testing - Validates generated WASM code works correctly in browsers - Tests user interactions (input, counter updates) - Runs on every push and PR ### GitHub Pages (.github/workflows/pages.yml) - Automatically deploys examples to GitHub Pages - Builds WASM for all examples - Creates index page with links to live demos - Triggered on main branch pushes ## Playwright E2E Tests Counter example tests (examples/counter/counter.spec.js): - ✅ Displays initial counter value - ✅ Updates counter when input changes - ✅ Handles multiple value changes - ✅ Validates counter text format Test infrastructure: - playwright.config.js - Test configuration - package.json - Dependencies and scripts - Automatic server startup during tests ## Updated Counter Example Enhanced interactive counter: - Number input field with styling - Real-time counter updates via JavaScript bridge - Improved CSS with modern design - Accessible and responsive layout Component updates: - Added Class() prop support for styling - Multiple nested components (Div, Span, Input) - ID() prop for DOM element targeting - Type(), Placeholder(), Value() props for input ## Configuration Files .gitignore: - Excludes generated files (*_gen.go) - Ignores build artifacts (*.wasm, wasm_exec.js) - Node modules and test results - IDE and OS-specific files .golangci.yml: - Comprehensive linter configuration - Excludes generated files from linting - Enables recommended linters - 5-minute timeout for complex projects ## Documentation examples/counter/README.md: - Build instructions - Testing guide - How it works explanation - Component breakdown All workflows tested and ready to run on GitHub!
1 parent b39c48c commit 5e1b1db

12 files changed

Lines changed: 725 additions & 37 deletions

File tree

.github/workflows/ci.yml

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

.github/workflows/e2e.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: E2E Tests
2+
3+
on:
4+
push:
5+
branches: [ main, claude/* ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
playwright:
11+
name: Playwright Tests
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v5
18+
with:
19+
go-version: '1.21'
20+
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '20'
25+
26+
- name: Build CLI
27+
run: go build -o guix ./cmd/guix
28+
29+
- name: Generate and build counter example
30+
run: |
31+
./guix generate -p examples/counter
32+
cd examples/counter
33+
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" .
34+
GOOS=js GOARCH=wasm go build -o main.wasm .
35+
36+
- name: Install Playwright
37+
working-directory: examples/counter
38+
run: |
39+
npm init -y
40+
npm install -D @playwright/test
41+
npx playwright install --with-deps chromium
42+
43+
- name: Run Playwright tests
44+
working-directory: examples/counter
45+
run: npx playwright test
46+
47+
- name: Upload test results
48+
if: always()
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: playwright-results
52+
path: examples/counter/test-results/
53+
retention-days: 7

.github/workflows/pages.yml

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

.gitignore

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Binaries
2+
guix
3+
*.exe
4+
*.exe~
5+
*.dll
6+
*.so
7+
*.dylib
8+
*.test
9+
*.out
10+
11+
# Go workspace file
12+
go.work
13+
14+
# Build artifacts
15+
*.wasm
16+
wasm_exec.js
17+
main.wasm
18+
19+
# Generated files
20+
*_gen.go
21+
22+
# Cache
23+
.guix/
24+
*.cache
25+
26+
# IDE
27+
.vscode/
28+
.idea/
29+
*.swp
30+
*.swo
31+
*~
32+
33+
# OS
34+
.DS_Store
35+
Thumbs.db
36+
37+
# Node
38+
node_modules/
39+
package-lock.json
40+
npm-debug.log*
41+
yarn-debug.log*
42+
yarn-error.log*
43+
44+
# Playwright
45+
test-results/
46+
playwright-report/
47+
playwright/.cache/
48+
49+
# Coverage
50+
coverage.txt
51+
*.coverprofile

0 commit comments

Comments
 (0)