Skip to content

perf(ci): optimize CI pipeline with caching and parallel execution #382

perf(ci): optimize CI pipeline with caching and parallel execution

perf(ci): optimize CI pipeline with caching and parallel execution #382

Workflow file for this run

name: 🚀 CI Pipeline
# Optimized CI with:
# - Separate lint job (1x instead of 6x)
# - Cached build artifacts (5 rebuilds eliminated)
# - Parallel job execution
# - Smart test runner with change detection
on:
push:
branches: [main]
tags: ['*']
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
jobs:
# Separate lint job - runs once instead of 6x in matrix
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run lint
run: pnpm run lint --all
# Build job - runs once and caches artifacts
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build project
run: pnpm run build
- name: Cache build artifacts
uses: actions/cache/save@v4
with:
path: |
dist
node_modules
key: build-${{ github.sha }}-${{ runner.os }}
# Test matrix - reuses build artifacts
test:
name: Test (Node ${{ matrix.node }} / ${{ matrix.os }})
needs: [lint, build]
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
node: [20, 22, 24]
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'
- name: Restore build artifacts
uses: actions/cache/restore@v4
with:
path: |
dist
node_modules
key: build-${{ github.sha }}-ubuntu-latest
fail-on-cache-miss: true
- name: Install dependencies (Windows)
if: runner.os == 'Windows'
run: pnpm install --frozen-lockfile
- name: Run tests
run: pnpm run test --fast --all
# Type check - reuses build artifacts
type-check:
name: Type Check
needs: build
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
- name: Restore build artifacts
uses: actions/cache/restore@v4
with:
path: |
dist
node_modules
key: build-${{ github.sha }}-${{ runner.os }}
fail-on-cache-miss: true
- name: Run type check
run: pnpm run check
# Status check job - used as required check in branch protection
ci-success:
name: CI Success
needs: [lint, build, test, type-check]
if: always()
runs-on: ubuntu-latest
steps:
- name: Check job results
run: |
if [ "${{ needs.lint.result }}" != "success" ] || \
[ "${{ needs.build.result }}" != "success" ] || \
[ "${{ needs.test.result }}" != "success" ] || \
[ "${{ needs.type-check.result }}" != "success" ]; then
echo "One or more jobs failed"
exit 1
fi
echo "All CI jobs passed successfully!"