Skip to content

Commit 8529612

Browse files
committed
tmp: just testing use-cache integration test
1 parent e480a9f commit 8529612

File tree

4 files changed

+50
-172
lines changed

4 files changed

+50
-172
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:
@@ -190,87 +119,3 @@ jobs:
190119
NEXT_RESOLVED_VERSION: ${{ steps.resolve-next-version.outputs.version }}
191120
TEMP: ${{ github.workspace }}/..
192121

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

tests/integration/use-cache.test.ts

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,22 +155,37 @@ describe.skipIf(!nextVersionSatisfies('>=15.3.0-canary.13'))('use cache', () =>
155155
// much more performant
156156
let ctx: FixtureTestContext
157157
beforeAll(async () => {
158-
ctx = {
159-
deployID: generateRandomObjectID(),
160-
siteID: v4(),
161-
} as FixtureTestContext
162-
163-
vi.stubEnv('SITE_ID', ctx.siteID)
164-
vi.stubEnv('DEPLOY_ID', ctx.deployID)
165-
vi.stubEnv('NETLIFY_PURGE_API_TOKEN', 'fake-token')
166-
await startMockBlobStore(ctx as FixtureTestContext)
167-
168-
await createFixture('use-cache', ctx)
169-
await runPlugin(ctx)
158+
console.log(`[${new Date().toISOString()}] Starting use-cache beforeAll`)
159+
try {
160+
ctx = {
161+
deployID: generateRandomObjectID(),
162+
siteID: v4(),
163+
} as FixtureTestContext
164+
ctx.debug = true
165+
166+
vi.stubEnv('SITE_ID', ctx.siteID)
167+
vi.stubEnv('DEPLOY_ID', ctx.deployID)
168+
vi.stubEnv('NETLIFY_PURGE_API_TOKEN', 'fake-token')
169+
await startMockBlobStore(ctx as FixtureTestContext)
170+
171+
await createFixture('use-cache', ctx)
172+
await runPlugin(ctx)
173+
console.log(`[${new Date().toISOString()}] Finished use-cache beforeAll`)
174+
} catch (err) {
175+
console.log(`[${new Date().toISOString()}] use-cache beforeAll failed`, err)
176+
throw err
177+
}
170178
})
171179

172180
afterAll(async () => {
173-
await afterTestCleanup(ctx)
181+
console.log(`[${new Date().toISOString()}] Finished use-cache afterAll`)
182+
try {
183+
await afterTestCleanup(ctx)
184+
console.log(`[${new Date().toISOString()}] Finished use-cache afterAll`)
185+
} catch (err) {
186+
console.log(`[${new Date().toISOString()}] use-cache afterAll failed`, err)
187+
throw err
188+
}
174189
})
175190

176191
describe('default (in-memory cache entries, shared tag manifests)', () => {

tests/utils/contexts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ export interface FixtureTestContext extends TestContext {
1616
edgeFunctionPort: number
1717
edgeFunctionOutput: WriteStream
1818
cleanup?: (() => Promise<void>)[]
19+
debug?: boolean
1920
}

tests/utils/fixture.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,25 @@ export async function runPlugin(
292292
configPath: join(edgeSource, 'manifest.json'),
293293
})
294294
const { asset } = result.manifest.bundles[0]
295-
const cmd = `deno run --allow-read --allow-write --allow-net --allow-env ${eszipHelper} extract ./${asset} .`
296-
await execaCommand(cmd, { cwd: dist })
295+
296+
if (ctx.debug) {
297+
await execaCommand(`deno -v`, { cwd: dist, stdio: 'inherit' })
298+
await execaCommand(`deno info`, { cwd: dist, stdio: 'inherit' })
299+
await execaCommand(`which deno`, { cwd: dist, stdio: 'inherit' })
300+
301+
console.log(`[${new Date().toISOString()}] start to extract`, dist)
302+
}
303+
304+
try {
305+
const cmd = `deno run --allow-read --allow-write --allow-net --allow-env ${eszipHelper} extract ./${asset} .`
306+
await execaCommand(cmd, { cwd: dist })
307+
console.log(`[${new Date().toISOString()}] finished extracting`, dist)
308+
} catch (err) {
309+
if (ctx.debug) {
310+
console.log(`[${new Date().toISOString()}] failed extracting`, dist, err)
311+
}
312+
throw err
313+
}
297314

298315
// start the edge functions server:
299316
const servePath = base.resolveFromPackagePath('.netlify', 'edge-functions-serve')

0 commit comments

Comments
 (0)