From cf16a216c3e987aa96819a7796e53b3b7312df75 Mon Sep 17 00:00:00 2001 From: Ammar Date: Wed, 29 Oct 2025 19:23:13 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=A4=96=20ci:=20cache=20Playwright=20b?= =?UTF-8?q?rowsers=20in=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Cache ~/.cache/ms-playwright keyed by Playwright version - Skip browser download on cache hit, only install system deps - Applies to both storybook-test and e2e-test jobs - Reduces CI time by avoiding ~200MB browser downloads --- .github/workflows/ci.yml | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 743abdfb4..8adfe8e32 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -123,9 +123,27 @@ jobs: - uses: ./.github/actions/setup-cmux + - name: Get Playwright version + id: playwright-version + run: echo "version=$(bun x playwright --version | cut -d' ' -f2)" >> $GITHUB_OUTPUT + + - name: Cache Playwright browsers + uses: actions/cache@v4 + id: playwright-cache + with: + path: ~/.cache/ms-playwright + key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }} + restore-keys: | + ${{ runner.os }}-playwright- + - name: Install Playwright browsers + if: steps.playwright-cache.outputs.cache-hit != 'true' run: bun x playwright install --with-deps + - name: Install Playwright system dependencies + if: steps.playwright-cache.outputs.cache-hit == 'true' + run: bun x playwright install-deps + - name: Build Storybook run: make storybook-build @@ -154,12 +172,27 @@ jobs: sudo apt-get update sudo apt-get install -y xvfb - - name: Install Playwright runtime dependencies - run: bun x playwright install-deps + - name: Get Playwright version + id: playwright-version + run: echo "version=$(bun x playwright --version | cut -d' ' -f2)" >> $GITHUB_OUTPUT + + - name: Cache Playwright browsers + uses: actions/cache@v4 + id: playwright-cache + with: + path: ~/.cache/ms-playwright + key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }} + restore-keys: | + ${{ runner.os }}-playwright- - name: Install Playwright browsers + if: steps.playwright-cache.outputs.cache-hit != 'true' run: bun x playwright install --with-deps + - name: Install Playwright system dependencies + if: steps.playwright-cache.outputs.cache-hit == 'true' + run: bun x playwright install-deps + - name: Run e2e tests run: xvfb-run -a make test-e2e env: From 5313c012187dce35fe94ca381289d71c26eecd22 Mon Sep 17 00:00:00 2001 From: Ammar Date: Wed, 29 Oct 2025 23:02:56 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=A4=96=20refactor:=20extract=20Playwr?= =?UTF-8?q?ight=20setup=20to=20reusable=20action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Created .github/actions/setup-playwright composite action - Encapsulates browser caching, version detection, and conditional install - Replaced duplicated logic in storybook-test and e2e-test jobs - Net -38 lines of workflow YAML --- .github/actions/setup-playwright/action.yml | 28 ++++++++++++++ .github/workflows/ci.yml | 42 +-------------------- 2 files changed, 30 insertions(+), 40 deletions(-) create mode 100644 .github/actions/setup-playwright/action.yml diff --git a/.github/actions/setup-playwright/action.yml b/.github/actions/setup-playwright/action.yml new file mode 100644 index 000000000..d565ce636 --- /dev/null +++ b/.github/actions/setup-playwright/action.yml @@ -0,0 +1,28 @@ +name: "Setup Playwright" +description: "Install Playwright browsers with caching" +runs: + using: "composite" + steps: + - name: Get Playwright version + id: playwright-version + shell: bash + run: echo "version=$(bun x playwright --version | cut -d' ' -f2)" >> $GITHUB_OUTPUT + + - name: Cache Playwright browsers + uses: actions/cache@v4 + id: playwright-cache + with: + path: ~/.cache/ms-playwright + key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }} + restore-keys: | + ${{ runner.os }}-playwright- + + - name: Install Playwright browsers + if: steps.playwright-cache.outputs.cache-hit != 'true' + shell: bash + run: bun x playwright install --with-deps + + - name: Install Playwright system dependencies + if: steps.playwright-cache.outputs.cache-hit == 'true' + shell: bash + run: bun x playwright install-deps diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8adfe8e32..8d1741793 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -123,26 +123,7 @@ jobs: - uses: ./.github/actions/setup-cmux - - name: Get Playwright version - id: playwright-version - run: echo "version=$(bun x playwright --version | cut -d' ' -f2)" >> $GITHUB_OUTPUT - - - name: Cache Playwright browsers - uses: actions/cache@v4 - id: playwright-cache - with: - path: ~/.cache/ms-playwright - key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }} - restore-keys: | - ${{ runner.os }}-playwright- - - - name: Install Playwright browsers - if: steps.playwright-cache.outputs.cache-hit != 'true' - run: bun x playwright install --with-deps - - - name: Install Playwright system dependencies - if: steps.playwright-cache.outputs.cache-hit == 'true' - run: bun x playwright install-deps + - uses: ./.github/actions/setup-playwright - name: Build Storybook run: make storybook-build @@ -172,26 +153,7 @@ jobs: sudo apt-get update sudo apt-get install -y xvfb - - name: Get Playwright version - id: playwright-version - run: echo "version=$(bun x playwright --version | cut -d' ' -f2)" >> $GITHUB_OUTPUT - - - name: Cache Playwright browsers - uses: actions/cache@v4 - id: playwright-cache - with: - path: ~/.cache/ms-playwright - key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }} - restore-keys: | - ${{ runner.os }}-playwright- - - - name: Install Playwright browsers - if: steps.playwright-cache.outputs.cache-hit != 'true' - run: bun x playwright install --with-deps - - - name: Install Playwright system dependencies - if: steps.playwright-cache.outputs.cache-hit == 'true' - run: bun x playwright install-deps + - uses: ./.github/actions/setup-playwright - name: Run e2e tests run: xvfb-run -a make test-e2e From 3a5e1c394f96ac52c6645d91a5ec3ddb7fe727f0 Mon Sep 17 00:00:00 2001 From: Ammar Date: Fri, 31 Oct 2025 17:58:12 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=A4=96=20perf:=20maximize=20CI=20cach?= =?UTF-8?q?ing=20across=20all=20platforms?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Playwright optimizations: - Skip install-deps entirely on cache hit (saves ~54s apt operations) - Only run full install --with-deps on cache miss - System deps are part of runner image, no need to reinstall macOS optimizations: - Cache Homebrew downloads directory (~236 MB) - Prevents re-downloading native dependencies - Should reduce setup-cmux time from 100s to ~30-40s Expected improvements: - Storybook/E2E tests: 58s → 4s (cache restore only) - macOS builds: 100s → 30-40s (skip Homebrew downloads) --- .github/actions/setup-cmux/action.yml | 11 +++++++++++ .github/actions/setup-playwright/action.yml | 7 +------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/actions/setup-cmux/action.yml b/.github/actions/setup-cmux/action.yml index 4c1fb0d65..dc94d509a 100644 --- a/.github/actions/setup-cmux/action.yml +++ b/.github/actions/setup-cmux/action.yml @@ -18,6 +18,17 @@ runs: shell: bash run: echo "version=$(bun --version)" >> $GITHUB_OUTPUT + - name: Cache Homebrew downloads (macOS) + if: runner.os == 'macOS' + uses: actions/cache@v4 + with: + path: | + ~/Library/Caches/Homebrew/downloads + ~/Library/Caches/Homebrew/Cask + key: ${{ runner.os }}-${{ runner.arch }}-homebrew-${{ hashFiles('**/bun.lock') }} + restore-keys: | + ${{ runner.os }}-${{ runner.arch }}-homebrew- + - name: Cache node_modules uses: actions/cache@v4 with: diff --git a/.github/actions/setup-playwright/action.yml b/.github/actions/setup-playwright/action.yml index d565ce636..3a7be4164 100644 --- a/.github/actions/setup-playwright/action.yml +++ b/.github/actions/setup-playwright/action.yml @@ -17,12 +17,7 @@ runs: restore-keys: | ${{ runner.os }}-playwright- - - name: Install Playwright browsers + - name: Install Playwright browsers and dependencies if: steps.playwright-cache.outputs.cache-hit != 'true' shell: bash run: bun x playwright install --with-deps - - - name: Install Playwright system dependencies - if: steps.playwright-cache.outputs.cache-hit == 'true' - shell: bash - run: bun x playwright install-deps