`matcha new --runtime edge` scaffolds a Worker: `nodejs_compat`, `edgeHandler` as the default export, and wrangler's `[assets]` serving `./public` so `/` is the same page as on the other three runtimes and `/zen` the same stream from the worker. `matcha run` is `wrangler dev`, which is real workerd, so edge stops being a deploy-only target. Runtime detection puts `wrangler.toml` ahead of `package.json`, since an edge project has both, and the graph resolves under node — `src/app.ts` imports core, never `edgeHandler`. Getting there turned up a core defect, filed as Green-Tea/core#93: the npm ESM build cannot load on workerd at all. tsup's `createRequire(import.meta.url)` banner runs at module scope and `import.meta.url` is undefined there, so `@green-tea/core/edge` throws before any of its own code runs — while `src/node-require.ts` is written precisely to make that lazy and survivable. core's own edge test cannot see it: it bundles `src/`, so `dist/` is the one artifact users install and the one nothing exercises. The scaffold installs from JSR, which publishes source with no banner and boots clean; the `.npmrc` says why and links the issue, and both it and the alias can go once it is fixed. `matcha doctor` reports the misconfigurations that fail confusingly rather than loudly: `experimentalDecorators` missing, which turns every `@Route` into a syntax error blaming the decorator; a core pin that cannot resolve or that does not match what is installed; an entry that does not export `app`; and `@Ws` or multipart routes whose lazy-loaded peer dependency is absent, which compile and then fail at the first request. Every check is a file read — no runtime spawned, nothing fetched — so it works before the project installs. It reads the installed version from the package's own manifest rather than core's exported `VERSION`, which is stale in the published artifact (Green-Tea/core#92) and would give the wrong answer to the one check that exists to catch a wrong version. The starter smoke and the CI matrix gained edge as a fourth runtime. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012x1UPw987zNSxjH2DxHy2C
78 lines
3.0 KiB
YAML
78 lines
3.0 KiB
YAML
name: CI
|
|
|
|
# Rust gate. Lives in .github/workflows so both Gitea and GitHub run it.
|
|
on:
|
|
pull_request:
|
|
branches: [develop, main]
|
|
push:
|
|
branches: [develop, main]
|
|
# Weekly, so a core release that breaks the starter or leaves the pin behind
|
|
# shows up here rather than in somebody's `matcha new`.
|
|
schedule:
|
|
- cron: '0 6 * * 1'
|
|
|
|
jobs:
|
|
check:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install Rust
|
|
run: |
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
|
|
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
|
- name: Add clippy + rustfmt
|
|
run: rustup component add clippy rustfmt
|
|
- run: cargo fmt --check
|
|
- run: cargo clippy --all-targets -- -D warnings
|
|
- run: cargo test --locked
|
|
|
|
# `cargo test` proves the CLI writes the files it means to write. It cannot
|
|
# prove those files describe a project the current @green-tea/core will run —
|
|
# which is how the templates sat two core releases behind for two months with
|
|
# a green build the whole time. This job scaffolds, installs, type-checks,
|
|
# boots and introspects a real starter, per runtime.
|
|
starter:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
runtime: [node, deno, bun, edge]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install Rust
|
|
run: |
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
|
|
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
|
- run: cargo build
|
|
- name: Install Deno
|
|
if: matrix.runtime == 'deno'
|
|
run: |
|
|
curl -fsSL https://deno.land/install.sh | sh -s -- --yes
|
|
echo "$HOME/.deno/bin" >> "$GITHUB_PATH"
|
|
- name: Install Bun
|
|
if: matrix.runtime == 'bun'
|
|
run: |
|
|
curl -fsSL https://bun.sh/install | bash
|
|
echo "$HOME/.bun/bin" >> "$GITHUB_PATH"
|
|
- run: scripts/starter-smoke.sh ${{ matrix.runtime }}
|
|
|
|
# The pin in src/template.rs is exact because core is prerelease-only and no
|
|
# caret range can move off its first matching prerelease. Exact pins go stale
|
|
# silently, so this is the thing that notices. Scheduled only: a core release
|
|
# should nag on Monday, not redden an unrelated pull request.
|
|
core-freshness:
|
|
if: github.event_name == 'schedule'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Compare the scaffold pin against the beta dist-tag
|
|
run: |
|
|
pinned=$(grep -oP 'CORE_VERSION: &str = "\K[^"]+' src/template.rs)
|
|
latest=$(npm view @green-tea/core dist-tags.beta)
|
|
echo "pinned=$pinned latest=$latest"
|
|
if [ "$pinned" != "$latest" ]; then
|
|
echo "::error::matcha scaffolds @green-tea/core@$pinned but the beta tag is $latest."
|
|
echo "Bump CORE_VERSION in src/template.rs and let the starter job prove it still boots."
|
|
exit 1
|
|
fi
|