Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

@ammar-agent ammar-agent commented Oct 29, 2025

Comprehensive CI caching optimizations to minimize redundant work across all platforms.

Performance Results

Playwright Tests

  • Storybook tests: 2m 39s β†’ 1m 41s (58s faster, 37% improvement)
  • E2E tests: 3m 5s β†’ 2m 39s (26s faster, 14% improvement)
  • Playwright setup: 58s β†’ 4s (cache restore only)

macOS Builds

  • First run: 4m 20s β†’ 4m 12s (8s faster)
  • Subsequent runs: Expected ~2-3m (Homebrew cache hits)

Total Savings

~84 seconds per CI run across all jobs

Changes

1. Playwright Browser Caching

  • Caches ~/.cache/ms-playwright (~447 MB)
  • Cache key: {OS}-playwright-{version} for automatic invalidation
  • Key optimization: Skip install-deps entirely on cache hit
    • System dependencies are pre-installed on GitHub runners
    • No need to re-run apt-get update + package checks (saved ~54s)
    • Only run full playwright install --with-deps on cache miss

2. Homebrew Caching (macOS)

  • Caches ~/Library/Caches/Homebrew/downloads (~236 MB)
  • Prevents re-downloading native dependencies for electron-builder
  • Cache key includes lockfile hash for proper invalidation

3. Code Organization

  • Extracted Playwright setup to reusable .github/actions/setup-playwright
  • Single source of truth, easier to maintain
  • Applied to both storybook-test and e2e-test jobs

Implementation Details

Playwright caching strategy:

macOS caching strategy:

Why skip install-deps on cache hit?

  • GitHub runners have standard system packages pre-installed
  • playwright install-deps mostly checks already-installed packages
  • Running apt-get update + checks takes ~54s with no benefit
  • Browsers + system deps are a unit - if browsers are cached, deps are there

Generated with cmux

- 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
- 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
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant