Loading...
Loading...
Optimizes GitHub Actions CI/CD workflows through test sharding, intelligent caching, and workflow parallelization. Use when CI execution time exceeds limits, costs are too high, or workflows need parallelization.
npx skill4agent add d-oit/do-novelist-ai ci-optimization-specialist.github/workflows/ci.ymle2e-tests:
name: 🧪 E2E Tests [Shard ${{ matrix.shard }}/3]
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3]
steps:
- name: Run Playwright tests
run: pnpm exec playwright test --shard=${{ matrix.shard }}/3
env:
CI: truematrix:
include:
- shard: 1
pattern: 'ai-generation|project-management' # Heavy tests
- shard: 2
pattern: 'project-wizard|settings|publishing' # Medium tests
- shard: 3
pattern: 'world-building|versioning|mock-validation' # Light tests
# In step:
run: pnpm exec playwright test --grep "${{ matrix.pattern }}"- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-- name: Cache Playwright browsers
uses: actions/cache@v4
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: pnpm exec playwright install --with-deps chromium
- name: Install Playwright system dependencies
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: pnpm exec playwright install-deps chromium- name: Cache Vite build
uses: actions/cache@v4
with:
path: |
dist/
node_modules/.vite/
key: ${{ runner.os }}-vite-${{ hashFiles('src/**', 'vite.config.ts') }}needsjobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Build
run: pnpm run build
- name: Run unit tests
run: pnpm test
e2e-tests:
needs: build-and-test # Wait for build to complete
runs-on: ubuntu-latest
strategy:
matrix:
shard: [1, 2, 3]
steps:
- name: Run E2E tests
run: pnpm exec playwright test --shard=${{ matrix.shard }}/3concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true- name: Upload Playwright report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report-shard-${{ matrix.shard }}-${{ github.sha }}
path: playwright-report/
retention-days: 7
compression-level: 6retention-days: 7 # Default is 90 days
compression-level: 6 # Compress to reduce storage| Optimization | Before | After | Improvement |
|---|---|---|---|
| Test sharding (3 shards) | 27 min | 9-10 min | 60-65% |
| pnpm cache hit | 2-3 min | 10-15s | 85-90% |
| Playwright cache hit | 1-2 min | 5-10s | 90-95% |
| Vite build cache | 1-2 min | 5-10s | 90-95% |
timeout-minutes: 30 # Fail if shard exceeds 30 minutesplaywright test --shard=1/3--grephashFilesplaywright install-deps