Add calculator example with channel-based state management #66
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: E2E Tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| playwright: | |
| name: Playwright Tests | |
| 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: Build CLI | |
| run: go build -o guix ./cmd/guix | |
| - name: Generate and build counter example | |
| run: | | |
| ./guix generate -p examples/counter | |
| cd examples/counter | |
| # Copy wasm_exec.js from Go installation | |
| 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" . | |
| elif [ -f "$GOROOT/misc/wasm/wasm_exec.js" ]; then | |
| cp "$GOROOT/misc/wasm/wasm_exec.js" . | |
| else | |
| echo "wasm_exec.js not found in GOROOT, downloading from GitHub" | |
| curl -o wasm_exec.js https://raw.githubusercontent.com/golang/go/go1.25.0/lib/wasm/wasm_exec.js | |
| fi | |
| GOOS=js GOARCH=wasm go build -o main.wasm . | |
| echo "Files after build:" | |
| ls -lah *.{html,js,wasm,go} 2>/dev/null || ls -lah | |
| - name: Install Playwright | |
| working-directory: examples/counter | |
| run: | | |
| npm init -y | |
| npm install -D @playwright/test | |
| npx playwright install --with-deps chromium | |
| - name: Run Playwright tests | |
| working-directory: examples/counter | |
| run: npx playwright test | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-results | |
| path: examples/counter/test-results/ | |
| retention-days: 7 | |
| chromedp: | |
| name: Calculator E2E Tests (chromedp) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.25' | |
| - name: Install Chrome | |
| run: | | |
| wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - | |
| sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' | |
| sudo apt-get update | |
| sudo apt-get install -y google-chrome-stable | |
| - name: Build CLI | |
| run: go build -o guix ./cmd/guix | |
| - name: Generate and build calculator example | |
| run: | | |
| ./guix generate -p examples/calculator | |
| cd examples/calculator | |
| # Copy wasm_exec.js from Go installation | |
| GOROOT="$(go env GOROOT)" | |
| if [ -f "$GOROOT/lib/wasm/wasm_exec.js" ]; then | |
| cp "$GOROOT/lib/wasm/wasm_exec.js" . | |
| elif [ -f "$GOROOT/misc/wasm/wasm_exec.js" ]; then | |
| cp "$GOROOT/misc/wasm/wasm_exec.js" . | |
| else | |
| echo "wasm_exec.js not found in GOROOT, downloading from GitHub" | |
| curl -o wasm_exec.js https://raw.githubusercontent.com/golang/go/go1.25.0/lib/wasm/wasm_exec.js | |
| fi | |
| GOOS=js GOARCH=wasm go build -o calculator.wasm . | |
| echo "Files after build:" | |
| ls -lah *.{html,js,wasm} 2>/dev/null || ls -lah | |
| - name: Run chromedp E2E tests | |
| working-directory: examples/calculator | |
| run: go test -v -tags=e2e -timeout=120s | |
| - name: Upload test logs | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: calculator-e2e-logs | |
| path: examples/calculator/*.log | |
| retention-days: 7 |