Skip to content

Commit 44c9e7b

Browse files
committed
upload artifcats aa
1 parent 3041ba5 commit 44c9e7b

File tree

3 files changed

+82
-56
lines changed

3 files changed

+82
-56
lines changed

.github/workflows/run-tests.yml

Lines changed: 58 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
name: 'Run tests'
1+
name: "Run tests"
22
on:
33
pull_request:
44
branches: [main]
55
schedule:
6-
- cron: '0 6 * * *' # Run every day at 6am UTC
6+
- cron: "0 6 * * *" # Run every day at 6am UTC
77
workflow_dispatch:
88
inputs:
99
versions:
10-
description: 'The versions of Next.js to test against (quoted and comma separated)'
10+
description: "The versions of Next.js to test against (quoted and comma separated)"
1111
required: false
12-
default: 'latest'
12+
default: "latest"
1313

1414
jobs:
1515
setup:
@@ -65,12 +65,12 @@ jobs:
6565
fi
6666
echo "version=$NODE_VERSION" >> $GITHUB_OUTPUT
6767
echo "Node version for 'next@${{ matrix.version }}' is '$NODE_VERSION'"
68-
- name: 'Install Node'
68+
- name: "Install Node"
6969
uses: actions/setup-node@v5
7070
with:
7171
node-version: ${{ steps.decide-node-version.outputs.version }}
72-
cache: 'npm'
73-
cache-dependency-path: '**/package-lock.json'
72+
cache: "npm"
73+
cache-dependency-path: "**/package-lock.json"
7474
- uses: oven-sh/setup-bun@v2
7575
- name: setup pnpm/yarn
7676
run: |
@@ -82,9 +82,9 @@ jobs:
8282
with:
8383
# Should match the `DENO_VERSION_RANGE` from https://github.com/netlify/build/blob/main/packages/edge-bundler/node/bridge.ts#L20
8484
deno-version: v2.2.4
85-
- name: 'Install dependencies'
85+
- name: "Install dependencies"
8686
run: npm ci
87-
- name: 'Prepare Netlify CLI'
87+
- name: "Prepare Netlify CLI"
8888
env:
8989
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
9090
run: |
@@ -97,8 +97,8 @@ jobs:
9797
- uses: actions/cache@v4
9898
id: playwright-cache
9999
with:
100-
path: '~/.cache/ms-playwright'
101-
key: '${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}'
100+
path: "~/.cache/ms-playwright"
101+
key: "${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}"
102102
restore-keys: |
103103
${{ runner.os }}-playwright-
104104
- name: Install Playwright Browsers
@@ -124,6 +124,13 @@ jobs:
124124
name: blob-report-${{matrix.version}}-${{ matrix.shard }}
125125
path: blob-report
126126
retention-days: 1
127+
- name: Upload debug artifacts
128+
uses: actions/upload-artifact@v4
129+
if: always()
130+
with:
131+
name: debug-artifacts-${{matrix.version}}-${{ matrix.shard }}
132+
path: debug-artifacts
133+
retention-days: 1
127134

128135
test:
129136
needs: setup
@@ -135,9 +142,9 @@ jobs:
135142
version: ${{ fromJson(needs.setup.outputs.matrix) }}
136143
exclude:
137144
- os: windows-2025
138-
version: '13.5.1'
145+
version: "13.5.1"
139146
- os: windows-2025
140-
version: '14.2.15'
147+
version: "14.2.15"
141148
runs-on: ${{ matrix.os }}
142149
steps:
143150
- uses: actions/checkout@v5
@@ -154,12 +161,12 @@ jobs:
154161
fi
155162
echo "version=$NODE_VERSION" >> $GITHUB_OUTPUT
156163
echo "Node version for 'next@${{ matrix.version }}' is '$NODE_VERSION'"
157-
- name: 'Install Node'
164+
- name: "Install Node"
158165
uses: actions/setup-node@v5
159166
with:
160167
node-version: ${{ steps.decide-node-version.outputs.version }}
161-
cache: 'npm'
162-
cache-dependency-path: '**/package-lock.json'
168+
cache: "npm"
169+
cache-dependency-path: "**/package-lock.json"
163170
- name: Prefer npm global on windows
164171
if: runner.os == 'Windows'
165172
# On Windows by default PATH prefers corepack bundled with Node.js
@@ -178,11 +185,11 @@ jobs:
178185
with:
179186
# Should match the `DENO_VERSION_RANGE` from https://github.com/netlify/edge-bundler/blob/e55f825bd985d3c92e21d1b765d71e70d5628fba/node/bridge.ts#L17
180187
deno-version: v2.2.4
181-
- name: 'Install dependencies'
188+
- name: "Install dependencies"
182189
run: npm ci
183-
- name: 'Build'
190+
- name: "Build"
184191
run: npm run build
185-
- name: 'Vendor deno helpers for integration tests'
192+
- name: "Vendor deno helpers for integration tests"
186193
run: node tools/vendor-deno-tools.js
187194
- name: Resolve Next.js version
188195
id: resolve-next-version
@@ -207,13 +214,13 @@ jobs:
207214
key:
208215
integration-fixtures-${{ runner.os }}-${{steps.resolve-next-version.outputs.version}}-${{
209216
steps.fixture-cache-key.outputs.key }}
210-
- name: 'Prepare Fixtures'
217+
- name: "Prepare Fixtures"
211218
if: steps.cache-fixtures.outputs.cache-hit != 'true'
212219
run: npm run pretest
213220
env:
214221
NEXT_VERSION: ${{ matrix.version }}
215222
NEXT_RESOLVED_VERSION: ${{ steps.resolve-next-version.outputs.version }}
216-
- name: 'Unit and integration tests'
223+
- name: "Unit and integration tests"
217224
run: npm run test:ci:unit-and-integration -- --shard=${{ matrix.shard }}/8
218225
env:
219226
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
@@ -244,12 +251,12 @@ jobs:
244251
fi
245252
echo "version=$NODE_VERSION" >> $GITHUB_OUTPUT
246253
echo "Node version for 'next@${{ matrix.version }}' is '$NODE_VERSION'"
247-
- name: 'Install Node'
254+
- name: "Install Node"
248255
uses: actions/setup-node@v5
249256
with:
250257
node-version: ${{ steps.decide-node-version.outputs.version }}
251-
cache: 'npm'
252-
cache-dependency-path: '**/package-lock.json'
258+
cache: "npm"
259+
cache-dependency-path: "**/package-lock.json"
253260
- name: setup pnpm/yarn
254261
run: corepack enable
255262
shell: bash
@@ -258,11 +265,11 @@ jobs:
258265
with:
259266
# Should match the `DENO_VERSION_RANGE` from https://github.com/netlify/build/blob/main/packages/edge-bundler/node/bridge.ts#L20
260267
deno-version: v2.2.4
261-
- name: 'Install dependencies'
268+
- name: "Install dependencies"
262269
run: npm ci
263-
- name: 'Build'
270+
- name: "Build"
264271
run: npm run build
265-
- name: 'Prepare Netlify CLI'
272+
- name: "Prepare Netlify CLI"
266273
env:
267274
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
268275
run: |
@@ -276,7 +283,7 @@ jobs:
276283
RESOLVED_VERSION=$(npm view next@${{ matrix.version }} version)
277284
echo "version=$RESOLVED_VERSION" >> $GITHUB_OUTPUT
278285
echo "Resolved Next.js version for 'next@${{ matrix.version }}' is '$RESOLVED_VERSION'"
279-
- name: 'Smoke tests'
286+
- name: "Smoke tests"
280287
run: npm run test:ci:smoke
281288
env:
282289
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
@@ -285,36 +292,36 @@ jobs:
285292

286293
merge-reports:
287294
if: always()
288-
needs: [setup,e2e]
295+
needs: [setup, e2e]
289296
strategy:
290297
fail-fast: false
291298
matrix:
292299
version: ${{ fromJson(needs.setup.outputs.matrix) }}
293300

294301
runs-on: ubuntu-latest
295302
steps:
296-
- uses: actions/checkout@v5
297-
- uses: actions/setup-node@v5
298-
with:
299-
node-version: 18
300-
- name: Install dependencies
301-
run: npm ci
303+
- uses: actions/checkout@v5
304+
- uses: actions/setup-node@v5
305+
with:
306+
node-version: 18
307+
- name: Install dependencies
308+
run: npm ci
302309

303-
- name: Download blob reports from GitHub Actions Artifacts
304-
uses: actions/download-artifact@v5
305-
with:
306-
path: all-blob-reports
307-
pattern: blob-report-${{ matrix.version }}-*
308-
merge-multiple: true
310+
- name: Download blob reports from GitHub Actions Artifacts
311+
uses: actions/download-artifact@v5
312+
with:
313+
path: all-blob-reports
314+
pattern: blob-report-${{ matrix.version }}-*
315+
merge-multiple: true
309316

310-
- name: Merge reports
311-
run: |
312-
npx playwright merge-reports --reporter html ./all-blob-reports
313-
npx playwright merge-reports --reporter json ./all-blob-reports > merged_reports.json
317+
- name: Merge reports
318+
run: |
319+
npx playwright merge-reports --reporter html ./all-blob-reports
320+
npx playwright merge-reports --reporter json ./all-blob-reports > merged_reports.json
314321
315-
- name: Upload HTML report
316-
uses: actions/upload-artifact@v4
317-
with:
318-
name: html-report-${{ matrix.version }}-attempt-${{ github.run_attempt }}
319-
path: playwright-report
320-
retention-days: 14
322+
- name: Upload HTML report
323+
uses: actions/upload-artifact@v4
324+
with:
325+
name: html-report-${{ matrix.version }}-attempt-${{ github.run_attempt }}
326+
path: playwright-report
327+
retention-days: 14

playwright.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default defineConfig({
1010
/* Fail the build on CI if you accidentally left test.only in the source code. */
1111
forbidOnly: Boolean(process.env.CI),
1212
/* Retry on CI only */
13-
retries: process.env.CI ? 2 : 0,
13+
retries: process.env.CI ? 0 : 0,
1414
/* Limit the number of workers on CI, use default locally */
1515
workers: process.env.CI ? 3 : undefined,
1616
globalSetup: './tests/test-setup-e2e.ts',

tests/utils/create-e2e-fixture.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { execaCommand } from 'execa'
22
import fg from 'fast-glob'
33
import { exec } from 'node:child_process'
44
import { existsSync } from 'node:fs'
5-
import { appendFile, copyFile, mkdir, mkdtemp, readFile, rm } from 'node:fs/promises'
5+
import { appendFile, copyFile, cp, mkdir, mkdtemp, readFile, rm } from 'node:fs/promises'
66
import { tmpdir } from 'node:os'
7-
import { dirname, join } from 'node:path'
7+
import { basename, dirname, join } from 'node:path'
88
import process from 'node:process'
99
import { fileURLToPath } from 'node:url'
1010
import { cpus } from 'os'
@@ -69,7 +69,10 @@ export const createE2EFixture = async (fixture: string, config: E2EConfig = {})
6969
}
7070
console.log('\n\n\n🪵 Deploy logs:')
7171
console.log(logs)
72-
// on failures we don't delete the deploy
72+
// on failures locally we don't delete the deploy
73+
if (process.env.CI) {
74+
return cleanup(isolatedFixtureRoot, deployID)
75+
}
7376
}
7477
try {
7578
const [packageName] = await Promise.all([
@@ -274,7 +277,23 @@ async function deploySite(
274277
}
275278

276279
const siteDir = join(isolatedFixtureRoot, cwd)
277-
await execaCommand(cmd, { cwd: siteDir, all: true }).pipeAll?.(join(siteDir, outputFile))
280+
try {
281+
await execaCommand(cmd, { cwd: siteDir, all: true }).pipeAll?.(join(siteDir, outputFile))
282+
} catch (error: unknown) {
283+
// try to collect zips if they exist
284+
const functionsPath = join(isolatedFixtureRoot, packagePath ?? '', '.netlify/functions')
285+
const zipPaths = await fg.glob('**/*.zip', {
286+
cwd: functionsPath,
287+
dot: true,
288+
})
289+
if (zipPaths.length) {
290+
const debugDir = join('debug-artifacts', isolatedFixtureRoot)
291+
await mkdir(debugDir, { recursive: true })
292+
for (const path of zipPaths) {
293+
await cp(join(functionsPath, path), join(debugDir, basename(path)))
294+
}
295+
}
296+
}
278297
const output = await readFile(join(siteDir, outputFile), 'utf-8')
279298

280299
const { siteName, deployID } =

0 commit comments

Comments
 (0)