From f287bddd97043ae7371a39365b23361923038cd3 Mon Sep 17 00:00:00 2001 From: Matysh Date: Wed, 19 Aug 2026 20:06:38 +0300 Subject: [PATCH] fix: cache Playwright browsers instead of reinstalling them via apt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit performance_smoke burned nearly all of its 15-minute budget before the benchmark even started, twice in a row: validate.yml had no browser cache at all, so every browser job paid for a full `playwright install --with-deps` — apt work the ubuntu-latest image makes redundant, with unbounded retries against an unreachable azure mirror on top. For a measuring job that is worse than lost minutes: the timing window competes with package installation on the same runner. #175 fixed this for the review pipeline but deliberately left the flag here, reasoning that a prerelease gate values predictability over minutes. That reasoning was wrong — the flag is what made the gate unpredictable. Browsers are now cached per package-lock hash in smoke, golden, performance_smoke and the full performance run; installation happens only on a cache miss and no longer touches apt. performance_smoke keeps headroom for a cold cache at 20 minutes. If the image ever drops a required library, Chromium fails to launch with a clear missing-libraries error; that is the moment to bring the flag back. Issue: #206 User-Visible: no --- .github/workflows/performance.yml | 10 ++++++- .github/workflows/validate.yml | 49 +++++++++++++++++++++++++++---- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index ee7d3a6b..947ebed2 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -132,9 +132,17 @@ jobs: - name: Install candidate and baseline dependencies run: npm ci --prefix candidate && npm ci --prefix baseline + # То же, что в validate.yml: кэш браузеров, apt не трогаем (#206). + - name: Кэш браузеров Playwright + id: pw + uses: actions/cache@v6 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ hashFiles('candidate/package-lock.json') }} - name: Install pinned Chromium + if: steps.pw.outputs.cache-hit != 'true' working-directory: candidate - run: npx playwright install --with-deps chromium + run: npx playwright install chromium - name: Build both exact source trees run: | diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 06fe7e5f..e5e971fd 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -169,8 +169,20 @@ jobs: node-version: 22 cache: npm - run: npm ci - - name: Install Chromium for Playwright - run: npx playwright install --with-deps chromium + # Браузеры кэшируются, а apt не запускается вовсе: на GitHub-раннере + # системные библиотеки Chromium уже в образе, а --with-deps тратил минуты + # и подолгу перебирал недоступное azure-зеркало (#175, #206). Если + # библиотека когда-нибудь исчезнет из образа, Chromium не запустится с + # внятной ошибкой — тогда флаг вернуть. + - name: Кэш браузеров Playwright + id: pw + uses: actions/cache@v6 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ hashFiles('package-lock.json') }} + - name: Install pinned Chromium + if: steps.pw.outputs.cache-hit != 'true' + run: npx playwright install chromium - name: Build a fresh bundle for the smokes run: npm run build && cp dist/houseplan-card.js demo/srv/assets/houseplan-card.js - name: Smoke suite @@ -207,8 +219,20 @@ jobs: node-version: 22 cache: npm - run: npm ci + # Браузеры кэшируются, а apt не запускается вовсе: на GitHub-раннере + # системные библиотеки Chromium уже в образе, а --with-deps тратил минуты + # и подолгу перебирал недоступное azure-зеркало (#175, #206). Если + # библиотека когда-нибудь исчезнет из образа, Chromium не запустится с + # внятной ошибкой — тогда флаг вернуть. + - name: Кэш браузеров Playwright + id: pw + uses: actions/cache@v6 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ hashFiles('package-lock.json') }} - name: Install pinned Chromium - run: npx playwright install --with-deps chromium + if: steps.pw.outputs.cache-hit != 'true' + run: npx playwright install chromium - name: Build the exact source under review run: npm run build && cp dist/houseplan-card.js demo/srv/assets/houseplan-card.js - name: Capture or verify golden matrix @@ -233,7 +257,10 @@ jobs: # prereleases. The expensive same-runner comparison lives in performance.yml. needs: frontend runs-on: ubuntu-latest - timeout-minutes: 15 + # 15 минут не хватало, когда установка браузера шла через apt: замер + # начинался на исходе окна (#206). Запас на холодный кэш — при попадании + # job укладывается в те же минуты, что и раньше. + timeout-minutes: 20 steps: - uses: actions/checkout@v7 - uses: actions/setup-node@v7 @@ -241,8 +268,20 @@ jobs: node-version: 22 cache: npm - run: npm ci + # Браузеры кэшируются, а apt не запускается вовсе: на GitHub-раннере + # системные библиотеки Chromium уже в образе, а --with-deps тратил минуты + # и подолгу перебирал недоступное azure-зеркало (#175, #206). Если + # библиотека когда-нибудь исчезнет из образа, Chromium не запустится с + # внятной ошибкой — тогда флаг вернуть. + - name: Кэш браузеров Playwright + id: pw + uses: actions/cache@v6 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ hashFiles('package-lock.json') }} - name: Install pinned Chromium - run: npx playwright install --with-deps chromium + if: steps.pw.outputs.cache-hit != 'true' + run: npx playwright install chromium - name: Build the exact candidate source run: npm run build && cp dist/houseplan-card.js demo/srv/assets/houseplan-card.js - name: Capture the heaviest Glow state