Browser tests run in Playwright's image, with nothing fetched from Ubuntu's mirror
The phone app's WebKit e2e also fetched its system libraries with `playwright install --with-deps`, and a slow mirror ran that job out of time too. It now runs in Playwright's image through `docker run`, with the workspace mounted at its own path so the test finds the `luxe` the job built, after removing the runner's unused Android SDK to make room for the image. Both images take their tag from the suite's lockfile, read in `what changed`, so a Dependabot bump of Playwright moves its image with it. In the image, site-cross's dev server came up on localhost and refused every probe: the server and the client resolved localhost to different loopbacks. Both servers now bind 127.0.0.1 and everything dials it. site-cross also reports why a dev server never answered: what the last probe got and the server's last lines of output.
This commit is contained in:
52
.github/workflows/ci.yml
vendored
52
.github/workflows/ci.yml
vendored
@@ -51,6 +51,8 @@ jobs:
|
|||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
outputs:
|
outputs:
|
||||||
code: ${{ steps.diff.outputs.code }}
|
code: ${{ steps.diff.outputs.code }}
|
||||||
|
web_playwright: ${{ steps.playwright.outputs.web }}
|
||||||
|
app_playwright: ${{ steps.playwright.outputs.app }}
|
||||||
steps:
|
steps:
|
||||||
# Full history: the diff is taken from a merge base
|
# Full history: the diff is taken from a merge base
|
||||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
@@ -67,6 +69,17 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
BASE: ${{ github.event.pull_request.base.sha || github.event.before }}
|
BASE: ${{ github.event.pull_request.base.sha || github.event.before }}
|
||||||
|
|
||||||
|
# The browser suites run in Playwright's image, whose browsers only work with the Playwright
|
||||||
|
# that matches its tag. Read from the lockfiles, so a Dependabot bump moves the image with it
|
||||||
|
- name: Playwright versions
|
||||||
|
id: playwright
|
||||||
|
run: |
|
||||||
|
for suite in web=web app=crates/luxe-remote/app-tests; do
|
||||||
|
version=$(jq -r '.packages["node_modules/playwright"].version // empty' "${suite#*=}/package-lock.json")
|
||||||
|
[ -n "$version" ] || { echo "::error::no playwright in ${suite#*=}/package-lock.json"; exit 1; }
|
||||||
|
echo "${suite%%=*}=$version" >> "$GITHUB_OUTPUT"
|
||||||
|
done
|
||||||
|
|
||||||
gate:
|
gate:
|
||||||
name: build · test · clippy · fmt
|
name: build · test · clippy · fmt
|
||||||
needs: changes
|
needs: changes
|
||||||
@@ -165,18 +178,24 @@ jobs:
|
|||||||
# made `target/debug/luxe`: a job of its own would compile the workspace a second time, and
|
# made `target/debug/luxe`: a job of its own would compile the workspace a second time, and
|
||||||
# the binary is too large to hand between jobs cheaply. The app's types and unit tests need
|
# the binary is too large to hand between jobs cheaply. The app's types and unit tests need
|
||||||
# no Rust, so they stay in `remote-app`.
|
# no Rust, so they stay in `remote-app`.
|
||||||
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
#
|
||||||
with:
|
# In Playwright's image, which has WebKit and the Ubuntu libraries it loads, rather than
|
||||||
node-version: 24
|
# fetching those from Ubuntu's mirror on every run, where a slow mirror ran the job out of
|
||||||
cache: npm
|
# time. The workspace is mounted at its own path, so the test finds `target/debug/luxe`
|
||||||
cache-dependency-path: crates/luxe-remote/app-tests/package-lock.json
|
# where it expects it, and runs as the runner's user, so what it writes stays cleanable.
|
||||||
|
#
|
||||||
|
# The build and test binaries leave the disk all but full, too full for the image, and
|
||||||
|
# `target/` can't give any back because the cache step saves it after this. The Android SDK
|
||||||
|
# the runner image ships is about 10 GB that nothing here uses.
|
||||||
- name: Phone app end to end (WebKit)
|
- name: Phone app end to end (WebKit)
|
||||||
working-directory: crates/luxe-remote/app-tests
|
|
||||||
run: |
|
run: |
|
||||||
npm ci
|
sudo rm -rf /usr/local/lib/android
|
||||||
npx playwright install --with-deps webkit
|
df -h / | tail -1
|
||||||
npm run e2e
|
docker run --rm --ipc=host --user "$(id -u):$(id -g)" -e HOME=/tmp/home \
|
||||||
|
-v "$GITHUB_WORKSPACE:$GITHUB_WORKSPACE" -w "$GITHUB_WORKSPACE/crates/luxe-remote/app-tests" \
|
||||||
|
"mcr.microsoft.com/playwright:v$PLAYWRIGHT-noble" sh -c 'npm ci && npm run e2e'
|
||||||
|
env:
|
||||||
|
PLAYWRIGHT: ${{ needs.changes.outputs.app_playwright }}
|
||||||
|
|
||||||
# Does it build and pass on the platforms nobody develops on? Linux above is the canonical gate —
|
# Does it build and pass on the platforms nobody develops on? Linux above is the canonical gate —
|
||||||
# `fmt` is an answer about the source, not about the OS, so running it three times would only
|
# `fmt` is an answer about the source, not about the OS, so running it three times would only
|
||||||
@@ -353,9 +372,7 @@ jobs:
|
|||||||
if: needs.changes.outputs.code == 'true'
|
if: needs.changes.outputs.code == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
# The tag has to be web/'s Playwright version exactly, or the browsers it looks for aren't
|
image: mcr.microsoft.com/playwright:v${{ needs.changes.outputs.web_playwright }}-noble
|
||||||
# the ones in the image; the first step below checks
|
|
||||||
image: mcr.microsoft.com/playwright:v1.63.0-noble
|
|
||||||
# Firefox won't run as root in a home it doesn't own, and Actions' home is the runner user's
|
# Firefox won't run as root in a home it doesn't own, and Actions' home is the runner user's
|
||||||
options: --user 1001
|
options: --user 1001
|
||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
@@ -372,15 +389,6 @@ jobs:
|
|||||||
run: npm ci
|
run: npm ci
|
||||||
working-directory: web
|
working-directory: web
|
||||||
|
|
||||||
- name: The image matches web/'s Playwright
|
|
||||||
run: |
|
|
||||||
want=$(node -p "require('playwright/package.json').version")
|
|
||||||
if [ "$want" != "1.63.0" ]; then
|
|
||||||
echo "::error::web/ uses Playwright $want: set the web cross-browser image to v$want-noble"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
working-directory: web
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: npm run build
|
run: npm run build
|
||||||
working-directory: web
|
working-directory: web
|
||||||
|
|||||||
@@ -100,6 +100,13 @@ const MIME = {
|
|||||||
".wasm": "application/wasm",
|
".wasm": "application/wasm",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where both servers listen and every browser and probe connects: an address, not `localhost`.
|
||||||
|
* In a container `localhost` can name `::1` to the server binding it and `127.0.0.1` to the
|
||||||
|
* client dialing it, and in Playwright's image the dev server came up and refused every request.
|
||||||
|
*/
|
||||||
|
const LOOPBACK = "127.0.0.1";
|
||||||
|
|
||||||
/** Serves `web/dist` the way a static host would, including the `.wasm` type the player needs. */
|
/** Serves `web/dist` the way a static host would, including the `.wasm` type the player needs. */
|
||||||
function serveBuilt(root) {
|
function serveBuilt(root) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
@@ -123,7 +130,7 @@ function serveBuilt(root) {
|
|||||||
}
|
}
|
||||||
response.writeHead(404).end("not found");
|
response.writeHead(404).end("not found");
|
||||||
});
|
});
|
||||||
server.listen(0, () => resolve({ server, port: server.address().port }));
|
server.listen(0, LOOPBACK, () => resolve({ server, port: server.address().port }));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,10 +151,35 @@ async function serveDev(port) {
|
|||||||
// shell that launched this with it. Spawned directly, `child.kill()` is the server.
|
// shell that launched this with it. Spawned directly, `child.kill()` is the server.
|
||||||
const child = spawn(
|
const child = spawn(
|
||||||
process.execPath,
|
process.execPath,
|
||||||
[join(web, "node_modules/astro/bin/astro.mjs"), "dev", "--port", String(port)],
|
[join(web, "node_modules/astro/bin/astro.mjs"), "dev", "--host", LOOPBACK, "--port", String(port)],
|
||||||
{ cwd: web, stdio: "ignore" },
|
{ cwd: web, stdio: ["ignore", "pipe", "pipe"] },
|
||||||
);
|
);
|
||||||
return { child, port };
|
return watchServer({ child, port, output: [], exit: null });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeps the last of what `target`'s server prints, and how it ended, so a server that never
|
||||||
|
* answers can say why. Read either way: a pipe nobody drains fills up and stalls its server.
|
||||||
|
*/
|
||||||
|
function watchServer(target) {
|
||||||
|
const keep = (chunk) => {
|
||||||
|
target.output.push(...String(chunk).split("\n").filter((line) => line.trim()));
|
||||||
|
target.output.splice(0, Math.max(0, target.output.length - 30));
|
||||||
|
};
|
||||||
|
target.child.stdout.on("data", keep);
|
||||||
|
target.child.stderr.on("data", keep);
|
||||||
|
target.child.on("exit", (code, signal) => {
|
||||||
|
target.exit = signal ?? `exit code ${code}`;
|
||||||
|
});
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Why `target`'s server never answered, with the last of what it printed. */
|
||||||
|
function reportSilentServer(name, target) {
|
||||||
|
const why = target.exit ? `it ended (${target.exit})` : "it was still running";
|
||||||
|
console.log(`✗ ${name.padEnd(9)} the dev server never answered; ${why}`);
|
||||||
|
console.log(` the last ask got: ${target.lastAnswer ?? "nothing yet"}`);
|
||||||
|
for (const line of target.output) console.log(` ${line}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function shutdown(target) {
|
function shutdown(target) {
|
||||||
@@ -157,13 +189,15 @@ function shutdown(target) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function waitForServer(port, seconds = 90) {
|
async function waitForServer(target, seconds = 90) {
|
||||||
for (let attempt = 0; attempt < seconds * 2; attempt += 1) {
|
for (let attempt = 0; attempt < seconds * 2 && !target.exit; attempt += 1) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`http://localhost:${port}/`);
|
const response = await fetch(`http://${LOOPBACK}:${target.port}/`);
|
||||||
if (response.ok) return true;
|
if (response.ok) return true;
|
||||||
} catch {
|
target.lastAnswer = `HTTP ${response.status}: ${(await response.text()).slice(0, 300)}`;
|
||||||
/* not up yet */
|
} catch (error) {
|
||||||
|
// Not up yet, usually; the cause is what tells a refused port from a wrong address
|
||||||
|
target.lastAnswer = `${error.message}${error.cause ? ` (${error.cause.code ?? error.cause.message})` : ""}`;
|
||||||
}
|
}
|
||||||
await new Promise((done) => setTimeout(done, 500));
|
await new Promise((done) => setTimeout(done, 500));
|
||||||
}
|
}
|
||||||
@@ -210,7 +244,7 @@ async function demosFit(browser, port, path) {
|
|||||||
const tab = await context.newPage();
|
const tab = await context.newPage();
|
||||||
const problems = [];
|
const problems = [];
|
||||||
try {
|
try {
|
||||||
await tab.goto(`http://localhost:${port}${path}`, { waitUntil: "networkidle" });
|
await tab.goto(`http://${LOOPBACK}:${port}${path}`, { waitUntil: "networkidle" });
|
||||||
await settleHero(tab);
|
await settleHero(tab);
|
||||||
const demos = tab.locator(".demo");
|
const demos = tab.locator(".demo");
|
||||||
const count = await demos.count();
|
const count = await demos.count();
|
||||||
@@ -279,7 +313,7 @@ async function checkEngine(engine, name, port) {
|
|||||||
noise.push(`request failed: ${request.url()} (${request.failure()?.errorText})`);
|
noise.push(`request failed: ${request.url()} (${request.failure()?.errorText})`);
|
||||||
});
|
});
|
||||||
|
|
||||||
await tab.goto(`http://localhost:${port}${page.path}`, { waitUntil: "networkidle" });
|
await tab.goto(`http://${LOOPBACK}:${port}${page.path}`, { waitUntil: "networkidle" });
|
||||||
await settleHero(tab);
|
await settleHero(tab);
|
||||||
|
|
||||||
if (page.demos) {
|
if (page.demos) {
|
||||||
@@ -366,8 +400,8 @@ for (const [name, engine] of [
|
|||||||
if (!built) {
|
if (!built) {
|
||||||
shutdown(current);
|
shutdown(current);
|
||||||
current = await serveDev((port += 1));
|
current = await serveDev((port += 1));
|
||||||
if (!(await waitForServer(current.port))) {
|
if (!(await waitForServer(current))) {
|
||||||
console.log(`✗ ${name.padEnd(9)} the dev server never answered`);
|
reportSilentServer(name, current);
|
||||||
failed = true;
|
failed = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user