Skip to content

improve test splitting #21

improve test splitting

improve test splitting #21

Workflow file for this run

name: PR Quality Gate
on:
pull_request:
branches: [ "leader" ]
workflow_dispatch:
inputs:
branch:
description: 'Branch to check'
required: true
default: 'leader'
env:
FORCE_COLOR: 1
# Global cache location for all jobs
PLAYWRIGHT_BROWSERS_PATH: ${{ github.workspace }}/.cache/ms-playwright
jobs:
# ===========================================================================
# JOB 1: INFRASTRUCTURE & BUILD
# Checks: Linting, Typos, Build Compilation, Commit Messages
# ===========================================================================
infra-check:
name: 🏗️ Infra & Build
runs-on: self-hosted
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4

Check failure on line 29 in .github/workflows/pr-quality.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/pr-quality.yml

Invalid workflow file

You have an error in your yaml syntax on line 29
with: { ref: ${{ inputs.branch || github.ref }}, fetch-depth: 0, clean: true }
# --- REPEATED SETUP (No Reusable Workflow) ---
- name: Install pnpm
uses: pnpm/action-setup@v4
with: { run_install: false }
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $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: Setup Node.js
uses: actions/setup-node@v4
with: { node-version: "20.x", cache-dependency-path: pnpm-lock.yaml }
- name: Configure pnpm & Install
run: |
pnpm config set side-effects-cache true
pnpm install --frozen-lockfile --prefer-offline
# ---------------------------------------------
- name: Create Runtime Envs
run: |
mkdir -p logs
echo "NEXTAUTH_URL=http://127.0.0.1:3000" > .env.local
echo "NEXTAUTH_SECRET=ci-secret" >> .env.local
- name: Lint Code
run: pnpm run lint
- name: Verify Build
run: pnpm run build
- name: Lint Commits
run: |
RANGE="origin/leader..HEAD"
if ! git rev-parse --verify origin/leader >/dev/null 2>&1; then RANGE="HEAD"; fi
git log --format=%s $RANGE | while read line; do
if [[ ! "$line" =~ ^(feat|fix|docs|style|refactor|test|chore|perf|ci)(\(.+\))?: ]]; then
echo "::error::Invalid Commit Message: $line"
exit 1
fi
done
# ===========================================================================
# JOB 2: CORE LOGIC TESTS
# Checks: Functional tests (API, Auth, State) - Skips visuals
# ===========================================================================
core-tests:
name: 🧪 Core Logic
runs-on: self-hosted
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
with: { ref: ${{ inputs.branch || github.ref }}, clean: true }
# --- REPEATED SETUP ---
- uses: pnpm/action-setup@v4
with: { run_install: false }
- id: pnpm-cache
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
- 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-
- uses: actions/setup-node@v4
with: { node-version: "20.x", cache-dependency-path: pnpm-lock.yaml }
- name: Cache Browsers
id: playwright-cache
uses: actions/cache@v4
with:
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-playwright-
- run: |
pnpm config set side-effects-cache true
pnpm install --frozen-lockfile --prefer-offline
- name: Install Playwright (Binary Only)
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: pnpm exec playwright install chromium
# ----------------------
- name: Create Runtime Envs
run: |
echo "NEXTAUTH_URL=http://127.0.0.1:3000" > .env.local
echo "NEXTAUTH_SECRET=ci-secret" >> .env.local
- name: Run Core Tests (Skip Visuals)
# Using CLI flag --grep-invert to skip tests tagged with @visual
run: pnpm exec playwright test --project=chromium --grep-invert "@visual"
# ===========================================================================
# JOB 3: VISUAL REGRESSION TESTS
# Checks: Screenshot comparisons
# ===========================================================================
visual-tests:
name: 🎨 Visual Regression
runs-on: self-hosted
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
with: { ref: ${{ inputs.branch || github.ref }}, clean: true }
# --- REPEATED SETUP ---
- uses: pnpm/action-setup@v4
with: { run_install: false }
- id: pnpm-cache
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
- 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-
- uses: actions/setup-node@v4
with: { node-version: "20.x", cache-dependency-path: pnpm-lock.yaml }
- name: Cache Browsers
id: playwright-cache
uses: actions/cache@v4
with:
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}
key: ${{ runner.os }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-playwright-
- run: |
pnpm config set side-effects-cache true
pnpm install --frozen-lockfile --prefer-offline
- name: Install Playwright (Binary Only)
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: pnpm exec playwright install chromium
# ----------------------
- name: Create Runtime Envs
run: |
echo "NEXTAUTH_URL=http://127.0.0.1:3000" > .env.local
echo "NEXTAUTH_SECRET=ci-secret" >> .env.local
- name: Run Visual Tests
# Using CLI flag --grep to ONLY run tests tagged with @visual
run: pnpm exec playwright test --project=chromium --grep "@visual"
- name: Upload Report on Failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-report-visual
path: playwright-report/
retention-days: 5