Make Playwright cache runner-agnostic
All checks were successful
CI / nightly-e2e (pull_request) Has been skipped
CI / deploy (pull_request) Has been skipped
CI / pr-e2e (pull_request) Successful in 1m17s
CI / ci (pull_request) Successful in 1m22s

Replace hardcoded /opt/playwright-tools mount with a persistent Docker volume cache and install Chromium into that cache before E2E jobs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Mark
2026-03-03 12:56:37 +00:00
parent 04a55844fd
commit e8b835e6fc

View File

@@ -75,12 +75,22 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
CI_IMAGE: nohype-ci-e2e:${{ github.run_id }} CI_IMAGE: nohype-ci-e2e:${{ github.run_id }}
PLAYWRIGHT_CACHE_VOLUME: nohype-playwright-browsers
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Build - name: Build
run: docker build -t "$CI_IMAGE" . run: docker build -t "$CI_IMAGE" .
- name: Ensure Playwright Chromium cache
run: |
docker volume create "$PLAYWRIGHT_CACHE_VOLUME" >/dev/null
docker run --rm \
-v "$PLAYWRIGHT_CACHE_VOLUME:/ms-playwright" \
-e PLAYWRIGHT_BROWSERS_PATH=/ms-playwright \
"$CI_IMAGE" \
python -m playwright install chromium
- name: Start PostgreSQL - name: Start PostgreSQL
run: | run: |
docker run -d --name pr-e2e-postgres \ docker run -d --name pr-e2e-postgres \
@@ -100,14 +110,14 @@ jobs:
- name: Start app with seeded content - name: Start app with seeded content
run: | run: |
docker run -d --name pr-e2e-app --network container:pr-e2e-postgres \ docker run -d --name pr-e2e-app --network container:pr-e2e-postgres \
-v /opt/playwright-tools/browsers:/opt/playwright-tools/browsers:ro \ -v "$PLAYWRIGHT_CACHE_VOLUME:/ms-playwright:ro" \
-e SECRET_KEY=ci-secret-key \ -e SECRET_KEY=ci-secret-key \
-e DATABASE_URL=postgres://nohype:nohype@127.0.0.1:5432/nohype \ -e DATABASE_URL=postgres://nohype:nohype@127.0.0.1:5432/nohype \
-e CONSENT_POLICY_VERSION=1 \ -e CONSENT_POLICY_VERSION=1 \
-e EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend \ -e EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend \
-e DEFAULT_FROM_EMAIL=hello@nohypeai.com \ -e DEFAULT_FROM_EMAIL=hello@nohypeai.com \
-e NEWSLETTER_PROVIDER=buttondown \ -e NEWSLETTER_PROVIDER=buttondown \
-e PLAYWRIGHT_BROWSERS_PATH=/opt/playwright-tools/browsers \ -e PLAYWRIGHT_BROWSERS_PATH=/ms-playwright \
"$CI_IMAGE" \ "$CI_IMAGE" \
sh -lc "python manage.py migrate --noinput && python manage.py seed_e2e_content && python manage.py runserver 0.0.0.0:8000" sh -lc "python manage.py migrate --noinput && python manage.py seed_e2e_content && python manage.py runserver 0.0.0.0:8000"
for i in $(seq 1 40); do for i in $(seq 1 40); do
@@ -139,10 +149,19 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
CI_IMAGE: nohype-ci-nightly:${{ github.run_id }} CI_IMAGE: nohype-ci-nightly:${{ github.run_id }}
PLAYWRIGHT_CACHE_VOLUME: nohype-playwright-browsers
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Build - name: Build
run: docker build -t "$CI_IMAGE" . run: docker build -t "$CI_IMAGE" .
- name: Ensure Playwright Chromium cache
run: |
docker volume create "$PLAYWRIGHT_CACHE_VOLUME" >/dev/null
docker run --rm \
-v "$PLAYWRIGHT_CACHE_VOLUME:/ms-playwright" \
-e PLAYWRIGHT_BROWSERS_PATH=/ms-playwright \
"$CI_IMAGE" \
python -m playwright install chromium
- name: Start PostgreSQL - name: Start PostgreSQL
run: | run: |
docker run -d --name nightly-postgres \ docker run -d --name nightly-postgres \
@@ -161,14 +180,14 @@ jobs:
- name: Start dev server with seeded content - name: Start dev server with seeded content
run: | run: |
docker run -d --name nightly-e2e --network container:nightly-postgres \ docker run -d --name nightly-e2e --network container:nightly-postgres \
-v /opt/playwright-tools/browsers:/opt/playwright-tools/browsers:ro \ -v "$PLAYWRIGHT_CACHE_VOLUME:/ms-playwright:ro" \
-e SECRET_KEY=ci-secret-key \ -e SECRET_KEY=ci-secret-key \
-e DATABASE_URL=postgres://nohype:nohype@127.0.0.1:5432/nohype \ -e DATABASE_URL=postgres://nohype:nohype@127.0.0.1:5432/nohype \
-e CONSENT_POLICY_VERSION=1 \ -e CONSENT_POLICY_VERSION=1 \
-e EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend \ -e EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend \
-e DEFAULT_FROM_EMAIL=hello@nohypeai.com \ -e DEFAULT_FROM_EMAIL=hello@nohypeai.com \
-e NEWSLETTER_PROVIDER=buttondown \ -e NEWSLETTER_PROVIDER=buttondown \
-e PLAYWRIGHT_BROWSERS_PATH=/opt/playwright-tools/browsers \ -e PLAYWRIGHT_BROWSERS_PATH=/ms-playwright \
"$CI_IMAGE" \ "$CI_IMAGE" \
sh -lc "python manage.py migrate --noinput && python manage.py seed_e2e_content && python manage.py runserver 0.0.0.0:8000" sh -lc "python manage.py migrate --noinput && python manage.py seed_e2e_content && python manage.py runserver 0.0.0.0:8000"
for i in $(seq 1 40); do for i in $(seq 1 40); do