test-and-validate.yml•2.09 kB
name: CI
on:
  push:
    branches:
      - main
    paths-ignore:
      - '**/*.md'
      - 'docs/**'
      - 'README*'
      - 'CHANGELOG*'
  pull_request:
    paths-ignore:
      - '**/*.md'
      - 'docs/**'
      - 'README*'
      - 'CHANGELOG*'
  workflow_dispatch:
  workflow_call:
concurrency:
  group: ci-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
env:
  HUSKY: 0
jobs:
  ci:
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v4
      - name: Setup Node.js and pnpm
        uses: ./.github/actions/setup-node-pnpm
      - name: Lint
        run: pnpm lint
      - name: Typecheck
        run: pnpm typecheck
      - name: Build
        run: pnpm build
      - name: Test Unit
        run: pnpm test:unit
  # Parallel E2E tests - run automatically on every push/PR
  # Using 4 shards for ~75% faster execution (~4min total runtime)
  # Shard count is optimized for the current test suite size and CI runner capacity
  # To adjust shards: update E2E_SHARD_COUNT and matrix.shard array
  # Skip E2E tests for tag events to speed up releases
  test-e2e-parallel:
    runs-on: ubuntu-latest
    needs: ci
    if: github.ref_type != 'tag'
    env:
      E2E_SHARD_COUNT: 4 # Configure number of parallel shards (adjust based on test suite size)
    strategy:
      matrix:
        shard: [1, 2, 3, 4] # Update this array when changing E2E_SHARD_COUNT
      fail-fast: false # Run all shards even if one fails for comprehensive results
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v4
      - name: Setup Node.js and pnpm
        uses: ./.github/actions/setup-node-pnpm
      - name: Build
        run: pnpm build
      - name: Test E2E - Shard ${{ matrix.shard }}/${{ env.E2E_SHARD_COUNT }}
        run: |
          # Run E2E tests with sharding for maximum parallelism
          # Each shard runs a portion of the tests in parallel
          pnpm test:e2e --shard=${{ matrix.shard }}/${{ env.E2E_SHARD_COUNT }} --reporter=basic
        env:
          CI: true