Skip to content

Commit e08da71

Browse files
authored
Merge pull request #37 from remix-run/pedro/ci
CI
2 parents a297233 + e12f214 commit e08da71

File tree

6 files changed

+88
-13
lines changed

6 files changed

+88
-13
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
jobs:
10+
test:
11+
strategy:
12+
matrix:
13+
include:
14+
- os: ubuntu-latest
15+
browser: firefox
16+
- os: ubuntu-latest
17+
browser: chromium
18+
- os: macos-latest
19+
browser: webkit
20+
- os: windows-latest
21+
browser: msedge
22+
fail-fast: false
23+
runs-on: ${{ matrix.os }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
- uses: pnpm/action-setup@v4
27+
with:
28+
version: 9
29+
- uses: actions/setup-node@v4
30+
with:
31+
node-version: 20
32+
cache: "pnpm"
33+
- name: Install dependencies
34+
run: pnpm install
35+
- name: Install Playwright Browsers
36+
working-directory: .tests
37+
run: pnpm playwright install --with-deps ${{ matrix.browser }}
38+
- name: Run Playwright tests
39+
working-directory: .tests
40+
run: pnpm test -- --project=${{ matrix.browser }}

.tests/playwright.config.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,24 @@ export default defineConfig({
1414
projects: [
1515
{
1616
name: "chromium",
17-
use: { ...devices["Desktop Chrome"] },
17+
use: devices["Desktop Chrome"],
18+
},
19+
{
20+
name: "webkit",
21+
use: devices["Desktop Safari"],
22+
},
23+
{
24+
name: "msedge",
25+
use: {
26+
...devices["Desktop Edge"],
27+
// Desktop Edge uses chromium by default
28+
// https://github.com/microsoft/playwright/blob/993546c1bc3267fb72eddaf8cf003cb2e1519598/packages/playwright-core/src/server/deviceDescriptorsSource.json#L1652
29+
channel: "msedge",
30+
},
31+
},
32+
{
33+
name: "firefox",
34+
use: devices["Desktop Firefox"],
1835
},
1936
],
2037
});

.tests/test.netlify.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { expect, Page } from "@playwright/test";
22
import getPort from "get-port";
33

4-
import { matchLine, testTemplate, urlRegex } from "./utils";
4+
import {
5+
matchLine,
6+
testTemplate,
7+
urlRegex,
8+
withoutHmrPortError,
9+
} from "./utils";
510

611
const test = testTemplate("netlify");
712

@@ -15,7 +20,7 @@ test("dev", async ({ page, $ }) => {
1520

1621
const url = await matchLine(dev.stdout, urlRegex.custom);
1722
await workflow({ page, url });
18-
expect(dev.buffer.stderr).toBe("");
23+
expect(withoutHmrPortError(dev.buffer.stderr)).toBe("");
1924
});
2025

2126
test("build", async ({ $ }) => {

.tests/test.node-custom-server.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { expect, Page } from "@playwright/test";
22
import getPort from "get-port";
33

4-
import { matchLine, testTemplate, urlRegex } from "./utils";
4+
import {
5+
matchLine,
6+
testTemplate,
7+
urlRegex,
8+
withoutHmrPortError,
9+
} from "./utils";
510

611
const test = testTemplate("node-custom-server");
712

@@ -15,7 +20,8 @@ test("dev", async ({ page, $ }) => {
1520

1621
const url = await matchLine(dev.stdout, urlRegex.custom);
1722
await workflow({ page, url });
18-
expect(dev.buffer.stderr).toBe("");
23+
24+
expect(withoutHmrPortError(dev.buffer.stderr)).toBe("");
1925
});
2026

2127
test("build + start", async ({ page, $ }) => {

.tests/test.vercel.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { expect, Page } from "@playwright/test";
22
import getPort from "get-port";
33

4-
import { matchLine, testTemplate, urlRegex } from "./utils";
4+
import {
5+
matchLine,
6+
testTemplate,
7+
urlRegex,
8+
withoutHmrPortError,
9+
} from "./utils";
510

611
const test = testTemplate("vercel");
712

@@ -15,7 +20,7 @@ test("dev", async ({ page, $ }) => {
1520

1621
const url = await matchLine(dev.stdout, urlRegex.custom);
1722
await workflow({ page, url });
18-
expect(dev.buffer.stderr).toBe("");
23+
expect(withoutHmrPortError(dev.buffer.stderr)).toBe("");
1924
});
2025

2126
test("build", async ({ $ }) => {

.tests/utils.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,7 @@ export const testTemplate = (template: string) =>
6262
await use(cwd);
6363

6464
const testPassed = testInfo.errors.length === 0;
65-
if (!testPassed) {
66-
console.log("cwd: ", cwd);
67-
return;
68-
}
69-
fs.rmSync(cwd, { recursive: true });
65+
if (!testPassed) console.log("cwd: ", cwd);
7066
},
7167
edit: async ({ cwd }, use) => {
7268
await use(async (file, transform) => {
@@ -114,7 +110,6 @@ export const testTemplate = (template: string) =>
114110

115111
testHasEnded = true;
116112
processes.forEach((p) => p.kill());
117-
await Promise.all(processes);
118113
},
119114
});
120115

@@ -144,3 +139,10 @@ export const urlRegex = {
144139
netlify: urlMatch({ prefix: / Server now ready on / }),
145140
wrangler: urlMatch({ prefix: /Ready on / }),
146141
};
142+
143+
// `vite.createServer` always tries to use the same HMR port
144+
// unless `server.hmr.port` is configured.
145+
// Ultimately, we should provide better primitives for building custom servers
146+
// something like `createRequestHandler(pathToBuild)`.
147+
export const withoutHmrPortError = (stderr: string) =>
148+
stderr.replace(/WebSocket server error: Port is already in use/, "").trim();

0 commit comments

Comments
 (0)