Skip to content

Commit 0274a20

Browse files
authored
chore: backport Netlify platform tests (#16281)
The action won't run unless it's on `main` so #16254 needs to be backported. Not sure if the instrumentation test app and job also needs to be backported for the one on `version-3` to run
1 parent 1b4adcc commit 0274a20

15 files changed

Lines changed: 180 additions & 3706 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: 'Netlify Deploy'
2+
description: 'Set up the repo and deploy a test app to Netlify'
3+
4+
inputs:
5+
test-app-dir:
6+
description: 'Path to the test app directory'
7+
required: true
8+
netlify-project-id:
9+
description: 'Netlify project ID'
10+
required: true
11+
netlify-token:
12+
description: 'Netlify authentication token'
13+
required: true
14+
outputs:
15+
deployment-url:
16+
description: 'URL of the deployed preview'
17+
value: ${{ steps.deploy.outputs.url }}
18+
19+
runs:
20+
using: 'composite'
21+
steps:
22+
- uses: ./.github/actions/node-setup
23+
24+
- name: Build adapter-netlify files
25+
shell: bash
26+
working-directory: packages/adapter-netlify
27+
run: pnpm prepublishOnly
28+
29+
- name: Install Netlify CLI
30+
shell: bash
31+
run: pnpm i -g netlify-cli
32+
33+
- name: Deploy to Netlify
34+
id: deploy
35+
shell: bash
36+
env:
37+
TEST_APP_DIR: ${{ inputs.test-app-dir }}
38+
NETLIFY_AUTH_TOKEN: ${{ inputs.netlify-token }}
39+
NETLIFY_PROJECT_ID: ${{ inputs.netlify-project-id }}
40+
run: |
41+
TEST_APP_NAME=$(cat "$TEST_APP_DIR/package.json" | jq -r '.name')
42+
echo "url=$(netlify deploy --json --filter="$TEST_APP_NAME" --dir="$TEST_APP_DIR/build" --functions=".netlify/v1/functions" --auth="$NETLIFY_AUTH_TOKEN" --site="$NETLIFY_PROJECT_ID" | jq -r '.deploy_url')" >> "$GITHUB_OUTPUT"

.github/workflows/ci.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,6 @@ jobs:
228228
node-version: [18, 20, 22, 24]
229229
steps:
230230
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
231-
# required for testing netlify edge functions
232-
- uses: denoland/setup-deno@667a34cdef165d8d2b2e98dde39547c9daac7282 # v2.0.4
233-
with:
234-
deno-version: ~2.8.2 # 2.9.0 crashes when accessing `globalThis.process` with `@netlify/dev`
235-
cache: true
236231
- uses: ./.github/actions/node-setup
237232
with:
238233
node-version: ${{ matrix.node-version }}

.github/workflows/platform-tests-all.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ jobs:
1818
sha: ${{ inputs.sha }}
1919
secrets: inherit
2020

21+
netlify:
22+
uses: ./.github/workflows/platform-tests-netlify.yml
23+
with:
24+
sha: ${{ inputs.sha }}
25+
secrets: inherit
26+
2127
node:
2228
uses: ./.github/workflows/platform-tests-node.yml
2329
with:
@@ -26,7 +32,7 @@ jobs:
2632

2733
report-status:
2834
if: always()
29-
needs: [vercel, node]
35+
needs: [vercel, netlify, node]
3036
runs-on: ubuntu-latest
3137
steps:
3238
- name: Determine outcome
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Platform Tests (Netlify)
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
sha:
7+
description: 'Commit SHA to test'
8+
required: false
9+
default: ''
10+
workflow_call:
11+
inputs:
12+
sha:
13+
description: 'Commit SHA to test'
14+
required: false
15+
type: string
16+
default: ''
17+
18+
permissions:
19+
contents: read
20+
21+
env:
22+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
23+
24+
jobs:
25+
test-basic:
26+
if: github.repository == 'sveltejs/kit'
27+
runs-on: ubuntu-latest
28+
timeout-minutes: 15
29+
environment: '@sveltejs/adapter-netlify platform tests'
30+
env:
31+
TEST_APP_DIR: packages/adapter-netlify/test/apps/basic
32+
steps:
33+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
34+
with:
35+
ref: ${{ inputs.sha || github.sha }}
36+
37+
- uses: ./.github/actions/netlify-deploy
38+
id: deploy
39+
with:
40+
test-app-dir: ${{ env.TEST_APP_DIR }}
41+
netlify-project-id: ${{ secrets.NETLIFY_PROJECT_ID_BASIC }}
42+
netlify-token: ${{ secrets.NETLIFY_TOKEN }}
43+
44+
- uses: ./.github/actions/platform-test
45+
with:
46+
test-app-dir: ${{ env.TEST_APP_DIR }}
47+
deployment-url: ${{ steps.deploy.outputs.deployment-url }}
48+
49+
test-edge:
50+
if: github.repository == 'sveltejs/kit'
51+
runs-on: ubuntu-latest
52+
timeout-minutes: 15
53+
environment: '@sveltejs/adapter-netlify platform tests'
54+
env:
55+
TEST_APP_DIR: packages/adapter-netlify/test/apps/edge
56+
steps:
57+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
58+
with:
59+
ref: ${{ inputs.sha || github.sha }}
60+
61+
- uses: ./.github/actions/netlify-deploy
62+
id: deploy
63+
with:
64+
test-app-dir: ${{ env.TEST_APP_DIR }}
65+
netlify-project-id: ${{ secrets.NETLIFY_PROJECT_ID_EDGE }}
66+
netlify-token: ${{ secrets.NETLIFY_TOKEN }}
67+
68+
- uses: ./.github/actions/platform-test
69+
with:
70+
test-app-dir: ${{ env.TEST_APP_DIR }}
71+
deployment-url: ${{ steps.deploy.outputs.deployment-url }}
72+
73+
test-split:
74+
if: github.repository == 'sveltejs/kit'
75+
runs-on: ubuntu-latest
76+
timeout-minutes: 15
77+
environment: '@sveltejs/adapter-netlify platform tests'
78+
env:
79+
TEST_APP_DIR: packages/adapter-netlify/test/apps/split
80+
steps:
81+
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
82+
with:
83+
ref: ${{ inputs.sha || github.sha }}
84+
85+
- uses: ./.github/actions/netlify-deploy
86+
id: deploy
87+
with:
88+
test-app-dir: ${{ env.TEST_APP_DIR }}
89+
netlify-project-id: ${{ secrets.NETLIFY_PROJECT_ID_SPLIT }}
90+
netlify-token: ${{ secrets.NETLIFY_TOKEN }}
91+
92+
- uses: ./.github/actions/platform-test
93+
with:
94+
test-app-dir: ${{ env.TEST_APP_DIR }}
95+
deployment-url: ${{ steps.deploy.outputs.deployment-url }}

packages/adapter-netlify/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,18 @@
3838
"check": "tsc",
3939
"lint": "prettier --check .",
4040
"format": "pnpm lint --write",
41-
"test": "pnpm test:integration",
4241
"test:unit": "vitest run",
43-
"test:integration": "pnpm build && pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test",
42+
"test:build": "pnpm build && pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" build",
43+
"test": "pnpm test:build",
4444
"prepublishOnly": "pnpm build"
4545
},
4646
"dependencies": {
4747
"@iarna/toml": "^2.2.5",
4848
"esbuild": "^0.28.1"
4949
},
5050
"devDependencies": {
51-
"@netlify/dev": "catalog:",
5251
"@netlify/edge-functions": "catalog:",
5352
"@netlify/functions": "catalog:",
54-
"@netlify/node-cookies": "^0.1.0",
55-
"@netlify/types": "^2.1.0",
5653
"@rollup/plugin-commonjs": "catalog:",
5754
"@rollup/plugin-json": "catalog:",
5855
"@rollup/plugin-node-resolve": "catalog:",
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
11
[build]
22
publish = "build"
3-
4-
# TODO: remove this after we refactor to the Netlify frameworks API
5-
# we are purposely misusing the user functions config to discover our framework
6-
# build output because our adapter still outputs using an older API but the new
7-
# Netlify dev server adheres to the new API
8-
[functions]
9-
directory = ".netlify/functions-internal"

packages/adapter-netlify/test/apps/basic/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"scripts": {
66
"dev": "vite dev",
77
"build": "vite build",
8-
"preview": "node ../../preview.js",
8+
"preview": "vite preview",
99
"prepare": "svelte-kit sync || echo ''",
10-
"test": "playwright test"
10+
"test:platform": "playwright test"
1111
},
1212
"devDependencies": {
1313
"@sveltejs/kit": "workspace:^",
Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,2 @@
11
[build]
22
publish = "build"
3-
4-
# TODO: remove these once we overhaul the Netlify adapter to use the new edge declarations https://docs.netlify.com/build/edge-functions/declarations/#declare-edge-functions-inline
5-
6-
# defaults to "netlify/edge-functions" (without the . prefix)
7-
edge_functions = ".netlify/edge-functions"
8-
9-
# the dev server doesn't read the manifest.json in edge-functions so we need
10-
# to explicitly declare this here
11-
[[edge_functions]]
12-
path = "/*"
13-
function = "render"
14-
excludedPath = ["/_app/immutable/*", "/_app/version.json", "/.netlify/*"]

packages/adapter-netlify/test/apps/edge/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"scripts": {
66
"dev": "vite dev",
77
"build": "vite build",
8-
"preview": "node ../../preview.js",
8+
"preview": "vite preview",
99
"prepare": "svelte-kit sync || echo ''",
10-
"test": "playwright test"
10+
"test:platform": "playwright test"
1111
},
1212
"devDependencies": {
1313
"@sveltejs/kit": "workspace:^",
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
11
[build]
22
publish = "build"
3-
4-
# TODO: remove this after we refactor to the Netlify frameworks API
5-
# we are purposely misusing the user functions config to discover our framework
6-
# build output because our adapter still outputs using an older API but the new
7-
# Netlify dev server adheres to the new API
8-
[functions]
9-
directory = ".netlify/functions-internal"

0 commit comments

Comments
 (0)