Skip to content

Commit 3aa07ee

Browse files
committed
run e2es on windows
1 parent f129602 commit 3aa07ee

File tree

8 files changed

+650
-220
lines changed

8 files changed

+650
-220
lines changed

.changeset/olive-lemons-dance.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/cloudflare": patch
3+
---
4+
5+
Fix multiple Windows path issues.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: "Setup Playwright"
2+
description: "Setup Playwright with caching"
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Put $HOME in env
8+
if: runner.os == 'windows'
9+
shell: pwsh
10+
run: echo "HOME=$HOME" | Out-File -FilePath $env:GITHUB_ENV -Append
11+
12+
- name: Cache Playwright
13+
id: playwright-cache
14+
uses: actions/cache@v4
15+
with:
16+
path: ${{ runner.os == 'Windows' && format('{0}{1}', env.HOME, '\AppData\Local\ms-playwright') || runner.os == 'Linux' && '~/.cache/ms-playwright' || '~/Library/Caches/ms-playwright' }}
17+
key: playwright-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
18+
19+
- name: Install Playwright with dependencies
20+
if: steps.playwright-cache.outputs.cache-hit != 'true'
21+
shell: bash
22+
run: pnpm playwright install --with-deps
23+
24+
- name: Install Playwright's dependencies
25+
if: steps.playwright-cache.outputs.cache-hit == 'true'
26+
shell: bash
27+
run: pnpm playwright install-deps

.github/workflows/playwright.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ on:
88
jobs:
99
test:
1010
timeout-minutes: 30
11-
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-latest, windows-latest]
15+
runs-on: ${{ matrix.os }}
1216
steps:
1317
- name: Check out code
1418
uses: actions/checkout@v4
@@ -17,7 +21,7 @@ jobs:
1721
uses: ./.github/actions/install-dependencies
1822

1923
- name: Install Playwright
20-
run: pnpm run install-playwright
24+
uses: ./.github/actions/setup-playwright
2125

2226
- name: Build the tool
2327
run: pnpm build
@@ -34,6 +38,6 @@ jobs:
3438
- uses: actions/upload-artifact@v4
3539
if: always()
3640
with:
37-
name: playwright-report
41+
name: playwright-report-${{ matrix.os }}
3842
path: ./**/playwright-report
3943
retention-days: 1

examples/common/config-e2e.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function configurePlaywright(
2727
if (isCI) {
2828
// Do not build on CI - there is a preceding build step
2929
command = `pnpm preview:worker -- --port ${port} --inspector-port ${inspectorPort} ${env}`;
30-
timeout = 100_000;
30+
timeout = 250_000;
3131
} else {
3232
timeout = 500_000;
3333
command = `pnpm preview -- --port ${port} --inspector-port ${inspectorPort} ${env}`;

packages/cloudflare/src/cli/build/patches/plugins/instrumentation.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { type BuildOptions, getPackagePath } from "@opennextjs/aws/build/helper.
55
import { patchCode } from "@opennextjs/aws/build/patch/astCodePatcher.js";
66
import type { ContentUpdater, Plugin } from "@opennextjs/aws/plugins/content-updater.js";
77

8+
import { normalizePath } from "../../utils/normalize-path.js";
9+
810
export function patchInstrumentation(updater: ContentUpdater, buildOpts: BuildOptions): Plugin {
911
const builtInstrumentationPath = getBuiltInstrumentationPath(buildOpts);
1012

@@ -84,7 +86,7 @@ function getBuiltInstrumentationPath(buildOpts: BuildOptions): string | null {
8486
getPackagePath(buildOpts),
8587
`.next/server/${INSTRUMENTATION_HOOK_FILENAME}.js`
8688
);
87-
return existsSync(maybeBuiltInstrumentationPath) ? maybeBuiltInstrumentationPath : null;
89+
return existsSync(maybeBuiltInstrumentationPath) ? normalizePath(maybeBuiltInstrumentationPath) : null;
8890
}
8991

9092
/**

packages/cloudflare/src/cli/build/patches/plugins/wrangler-external.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import { dirname, resolve } from "node:path";
1818

1919
import type { PluginBuild } from "esbuild";
2020

21+
import { normalizePath } from "../../utils/normalize-path.js";
22+
2123
export function setWranglerExternal() {
2224
return {
2325
name: "wrangler-externals",
@@ -27,7 +29,7 @@ export function setWranglerExternal() {
2729

2830
build.onResolve({ filter: /(\.bin|\.wasm\?module)$/ }, ({ path, importer }) => {
2931
return {
30-
path: resolve(dirname(importer), path),
32+
path: normalizePath(resolve(dirname(importer), path)),
3133
namespace,
3234
external: true,
3335
};

packages/cloudflare/src/cli/commands/populate-cache.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
BINDING_NAME as D1_TAG_BINDING_NAME,
3434
NAME as D1_TAG_NAME,
3535
} from "../../api/overrides/tag-cache/d1-next-tag-cache.js";
36+
import { normalizePath } from "../build/utils/normalize-path.js";
3637
import type { WranglerTarget } from "../utils/run-wrangler.js";
3738
import { runWrangler } from "../utils/run-wrangler.js";
3839

@@ -57,8 +58,8 @@ export function getCacheAssets(opts: BuildOptions): CacheAsset[] {
5758
const assets: CacheAsset[] = [];
5859

5960
for (const file of allFiles) {
60-
const fullPath = file.fullpathPosix();
61-
const relativePath = path.relative(path.join(opts.outputDir, "cache"), fullPath);
61+
const fullPath = file.fullpath();
62+
const relativePath = normalizePath(path.relative(path.join(opts.outputDir, "cache"), fullPath));
6263

6364
if (relativePath.startsWith("__fetch")) {
6465
const [__fetch, buildId, ...keyParts] = relativePath.split("/");
@@ -121,7 +122,11 @@ function populateR2IncrementalCache(
121122

122123
runWrangler(
123124
options,
124-
["r2 object put", JSON.stringify(path.join(bucket, cacheKey)), `--file ${JSON.stringify(fullPath)}`],
125+
[
126+
"r2 object put",
127+
JSON.stringify(normalizePath(path.join(bucket, cacheKey))),
128+
`--file ${JSON.stringify(fullPath)}`,
129+
],
125130
// NOTE: R2 does not support the environment flag and results in the following error:
126131
// Incorrect type for the 'cacheExpiry' field on 'HttpMetadata': the provided value is not of type 'date'.
127132
{ target: populateCacheOptions.target, excludeRemoteFlag: true, logging: "error" }

0 commit comments

Comments
 (0)