Skip to content

AI-native design editor. Open-source Figma alternative.

ci: restore Playwright's Chromium from a cache instead of installing apt packages (#1522)

Danila Poyarkove02bd726b290
diff --git a/.github/actions/setup-playwright/action.yml b/.github/actions/setup-playwright/action.yml
new file mode 100644
index 000000000..f3a2d8231
--- /dev/null
+++ b/.github/actions/setup-playwright/action.yml
@@ -0,0 +1,25 @@
+name: Setup Playwright Chromium
+
+description: >-
+ Restore Playwright's Chromium from the cache, downloading it only on a miss. GitHub's Ubuntu
+ runners already have the libraries Chromium needs, so nothing is installed with apt, whose
+ mirrors can take minutes.
+
+runs:
+ using: composite
+ steps:
+ - name: Read the Playwright version
+ id: playwright
+ shell: bash
+ run: echo "version=$(bunx playwright --version | awk '{print $2}')" >> "$GITHUB_OUTPUT"
+
+ - uses: actions/cache@v6
+ id: browsers
+ with:
+ path: ~/.cache/ms-playwright
+ key: playwright-chromium-${{ runner.os }}-${{ runner.arch }}-${{ steps.playwright.outputs.version }}
+
+ - name: Download Chromium
+ if: steps.browsers.outputs.cache-hit != 'true'
+ shell: bash
+ run: bunx playwright install chromium
diff --git a/.github/workflows/app.yml b/.github/workflows/app.yml
index 01e7546fa..76101dea4 100644
--- a/.github/workflows/app.yml
+++ b/.github/workflows/app.yml
@@ -25,7 +25,7 @@ jobs:
run: bun run format:check
# The demo document's shader fills are drawn at build time in a headless Chromium.
- - run: bunx playwright install --with-deps chromium
+ - uses: ./.github/actions/setup-playwright
- run: bun run build
env:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 9503eabac..efa90fc5c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -343,7 +343,7 @@ jobs:
# The editor's demo document draws its shader fills at build time in a headless Chromium.
- name: Install Chromium for the demo document
if: matrix.worker
- run: bunx playwright install --with-deps chromium
+ uses: ./.github/actions/setup-playwright
# The Worker serves the editor and the portal as static assets, and every official
# deployment bundles them.
diff --git a/.github/workflows/cloud.yml b/.github/workflows/cloud.yml
index a4ee5f76a..244c48fa9 100644
--- a/.github/workflows/cloud.yml
+++ b/.github/workflows/cloud.yml
@@ -34,7 +34,7 @@ jobs:
- uses: ./.github/actions/setup-bun
# The editor's demo document draws its shader fills at build time in a headless Chromium.
- - run: bunx playwright install --with-deps chromium
+ - uses: ./.github/actions/setup-playwright
# The Worker serves the editor and the portal as static assets. The editor names this
# deployment as the official server and, like app.openpencil.dev, sends the daily ping.
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index c6f003c66..08098ad5c 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -32,7 +32,7 @@ jobs:
# The demo document the landing's stages open draws its shader stills in headless Chromium.
- name: Install Chromium for the demo document
- run: bunx playwright install --with-deps chromium
+ uses: ./.github/actions/setup-playwright
- run: bun run --filter @open-pencil/docs build:site
@@ -63,7 +63,7 @@ jobs:
cache-save: 'false'
- name: Install Chromium for landing posters
- run: bunx playwright install --with-deps chromium
+ uses: ./.github/actions/setup-playwright
- uses: actions/download-artifact@v8
with:
diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml
index ed16b46f5..ddca59e77 100644
--- a/.github/workflows/preview.yml
+++ b/.github/workflows/preview.yml
@@ -27,7 +27,7 @@ jobs:
run: bun run format:check
# The demo document's shader fills are drawn at build time in a headless Chromium.
- - run: bunx playwright install --with-deps chromium
+ - uses: ./.github/actions/setup-playwright
- run: bun run build
diff --git a/tools/ci/images/ci-images/package.json b/tools/ci/images/ci-images/package.json
deleted file mode 100644
index bd9877410..000000000
--- a/tools/ci/images/ci-images/package.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "name": "@open-pencil/ci-images-tools",
- "private": true,
- "type": "module"
-}
diff --git a/tools/ci/images/ci-images/native-contracts/Dockerfile b/tools/ci/images/native-contracts/Dockerfile
similarity index 100%
rename from tools/ci/images/ci-images/native-contracts/Dockerfile
rename to tools/ci/images/native-contracts/Dockerfile