Replace the Woodpecker pipelines with Actions workflows under `.github/workflows`, matching the conventions the other migrated repositories now use (butterrobot, smtp2shoutrrr, terraria-companion, dharma). ## Workflows - Jobs run on `ubuntu-latest`, answered with the catthehacker act image — no `ci-base` container. - Short `uses:` resolves against github.com, so every action carries its real name: `goreleaser/goreleaser-action`, `oven-sh/setup-bun`, `docker/setup-qemu-action`, `docker/setup-buildx-action`. - The act image carries none of the tooling `ci-base` provided, so each job installs what it calls: `make` everywhere, `build-essential` for the CGO test job, `upx-ucl` for goreleaser's `upx` block, bun for the webapp build, goreleaser itself for `make build`. - `e2e` gets a Docker-in-Docker service so testcontainers can resolve its mapped ports from inside the job container; Playwright installs with `--with-deps` now that the job has sudo. ## Supporting changes - `Makefile` drops unused variables and adopts a self-documenting `help` target. - `.goreleaser.yml` keeps `dockers_v2` for the multi-platform image. - `Containerfile` moves to Alpine 3.23; nfpm description fixed. - e2e: shared Docker network so link creation reaches the test web server, `mattn/go-sqlite3` added to the e2e module, `all:dist` embed directive so dot-files ship in the webapp bundle. Reviewed-on: #1
74 lines
1.7 KiB
Go
74 lines
1.7 KiB
Go
package e2eutil
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/mxschmitt/playwright-go"
|
|
)
|
|
|
|
// NewPlaywright initializes Playwright and returns a browser instance.
|
|
// It automatically registers cleanup handlers for test teardown.
|
|
func NewPlaywright(t *testing.T) (*playwright.Playwright, playwright.Browser, error) {
|
|
t.Helper()
|
|
|
|
// Run Playwright
|
|
pw, err := playwright.Run()
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
|
|
// Register cleanup for Playwright
|
|
t.Cleanup(func() {
|
|
if err := pw.Stop(); err != nil {
|
|
t.Logf("Failed to stop Playwright: %v", err)
|
|
}
|
|
})
|
|
|
|
// Launch Chromium browser with headless options
|
|
browser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
|
|
Headless: playwright.Bool(true),
|
|
Args: []string{
|
|
"--disable-gpu",
|
|
"--disable-dev-shm-usage",
|
|
"--no-sandbox",
|
|
},
|
|
})
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
|
|
// Register cleanup for browser
|
|
t.Cleanup(func() {
|
|
if err := browser.Close(); err != nil {
|
|
t.Logf("Failed to close browser: %v", err)
|
|
}
|
|
})
|
|
|
|
return pw, browser, nil
|
|
}
|
|
|
|
// NewBrowserContext creates a new browser context with a standard viewport.
|
|
// It automatically registers cleanup handlers for test teardown.
|
|
func NewBrowserContext(browser playwright.Browser, t *testing.T) (playwright.BrowserContext, error) {
|
|
t.Helper()
|
|
|
|
// Create browser context with standard viewport
|
|
context, err := browser.NewContext(playwright.BrowserNewContextOptions{
|
|
Viewport: &playwright.Size{
|
|
Width: 1280,
|
|
Height: 720,
|
|
},
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
// Register cleanup
|
|
t.Cleanup(func() {
|
|
if err := context.Close(); err != nil {
|
|
t.Logf("Failed to close browser context: %v", err)
|
|
}
|
|
})
|
|
|
|
return context, nil
|
|
}
|