Skip to content

Commit 254d7bd

Browse files
committed
test: wat
1 parent 29e509e commit 254d7bd

File tree

4 files changed

+38
-158
lines changed

4 files changed

+38
-158
lines changed

.github/workflows/run-tests.yml

Lines changed: 2 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -36,89 +36,18 @@ jobs:
3636
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
3737
echo "matrix=${{ github.event.inputs.versions }}" >> $GITHUB_OUTPUT
3838
elif [ "${{ github.event_name }}" = "schedule" ] || [ "${{ steps.check-labels.outputs.result }}" = "true" ]; then
39-
echo "matrix=[\"latest\", \"canary\", \"14.2.15\", \"13.5.1\"]" >> $GITHUB_OUTPUT
39+
echo "matrix=[\"latest\", \"canary\"]" >> $GITHUB_OUTPUT
4040
else
4141
echo "matrix=[\"latest\"]" >> $GITHUB_OUTPUT
4242
fi
4343
44-
e2e:
45-
needs: setup
46-
runs-on: ubuntu-latest
47-
strategy:
48-
fail-fast: false
49-
matrix:
50-
version: ${{ fromJson(needs.setup.outputs.matrix) }}
51-
shard: [1, 2, 3, 4, 5]
52-
53-
steps:
54-
- uses: actions/checkout@v4
55-
- name: 'Install Node'
56-
uses: actions/setup-node@v4
57-
with:
58-
node-version: '18.x'
59-
cache: 'npm'
60-
cache-dependency-path: '**/package-lock.json'
61-
- uses: oven-sh/setup-bun@v1
62-
- name: setup pnpm/yarn
63-
run: |
64-
npm install -g corepack
65-
corepack enable
66-
shell: bash
67-
- name: Install Deno
68-
uses: denoland/setup-deno@v1
69-
with:
70-
# Should match the `DENO_VERSION_RANGE` from https://github.com/netlify/build/blob/main/packages/edge-bundler/node/bridge.ts#L20
71-
deno-version: v1.44.4
72-
- name: 'Install dependencies'
73-
run: npm ci
74-
- name: 'Prepare Netlify CLI'
75-
env:
76-
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
77-
run: |
78-
# Control netlify-cli as a regular dev dep but expose it globally for test fixtures to use
79-
npm install -g "netlify-cli@$(npm list --json --depth=0 netlify-cli | jq -r ".dependencies[\"netlify-cli\"].version")"
80-
npx netlify login
81-
- name: Get installed Playwright version
82-
id: playwright-version
83-
run: echo "version=$(npm view @playwright/test version)" >> $GITHUB_OUTPUT
84-
- uses: actions/cache@v4
85-
id: playwright-cache
86-
with:
87-
path: '~/.cache/ms-playwright'
88-
key: '${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }}'
89-
restore-keys: |
90-
${{ runner.os }}-playwright-
91-
- name: Install Playwright Browsers
92-
if: steps.playwright-cache.outputs.cache-hit != 'true'
93-
run: npx playwright install --with-deps
94-
- name: Resolve Next.js version
95-
id: resolve-next-version
96-
shell: bash
97-
run: |
98-
RESOLVED_VERSION=$(npm view next@${{ matrix.version }} version)
99-
echo "version=$RESOLVED_VERSION" >> $GITHUB_OUTPUT
100-
echo "Resolved Next.js version for 'next@${{ matrix.version }}' is '$RESOLVED_VERSION'"
101-
- name: Run Playwright tests
102-
run: npm run test:ci:e2e -- --shard=${{ matrix.shard }}/5
103-
env:
104-
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
105-
NEXT_VERSION: ${{ matrix.version }}
106-
NEXT_RESOLVED_VERSION: ${{ steps.resolve-next-version.outputs.version }}
107-
- name: Upload blob report to GitHub Actions Artifacts
108-
uses: actions/upload-artifact@v4
109-
if: always()
110-
with:
111-
name: blob-report-${{matrix.version}}-${{ matrix.shard }}
112-
path: blob-report
113-
retention-days: 1
114-
11544
test:
11645
needs: setup
11746
runs-on: ${{ matrix.os }}
11847
strategy:
11948
fail-fast: false
12049
matrix:
121-
shard: [1, 2, 3, 4, 5, 6, 7, 8]
50+
shard: [6]
12251
os: [ubuntu-latest, windows-latest]
12352
version: ${{ fromJson(needs.setup.outputs.matrix) }}
12453
steps:
@@ -188,87 +117,3 @@ jobs:
188117
NEXT_RESOLVED_VERSION: ${{ steps.resolve-next-version.outputs.version }}
189118
TEMP: ${{ github.workspace }}/..
190119

191-
smoke:
192-
if: always()
193-
needs: setup
194-
runs-on: ubuntu-latest
195-
strategy:
196-
fail-fast: false
197-
matrix:
198-
version: ${{ fromJson(needs.setup.outputs.matrix) }}
199-
steps:
200-
- uses: actions/checkout@v4
201-
- name: 'Install Node'
202-
uses: actions/setup-node@v4
203-
with:
204-
node-version: '18.x'
205-
cache: 'npm'
206-
cache-dependency-path: '**/package-lock.json'
207-
- name: setup pnpm/yarn
208-
run: corepack enable
209-
shell: bash
210-
- name: Install Deno
211-
uses: denoland/setup-deno@v1
212-
with:
213-
# Should match the `DENO_VERSION_RANGE` from https://github.com/netlify/build/blob/main/packages/edge-bundler/node/bridge.ts#L20
214-
deno-version: v1.44.4
215-
- name: 'Install dependencies'
216-
run: npm ci
217-
- name: 'Build'
218-
run: npm run build
219-
- name: 'Prepare Netlify CLI'
220-
env:
221-
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
222-
run: |
223-
# Control netlify-cli as a regular dev dep but expose it globally for test fixtures to use
224-
npm install -g "netlify-cli@$(npm list --json --depth=0 netlify-cli | jq -r ".dependencies[\"netlify-cli\"].version")"
225-
npx netlify login
226-
- name: Resolve Next.js version
227-
id: resolve-next-version
228-
shell: bash
229-
run: |
230-
RESOLVED_VERSION=$(npm view next@${{ matrix.version }} version)
231-
echo "version=$RESOLVED_VERSION" >> $GITHUB_OUTPUT
232-
echo "Resolved Next.js version for 'next@${{ matrix.version }}' is '$RESOLVED_VERSION'"
233-
- name: 'Smoke tests'
234-
run: npm run test:ci:smoke
235-
env:
236-
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
237-
NEXT_VERSION: ${{ matrix.version }}
238-
NEXT_RESOLVED_VERSION: ${{ steps.resolve-next-version.outputs.version }}
239-
240-
merge-reports:
241-
if: always()
242-
needs: [setup,e2e]
243-
strategy:
244-
fail-fast: false
245-
matrix:
246-
version: ${{ fromJson(needs.setup.outputs.matrix) }}
247-
248-
runs-on: ubuntu-latest
249-
steps:
250-
- uses: actions/checkout@v4
251-
- uses: actions/setup-node@v4
252-
with:
253-
node-version: 18
254-
- name: Install dependencies
255-
run: npm ci
256-
257-
- name: Download blob reports from GitHub Actions Artifacts
258-
uses: actions/download-artifact@v4
259-
with:
260-
path: all-blob-reports
261-
pattern: blob-report-${{ matrix.version }}-*
262-
merge-multiple: true
263-
264-
- name: Merge reports
265-
run: |
266-
npx playwright merge-reports --reporter html ./all-blob-reports
267-
npx playwright merge-reports --reporter json ./all-blob-reports > merged_reports.json
268-
269-
- name: Upload HTML report
270-
uses: actions/upload-artifact@v4
271-
with:
272-
name: html-report-${{ matrix.version }}-attempt-${{ github.run_attempt }}
273-
path: playwright-report
274-
retention-days: 14

tests/test-setup.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import fs from 'node:fs'
22
import { afterEach } from 'vitest'
33
import { type FixtureTestContext } from './utils/contexts'
4+
import { tmpdir } from 'node:os'
5+
import { join } from 'node:path'
6+
import { mkdtemp } from 'node:fs/promises'
7+
8+
if (!process.env.DENO_DIR) {
9+
// avoid using same deno dir in all workers as there seems to be some race happening
10+
const denoDir = await mkdtemp(join(tmpdir(), 'opennextjs-netlify-dist'))
11+
process.env.DENO_DIR = denoDir
12+
}
413

514
export async function afterTestCleanup({ cleanup }: FixtureTestContext) {
615
if ('reset' in fs) {
@@ -16,3 +25,13 @@ export async function afterTestCleanup({ cleanup }: FixtureTestContext) {
1625
afterEach<FixtureTestContext>(async (ctx) => {
1726
await afterTestCleanup(ctx)
1827
})
28+
29+
// beforeAll(() => {
30+
// console.log('before all', {
31+
// pid: process.pid,
32+
// a: process.env.VITEST_POOL_ID,
33+
// b: process.env.VITEST_WORKER_ID,
34+
// c: process.env.DENO_DIR,
35+
// })
36+
// process.exit(1)
37+
// })

tests/utils/fixture.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,11 @@ export async function runPlugin(
292292
configPath: join(edgeSource, 'manifest.json'),
293293
})
294294
const { asset } = result.manifest.bundles[0]
295+
296+
await execaCommand(`deno -v`, { cwd: dist, stdio: 'inherit' })
297+
await execaCommand(`deno info`, { cwd: dist, stdio: 'inherit' })
298+
await execaCommand(`which deno`, { cwd: dist, stdio: 'inherit' })
299+
295300
const cmd = `deno run --allow-read --allow-write --allow-net --allow-env ${eszipHelper} extract ./${asset} .`
296301
await execaCommand(cmd, { cwd: dist })
297302

tests/utils/next-version-helpers.mjs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,18 @@ export function nextVersionSatisfies(condition) {
2121
const isSemverVersion = valid(version)
2222
const checkVersion = isSemverVersion ? version : FUTURE_NEXT_PATCH_VERSION
2323

24-
return satisfies(checkVersion, condition, { includePrerelease: true }) || version === condition
24+
const satisfied =
25+
satisfies(checkVersion, condition, { includePrerelease: true }) || version === condition
26+
27+
// console.trace('nextVersionSatisfies', {
28+
// condition,
29+
// version,
30+
// isSemverVersion,
31+
// checkVersion,
32+
// satisfied,
33+
// })
34+
35+
return satisfied
2536
}
2637

2738
/**

0 commit comments

Comments
 (0)