Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/calm-workers-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@sveltejs/kit': patch
'@sveltejs/adapter-cloudflare': patch
---

fix: dispose adapter emulators when their lifecycle ends
42 changes: 0 additions & 42 deletions .github/actions/netlify-deploy/action.yml

This file was deleted.

31 changes: 0 additions & 31 deletions .github/actions/platform-test/action.yml

This file was deleted.

40 changes: 0 additions & 40 deletions .github/actions/vercel-deploy/action.yml

This file was deleted.

181 changes: 181 additions & 0 deletions .github/workflows/platform-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
name: Platform Test

on:
workflow_call:
inputs:
sha:
description: 'Commit SHA to test'
required: true
type: string
platform:
description: 'netlify or vercel'
required: true
type: string
variant:
description: 'Name of the test app variant'
required: true
type: string
app:
description: 'Directory of the test app'
required: true
type: string

permissions:
contents: read

env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
APP: packages/adapter-${{ inputs.platform }}/test/apps/${{ inputs.app }}

defaults:
run:
shell: bash

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- &checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.sha }}
persist-credentials: false

# reads the pnpm version from the commit under test: `main` is on v10, `version-3` on v12
- &pnpm
uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0

- &node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 24

- &install
name: Install dependencies
run: pnpm install --frozen-lockfile

# TODO: only adapter-netlify on `main` has a build script, remove this step after the v3 release
- name: Build adapter
env:
PLATFORM: ${{ inputs.platform }}
run: pnpm --filter "@sveltejs/adapter-$PLATFORM" --if-present build

- name: Build test app
working-directory: ${{ env.APP }}
env:
EDGE: ${{ inputs.variant == 'split-edge' }}
run: pnpm build

# the Netlify CLI bundles the functions in the deploy job, which has no `node_modules`
- name: Copy Kit next to the Netlify functions
if: inputs.platform == 'netlify'
run: |
mkdir -p "$APP/.netlify/v1/node_modules/@sveltejs/kit"
cp -r packages/kit/package.json packages/kit/src "$APP/.netlify/v1/node_modules/@sveltejs/kit"

- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ inputs.platform }}-${{ inputs.variant }}
# whichever of these the adapter wrote, relative to the test app
path: |
${{ env.APP }}/build
${{ env.APP }}/.netlify
${{ env.APP }}/.vercel
include-hidden-files: true
if-no-files-found: error
retention-days: 1

deploy:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
environment: '@sveltejs/adapter-${{ inputs.platform }} platform tests'
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ inputs.platform }}-${{ inputs.variant }}

- uses: pnpm/setup@703c52620218391530e48b9e8870d5c0082e1b9b # v2.1.0
with:
version: ^12.0.0
runtime: node@24

- name: Install CLI
env:
CLI: ${{ inputs.platform == 'netlify' && 'netlify-cli' || 'vercel' }}
run: pnpm i -g "$CLI" --allow-build=esbuild --allow-build=netlify-cli

# the secrets are passed as flags and scrubbed from the environment the CLI bundles functions in
- name: Deploy to Netlify
if: inputs.platform == 'netlify'
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_TOKEN }}
NETLIFY_PROJECT_ID: ${{ inputs.variant == 'basic' && secrets.NETLIFY_PROJECT_ID_BASIC || inputs.variant == 'edge' && secrets.NETLIFY_PROJECT_ID_EDGE || secrets.NETLIFY_PROJECT_ID_SPLIT }}
run: |
env -u NETLIFY_AUTH_TOKEN -u NETLIFY_PROJECT_ID \
netlify deploy --json --no-build --dir=build --functions=.netlify/v1/functions \
--auth="$NETLIFY_AUTH_TOKEN" --site="$NETLIFY_PROJECT_ID" \
| tee /dev/stderr | jq -er '.deploy_url' > url

# Important: When setting up a new Vercel test app, make sure
# to set the root directory in the dashboard to the correct path.
- name: Deploy to Vercel
if: inputs.platform == 'vercel'
env: &vercel-secrets
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ inputs.variant == 'basic' && secrets.VERCEL_PROJECT_ID_BASIC || secrets.VERCEL_PROJECT_ID_SPLIT }}
# the CLI reads `.vercel/output` from here but checks that the project's root directory exists
run: |
mkdir -p "$APP"
vercel deploy --prebuilt --yes --token="$VERCEL_TOKEN" > url

# avoid stale cache results when testing ISR routes
- name: Purge Vercel CDN Cache
if: inputs.platform == 'vercel' && inputs.variant == 'basic'
env: *vercel-secrets
run: vercel cache purge --type cdn --token="$VERCEL_TOKEN" --yes

- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ inputs.platform }}-${{ inputs.variant }}-url
path: url
if-no-files-found: error
retention-days: 1

test:
needs: deploy
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- *checkout
- *pnpm
- *node
- *install

- name: Install Playwright
run: pnpm playwright install chromium --no-shell

# some tests inspect the build output
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ inputs.platform }}-${{ inputs.variant }}
path: ${{ env.APP }}

- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ${{ inputs.platform }}-${{ inputs.variant }}-url
path: ${{ runner.temp }}

- name: Run Playwright tests
working-directory: ${{ env.APP }}
run: DEPLOYMENT_URL=$(cat "$RUNNER_TEMP/url") pnpm test:platform

- name: Upload test artifacts
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: test-results-${{ inputs.platform }}-${{ inputs.variant }}
path: ${{ env.APP }}/test-results
retention-days: 3
Loading