Skip to content

Commit 5d290b0

Browse files
authored
Merge pull request #270 from flyingrobots/wesley-anywhere
feat(host-browser): browser host + browser/deno/bun smokes
2 parents e9ada78 + ace0479 commit 5d290b0

File tree

108 files changed

+3787
-39
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+3787
-39
lines changed

.githooks/pre-push

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,39 @@
11
#!/usr/bin/env bash
2+
# Fast pre-push sanity: run repo-level Bats tests that CI runs in build-test.
3+
# Skip in CI or when SKIP_BATS_PREPUSH=1 is set.
24
set -euo pipefail
35

4-
echo "🔎 Preflight: running repository checks..."
5-
node scripts/preflight.mjs
6-
echo "✅ Preflight passed"
7-
8-
if [[ "${WESLEY_SKIP_CLI_TESTS:-0}" != "1" ]]; then
9-
echo "🧪 CLI: running Bats suite..."
10-
pnpm --filter @wesley/cli test
11-
echo "✅ CLI Bats passed"
12-
else
13-
echo "⚠️ CLI Bats skipped (WESLEY_SKIP_CLI_TESTS=1)."
6+
if [[ "${CI:-}" == "true" || "${SKIP_BATS_PREPUSH:-}" == "1" ]]; then
7+
exit 0
148
fi
9+
10+
export BATS_LIB_PATH=packages/wesley-cli/test
11+
export TERM=xterm
12+
export BATS_NO_COLOR=1
13+
14+
# Ensure plugins are present (hard cap to avoid hangs)
15+
timeout 60s bash scripts/setup-bats-plugins.sh || {
16+
echo "[pre-push] Failed to bootstrap Bats plugins (timeout or error)" >&2
17+
exit 1
18+
}
19+
20+
rm -rf test/bats-plugins 2>/dev/null || true
21+
ln -sfn "$PWD/packages/wesley-cli/test/bats-plugins" test/bats-plugins
22+
23+
files=(
24+
test/serve-static-unit.bats
25+
test/serve-static-relative-unit.bats
26+
test/progress-dry-run.bats
27+
test/progress-safety.bats
28+
test/ci-browser-smoke.bats
29+
test/ci-pkg-core.bats
30+
test/ci-pkg-host-bun.bats
31+
test/ci-workflows.bats
32+
test/deno-host-webcrypto-guard.bats
33+
)
34+
35+
for f in "${files[@]}"; do
36+
echo "[pre-push] bats -t $f"
37+
timeout 3m bats -t "$f"
38+
done
39+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: "Install Bats and JQ"
2+
description: "Installs bats and jq on Ubuntu runners"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: apt-get update
7+
shell: bash
8+
run: sudo apt-get update
9+
- name: install bats and jq
10+
shell: bash
11+
run: sudo apt-get install -y bats jq
12+
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Browser Smoke
2+
3+
on:
4+
# Avoid double-runs on PRs from same repo by running push only on main
5+
push:
6+
branches: ["main"]
7+
pull_request:
8+
branches: ["**"]
9+
workflow_dispatch:
10+
inputs:
11+
note:
12+
description: Optional note for manual run
13+
required: false
14+
15+
concurrency:
16+
group: browser-smoke-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
browser-smoke:
21+
runs-on: ubuntu-latest
22+
timeout-minutes: 10
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Setup pnpm
28+
uses: pnpm/action-setup@v4
29+
with:
30+
version: 9.15.9
31+
32+
- name: Setup Node
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: 20
36+
cache: 'pnpm'
37+
38+
- name: Enable corepack (pnpm)
39+
run: corepack enable
40+
41+
- name: Install deps (frozen)
42+
run: pnpm install --frozen-lockfile
43+
44+
- name: Preflight
45+
run: pnpm run -s preflight
46+
47+
- name: Cache Playwright browsers
48+
uses: actions/cache@v4
49+
with:
50+
path: ~/.cache/ms-playwright
51+
key: playwright-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
52+
restore-keys: |
53+
playwright-${{ runner.os }}-
54+
55+
- name: Set Playwright env
56+
run: echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/ms-playwright" >> $GITHUB_ENV
57+
58+
- name: Install bats
59+
uses: ./.github/actions/install-bats
60+
61+
- name: Install Playwright browsers (workspace)
62+
run: pnpm exec playwright install chromium
63+
64+
- name: Run browser host contracts (Bats → Playwright)
65+
env:
66+
BATS_LIB_PATH: packages/wesley-cli/test
67+
TERM: xterm
68+
BATS_NO_COLOR: "1"
69+
run: |
70+
# Ensure Bats can resolve 'load "bats-plugins/..."' relative to the test dir
71+
rm -rf test/hosts/bats-plugins || true
72+
ln -sfn "$PWD/packages/wesley-cli/test/bats-plugins" test/hosts/bats-plugins
73+
timeout 2m bash scripts/setup-bats-plugins.sh
74+
OUT_JSON="$RUNNER_TEMP/host-contracts.json" HOST=browser bats -t test/hosts/host-contracts.bats
75+
76+
- name: Serve-static traversal e2e (no browser)
77+
env:
78+
BATS_LIB_PATH: packages/wesley-cli/test
79+
TERM: xterm
80+
BATS_NO_COLOR: "1"
81+
run: |
82+
# Repo-level plugin resolution
83+
rm -rf test/bats-plugins || true
84+
ln -sfn "$PWD/packages/wesley-cli/test/bats-plugins" test/bats-plugins
85+
timeout 2m bats -t test/serve-static-e2e.bats
86+
87+
- name: Upload host-contracts JSON artifact
88+
if: always()
89+
uses: actions/upload-artifact@v4
90+
with:
91+
name: browser-host-contracts
92+
path: ${{ runner.temp }}/host-contracts.json
93+
if-no-files-found: warn

.github/workflows/ci.yml

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on: [push, pull_request]
44
jobs:
55
build-test:
66
runs-on: ubuntu-latest
7+
timeout-minutes: 20
78
services:
89
postgres:
910
image: postgres:15
@@ -33,12 +34,8 @@ jobs:
3334
run: git diff --exit-code -- pnpm-lock.yaml
3435

3536
# Install Bats for CLI tests executed in this workflow
36-
- name: Install Bats (Ubuntu)
37-
run: |
38-
curl -LO https://github.com/bats-core/bats-core/archive/v1.12.0.tar.gz
39-
tar -xzf v1.12.0.tar.gz
40-
sudo ./bats-core-1.12.0/install.sh /usr/local
41-
echo "/usr/local/bin" >> $GITHUB_PATH
37+
- name: Install Bats
38+
uses: ./.github/actions/install-bats
4239

4340
# Spin local PG via docker-compose init scripts (extensions)
4441
- run: psql -h localhost -U postgres -c "select 1" || true
@@ -52,3 +49,53 @@ jobs:
5249
# (See .github/workflows/cli-tests.yml and cli-quick.yml)
5350

5451
- run: node packages/wesley-host-node/bin/wesley.mjs generate --schema test/fixtures/examples/ecommerce.graphql --allow-dirty
52+
53+
- name: Detect changes for repo Bats tests (no servers)
54+
id: changelog
55+
env:
56+
EVENT: ${{ github.event_name }}
57+
BASE_REF: ${{ github.event.pull_request.base.sha }}
58+
BEFORE: ${{ github.event.before }}
59+
SHA: ${{ github.sha }}
60+
run: |
61+
set -euo pipefail
62+
RANGE="${BEFORE}..${SHA}"
63+
if [ "$EVENT" = "pull_request" ] && [ -n "${BASE_REF}" ]; then
64+
RANGE="${BASE_REF}..${SHA}"
65+
fi
66+
echo "Diff range: $RANGE"
67+
CHANGED=$(git diff --name-only "$RANGE" || true)
68+
echo "$CHANGED" | sed 's/^/ - /'
69+
NEED=false
70+
# Trigger only on unit/serverless tests; exclude browser-contracts and serve-static e2e
71+
echo "$CHANGED" | grep -E -q '^(scripts/serve-static\.mjs|test/serve-static-(unit|relative-unit)\.bats|scripts/compute-progress\.mjs|test/progress-|test/ci-|test/deno-host-webcrypto-guard\.bats)' && NEED=true || true
72+
echo "RUN_BATS=$NEED" >> $GITHUB_ENV
73+
74+
- name: Repo Bats tests (unit/progress/ci checks only)
75+
if: ${{ env.RUN_BATS == 'true' }}
76+
env:
77+
BATS_LIB_PATH: packages/wesley-cli/test
78+
TERM: xterm
79+
BATS_NO_COLOR: "1"
80+
run: |
81+
# Ensure tests that use `load 'bats-plugins/…'` from the repo-level
82+
# `test/` directory can resolve plugins.
83+
timeout 2m bash scripts/setup-bats-plugins.sh
84+
rm -rf test/bats-plugins || true
85+
ln -sfn "$PWD/packages/wesley-cli/test/bats-plugins" test/bats-plugins
86+
set -euo pipefail
87+
files=(
88+
test/serve-static-unit.bats
89+
test/serve-static-relative-unit.bats
90+
test/progress-dry-run.bats
91+
test/progress-safety.bats
92+
test/ci-browser-smoke.bats
93+
test/ci-pkg-core.bats
94+
test/ci-pkg-host-bun.bats
95+
test/ci-workflows.bats
96+
test/deno-host-webcrypto-guard.bats
97+
)
98+
for f in "${files[@]}"; do
99+
echo "Running Bats: $f"
100+
timeout 3m bats -t "$f"
101+
done

.github/workflows/install-bats.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: install-bats
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
install:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Install bats and jq
11+
run: |
12+
sudo apt-get update
13+
sudo apt-get install -y bats jq

.github/workflows/pkg-cli.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: pkg-cli
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
paths:
7+
- 'packages/wesley-cli/**'
8+
- 'pnpm-lock.yaml'
9+
- 'package.json'
10+
pull_request:
11+
branches: ["**"]
12+
paths:
13+
- 'packages/wesley-cli/**'
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 15
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: pnpm/action-setup@v4
22+
with:
23+
version: 9.15.9
24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version: 20
27+
- name: Enable corepack (pnpm)
28+
run: corepack enable
29+
- name: Install deps
30+
run: pnpm install --frozen-lockfile
31+
- name: @wesley/cli tests (Bats)
32+
run: pnpm --filter @wesley/cli test

.github/workflows/pkg-core.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: pkg-core
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
paths:
7+
- 'packages/wesley-core/**'
8+
- 'pnpm-lock.yaml'
9+
- 'package.json'
10+
pull_request:
11+
branches: ["**"]
12+
paths:
13+
- 'packages/wesley-core/**'
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 10
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: pnpm/action-setup@v4
22+
with:
23+
version: 9.15.9
24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version: 20
27+
- name: Enable corepack (pnpm)
28+
run: corepack enable
29+
- name: Install deps
30+
run: pnpm install --frozen-lockfile
31+
- name: @wesley/core tests (coverage)
32+
# Quote the command: '@' can confuse YAML if unquoted
33+
run: "pnpm --filter @wesley/core test:coverage || pnpm --filter @wesley/core test"
34+
- name: Upload core coverage (if present)
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: core-coverage
38+
path: packages/wesley-core/coverage/**
39+
if-no-files-found: ignore
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: pkg-generator-js
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
paths:
7+
- 'packages/wesley-generator-js/**'
8+
- 'pnpm-lock.yaml'
9+
- 'package.json'
10+
pull_request:
11+
branches: ["**"]
12+
paths:
13+
- 'packages/wesley-generator-js/**'
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 10
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: pnpm/action-setup@v4
22+
with:
23+
version: 9.15.9
24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version: 20
27+
- name: Enable corepack (pnpm)
28+
run: corepack enable
29+
- name: Install deps
30+
run: pnpm install --frozen-lockfile
31+
- name: @wesley/generator-js tests
32+
run: pnpm --filter @wesley/generator-js test
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: pkg-generator-supabase
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
paths:
7+
- 'packages/wesley-generator-supabase/**'
8+
- 'pnpm-lock.yaml'
9+
- 'package.json'
10+
pull_request:
11+
branches: ["**"]
12+
paths:
13+
- 'packages/wesley-generator-supabase/**'
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 10
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: pnpm/action-setup@v4
22+
with:
23+
version: 9.15.9
24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version: 20
27+
- name: Enable corepack (pnpm)
28+
run: corepack enable
29+
- name: Install deps
30+
run: pnpm install --frozen-lockfile
31+
- name: @wesley/generator-supabase tests
32+
run: pnpm --filter @wesley/generator-supabase test

0 commit comments

Comments
 (0)