Skip to content

Commit

Permalink
Merge pull request #37 from remix-run/pedro/ci
Browse files Browse the repository at this point in the history
CI
  • Loading branch information
pcattori authored Dec 11, 2024
2 parents a297233 + e12f214 commit e08da71
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 13 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
strategy:
matrix:
include:
- os: ubuntu-latest
browser: firefox
- os: ubuntu-latest
browser: chromium
- os: macos-latest
browser: webkit
- os: windows-latest
browser: msedge
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Install Playwright Browsers
working-directory: .tests
run: pnpm playwright install --with-deps ${{ matrix.browser }}
- name: Run Playwright tests
working-directory: .tests
run: pnpm test -- --project=${{ matrix.browser }}
19 changes: 18 additions & 1 deletion .tests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,24 @@ export default defineConfig({
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
use: devices["Desktop Chrome"],
},
{
name: "webkit",
use: devices["Desktop Safari"],
},
{
name: "msedge",
use: {
...devices["Desktop Edge"],
// Desktop Edge uses chromium by default
// https://github.com/microsoft/playwright/blob/993546c1bc3267fb72eddaf8cf003cb2e1519598/packages/playwright-core/src/server/deviceDescriptorsSource.json#L1652
channel: "msedge",
},
},
{
name: "firefox",
use: devices["Desktop Firefox"],
},
],
});
9 changes: 7 additions & 2 deletions .tests/test.netlify.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { expect, Page } from "@playwright/test";
import getPort from "get-port";

import { matchLine, testTemplate, urlRegex } from "./utils";
import {
matchLine,
testTemplate,
urlRegex,
withoutHmrPortError,
} from "./utils";

const test = testTemplate("netlify");

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

const url = await matchLine(dev.stdout, urlRegex.custom);
await workflow({ page, url });
expect(dev.buffer.stderr).toBe("");
expect(withoutHmrPortError(dev.buffer.stderr)).toBe("");
});

test("build", async ({ $ }) => {
Expand Down
10 changes: 8 additions & 2 deletions .tests/test.node-custom-server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { expect, Page } from "@playwright/test";
import getPort from "get-port";

import { matchLine, testTemplate, urlRegex } from "./utils";
import {
matchLine,
testTemplate,
urlRegex,
withoutHmrPortError,
} from "./utils";

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

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

const url = await matchLine(dev.stdout, urlRegex.custom);
await workflow({ page, url });
expect(dev.buffer.stderr).toBe("");

expect(withoutHmrPortError(dev.buffer.stderr)).toBe("");
});

test("build + start", async ({ page, $ }) => {
Expand Down
9 changes: 7 additions & 2 deletions .tests/test.vercel.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { expect, Page } from "@playwright/test";
import getPort from "get-port";

import { matchLine, testTemplate, urlRegex } from "./utils";
import {
matchLine,
testTemplate,
urlRegex,
withoutHmrPortError,
} from "./utils";

const test = testTemplate("vercel");

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

const url = await matchLine(dev.stdout, urlRegex.custom);
await workflow({ page, url });
expect(dev.buffer.stderr).toBe("");
expect(withoutHmrPortError(dev.buffer.stderr)).toBe("");
});

test("build", async ({ $ }) => {
Expand Down
14 changes: 8 additions & 6 deletions .tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ export const testTemplate = (template: string) =>
await use(cwd);

const testPassed = testInfo.errors.length === 0;
if (!testPassed) {
console.log("cwd: ", cwd);
return;
}
fs.rmSync(cwd, { recursive: true });
if (!testPassed) console.log("cwd: ", cwd);
},
edit: async ({ cwd }, use) => {
await use(async (file, transform) => {
Expand Down Expand Up @@ -114,7 +110,6 @@ export const testTemplate = (template: string) =>

testHasEnded = true;
processes.forEach((p) => p.kill());
await Promise.all(processes);
},
});

Expand Down Expand Up @@ -144,3 +139,10 @@ export const urlRegex = {
netlify: urlMatch({ prefix: /◈ Server now ready on / }),
wrangler: urlMatch({ prefix: /Ready on / }),
};

// `vite.createServer` always tries to use the same HMR port
// unless `server.hmr.port` is configured.
// Ultimately, we should provide better primitives for building custom servers
// something like `createRequestHandler(pathToBuild)`.
export const withoutHmrPortError = (stderr: string) =>
stderr.replace(/WebSocket server error: Port is already in use/, "").trim();

0 comments on commit e08da71

Please sign in to comment.