Skip to content

ci: disable turborepo caching for tests #214

ci: disable turborepo caching for tests

ci: disable turborepo caching for tests #214

Workflow file for this run

# GitHub Actions workflow for running Playwright end-to-end tests
# Features:
# - Automated testing on push/PR
# - Environment setup
# - Cache hit detection for builds
# - Test execution
# - Results reporting
# - Deployment trigger
#
# By Dulapah Vibulsanti (https://dulapahv.dev)
name: 🎭 Playwright Tests
permissions:
contents: read
actions: write
checks: write
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
jobs:
test:
name: 🧪 Run E2E Tests
timeout-minutes: 60
runs-on: ubuntu-latest
env:
CI: true
SENTRY_SUPPRESS_TURBOPACK_WARNING: 1
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
BETTERSTACK_API_KEY: ${{ secrets.BETTERSTACK_API_KEY }}
steps:
# Checkout code
- name: 📥 Checkout code
uses: actions/checkout@v4
# Install pnpm
- name: 📦 Install pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
# Setup Node.js
- name: 🔧 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
# Turbo cache
- name: 💾 Cache Turbo
id: turbo-cache
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
# Next.js cache
- name: 💾 Cache Next.js bundle
id: nextjs-cache
uses: actions/cache@v4
with:
path: |
~/.pnpm-store
${{ github.workspace }}/apps/client/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('apps/client/src/**/*.{js,jsx,ts,tsx}') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
${{ runner.os }}-nextjs-
# Playwright browsers cache
- name: 💾 Cache Playwright browsers
id: cache-playwright
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-playwright-
# Check for client changes using turbo
- name: 🔍 Check for client changes
id: check-changes
run: |
# Install only the minimal dependencies needed for turbo
pnpm add -g turbo
# Run dry-run build to check for changes
if pnpm turbo build --filter=client --dry-run > /dev/null 2>&1; then
echo "No changes detected in client package"
echo "skip_build=true" >> $GITHUB_OUTPUT
else
echo "Changes detected in client package"
echo "skip_build=false" >> $GITHUB_OUTPUT
fi
# Install dependencies
- name: 🏗️ Install dependencies
if: steps.check-changes.outputs.skip_build != 'true'
run: pnpm install
# Build packages
- name: 🔨 Build packages
if: steps.check-changes.outputs.skip_build != 'true'
run: pnpm build
# Install Playwright browsers
- name: 🎭 Install Playwright browsers
if: steps.cache-playwright.outputs.cache-hit != 'true'
run: pnpm --filter client exec playwright install --with-deps
# Run Playwright tests
- name: 🧪 Run Playwright tests
run: pnpm test:client
# Upload test results
- name: 📊 Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: |
apps/client/playwright-report/
apps/client/test-results.xml
retention-days: 30
# Upload test screenshots on failure
- name: 📸 Upload test screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-screenshots
path: apps/client/test-results/
retention-days: 30
# Trigger Vercel deployment if tests pass
- name: 🚀 Trigger Vercel Deployment
if: success() && steps.check-changes.outputs.skip_build != 'true' && github.ref == 'refs/heads/main'
run: |
curl -X POST "${{ secrets.VERCEL_DEPLOY_HOOK }}"