mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-12-01 21:05:42 +09:00
perf: Speed up Builder E2E setup and project opens
This commit is contained in:
1 parent
bfafc2a14d
commit
d62fc4bfa9
6 files changed
+60
-17
No files matched your search
@@ -38,10 +38,37 @@ runs:
|
||||
shell: bash
|
||||
run: pnpm --filter @webstudio-is/sdk-components-react-router build
|
||||
|
||||
- name: Identify schema snapshot
|
||||
id: schema
|
||||
shell: bash
|
||||
run: |
|
||||
ROOT_DIR="$PWD"
|
||||
source apps/builder/backend/lib.sh
|
||||
echo "fingerprint=$(builder_backend_schema_fingerprint)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Restore schema snapshot
|
||||
id: schema-cache
|
||||
uses: actions/cache/restore@v5
|
||||
with:
|
||||
path: .cache/builder-e2e/schema-${{ steps.schema.outputs.fingerprint }}.sql
|
||||
key: builder-e2e-schema-v1-${{ runner.os }}-${{ steps.schema.outputs.fingerprint }}
|
||||
|
||||
- name: Generate schema snapshot
|
||||
if: steps.schema-cache.outputs.cache-hit != 'true'
|
||||
shell: bash
|
||||
run: pnpm --filter @webstudio-is/builder e2e:schema-cache
|
||||
|
||||
- name: Check schema snapshot
|
||||
shell: bash
|
||||
run: test -s ".cache/builder-e2e/schema-${{ steps.schema.outputs.fingerprint }}.sql"
|
||||
|
||||
- name: Save schema snapshot
|
||||
if: steps.schema-cache.outputs.cache-hit != 'true'
|
||||
uses: actions/cache/save@v5
|
||||
with:
|
||||
path: .cache/builder-e2e/schema-${{ steps.schema.outputs.fingerprint }}.sql
|
||||
key: builder-e2e-schema-v1-${{ runner.os }}-${{ steps.schema.outputs.fingerprint }}
|
||||
|
||||
- name: Upload prerequisites
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { execFile } from "node:child_process";
|
||||
import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { dirname, join } from "node:path";
|
||||
import { promisify } from "node:util";
|
||||
import { afterEach, expect, test } from "vitest";
|
||||
|
||||
@@ -67,6 +67,24 @@ test("schema fingerprint includes new backend files", async () => {
|
||||
expect(await readSchemaFingerprint(root)).not.toBe(before);
|
||||
});
|
||||
|
||||
test.each([
|
||||
"packages/prisma-client/prisma/migrations/initial/schema.prisma",
|
||||
"packages/prisma-client/prisma/schema.prisma",
|
||||
"packages/prisma-client/migrations-cli/commands.ts",
|
||||
"packages/prisma-client/src/prisma.ts",
|
||||
"packages/prisma-client/package.json",
|
||||
"pnpm-lock.yaml",
|
||||
])("schema fingerprint includes %s", async (file) => {
|
||||
const root = await createRepositoryFixture();
|
||||
const path = join(root, file);
|
||||
await mkdir(dirname(path), { recursive: true });
|
||||
await writeFile(path, "before");
|
||||
const before = await readSchemaFingerprint(root);
|
||||
await writeFile(path, "after");
|
||||
|
||||
expect(await readSchemaFingerprint(root)).not.toBe(before);
|
||||
});
|
||||
|
||||
test("backend modes select safe Compose projects", async () => {
|
||||
const root = await createRepositoryFixture();
|
||||
const readProjectName = async (mode: "development" | "test") => {
|
||||
|
||||
@@ -36,8 +36,15 @@ builder_backend_schema_fingerprint() {
|
||||
find packages/prisma-client/prisma/migrations \
|
||||
-mindepth 1 -maxdepth 1 -type d -print
|
||||
find packages/prisma-client/prisma/migrations \
|
||||
-type f \( -name migration.sql -o -name migration.ts \) -print
|
||||
-type f \( -name migration.sql -o -name migration.ts -o -name schema.prisma -o -name migration_lock.toml -o -name template.txt \) -print
|
||||
find packages/prisma-client/migrations-cli \
|
||||
-type f -name '*.ts' ! -name '*.test.ts' -print
|
||||
find apps/builder/backend -type f ! -name '*.test.*' -print
|
||||
printf '%s\n' \
|
||||
packages/prisma-client/prisma/schema.prisma \
|
||||
packages/prisma-client/src/prisma.ts \
|
||||
packages/prisma-client/package.json \
|
||||
pnpm-lock.yaml
|
||||
} | LC_ALL=C sort | while IFS= read -r file; do
|
||||
if [ -f "$file" ]; then
|
||||
printf '%s ' "$file"
|
||||
|
||||
@@ -12,6 +12,9 @@ Use the full command for CI-like validation:
|
||||
pnpm e2e:builder
|
||||
```
|
||||
|
||||
The local command builds Builder and the generated React Router components
|
||||
used by Preview tests.
|
||||
|
||||
The first run after migrations change applies the regular migration pipeline
|
||||
and writes an ignored schema cache under `.cache/builder-e2e`. Refresh it
|
||||
explicitly with:
|
||||
|
||||
@@ -110,18 +110,6 @@ export const waitForCanvasTextHidden = async ({
|
||||
});
|
||||
};
|
||||
|
||||
export const dismissBlockingAlerts = async ({ page }: { page: Page }) => {
|
||||
const startedAt = Date.now();
|
||||
while (Date.now() - startedAt < 3_000) {
|
||||
const dismissButton = page.getByRole("button", { name: "Dismiss" });
|
||||
if (await dismissButton.isVisible({ timeout: 500 }).catch(() => false)) {
|
||||
await dismissButton.click();
|
||||
return;
|
||||
}
|
||||
await delay(100);
|
||||
}
|
||||
};
|
||||
|
||||
export const openProjectBuilder = async ({
|
||||
page,
|
||||
projectId,
|
||||
@@ -148,7 +136,6 @@ export const openProjectBuilder = async ({
|
||||
.waitForLoadState("networkidle", { timeout: builderNetworkIdleTimeout })
|
||||
.catch(() => undefined);
|
||||
const canvas = await waitForCanvasFrame({ page });
|
||||
await dismissBlockingAlerts({ page });
|
||||
return canvas;
|
||||
};
|
||||
|
||||
@@ -164,6 +151,5 @@ export const openBuilderUrl = async ({
|
||||
.waitForLoadState("networkidle", { timeout: builderNetworkIdleTimeout })
|
||||
.catch(() => undefined);
|
||||
const canvas = await waitForCanvasFrame({ page });
|
||||
await dismissBlockingAlerts({ page });
|
||||
return canvas;
|
||||
};
|
||||
@@ -137,13 +137,15 @@ install_playwright_chromium() {
|
||||
|
||||
build_e2e_apps() {
|
||||
pnpm --dir "$ROOT_DIR" e2e:builder:build
|
||||
pnpm --dir "$ROOT_DIR" --filter=@webstudio-is/sdk-components-react-router build
|
||||
}
|
||||
|
||||
verify_e2e_apps_built() {
|
||||
local builder_server="$ROOT_DIR/apps/builder/build/server"
|
||||
local builder_assets="$ROOT_DIR/apps/builder/build/client/assets"
|
||||
local router_components="$ROOT_DIR/packages/sdk-components-react-router/lib/components.js"
|
||||
|
||||
if [ ! -d "$builder_server" ] || [ ! -d "$builder_assets" ]; then
|
||||
if [ ! -d "$builder_server" ] || [ ! -d "$builder_assets" ] || [ ! -f "$router_components" ]; then
|
||||
echo "E2E_SKIP_BUILDER_BUILD requires prebuilt Builder artifacts" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user