|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +# Cancel in-progress runs for the same workflow + branch/PR |
| 13 | +concurrency: |
| 14 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +env: |
| 18 | + # NOTE: These versions should be detected from your project during installation |
| 19 | + # NODE_VERSION: Check package.json engines.node or use latest LTS |
| 20 | + # PNPM_VERSION: Check package.json packageManager field or use `pnpm --version` |
| 21 | + NODE_VERSION: "22" # REPLACE: Detected during /repo-tooling installation |
| 22 | + PNPM_VERSION: "10" # REPLACE: Detected during /repo-tooling installation |
| 23 | + |
| 24 | +jobs: |
| 25 | + # Job 1: Code Quality Checks (Lint, Format, Type Check) |
| 26 | + quality: |
| 27 | + name: 🔍 Code Quality |
| 28 | + runs-on: ubuntu-latest |
| 29 | + timeout-minutes: 5 |
| 30 | + |
| 31 | + steps: |
| 32 | + - name: 📥 Checkout repository |
| 33 | + uses: actions/checkout@v5 |
| 34 | + with: |
| 35 | + fetch-depth: 0 |
| 36 | + |
| 37 | + - name: 📦 Setup pnpm |
| 38 | + uses: pnpm/action-setup@v4 |
| 39 | + with: |
| 40 | + version: ${{ env.PNPM_VERSION }} |
| 41 | + |
| 42 | + - name: ⚙️ Setup Node.js ${{ env.NODE_VERSION }} |
| 43 | + uses: actions/setup-node@v5 |
| 44 | + with: |
| 45 | + node-version: ${{ env.NODE_VERSION }} |
| 46 | + cache: "pnpm" |
| 47 | + |
| 48 | + - name: 📚 Install dependencies |
| 49 | + run: pnpm install --frozen-lockfile |
| 50 | + |
| 51 | + - name: 🔎 Run ESLint |
| 52 | + run: pnpm lint |
| 53 | + |
| 54 | + - name: ✨ Check code formatting with Prettier |
| 55 | + run: pnpm format:check |
| 56 | + |
| 57 | + - name: 🔧 Run TypeScript type checking |
| 58 | + run: pnpm type-check |
| 59 | + |
| 60 | + # Job 2: Unit & Integration Tests |
| 61 | + test: |
| 62 | + name: 🧪 Tests & Coverage |
| 63 | + runs-on: ubuntu-latest |
| 64 | + timeout-minutes: 5 |
| 65 | + |
| 66 | + steps: |
| 67 | + - name: 📥 Checkout repository |
| 68 | + uses: actions/checkout@v5 |
| 69 | + |
| 70 | + - name: 📦 Setup pnpm |
| 71 | + uses: pnpm/action-setup@v4 |
| 72 | + with: |
| 73 | + version: ${{ env.PNPM_VERSION }} |
| 74 | + |
| 75 | + - name: ⚙️ Setup Node.js ${{ env.NODE_VERSION }} |
| 76 | + uses: actions/setup-node@v5 |
| 77 | + with: |
| 78 | + node-version: ${{ env.NODE_VERSION }} |
| 79 | + cache: "pnpm" |
| 80 | + |
| 81 | + - name: 📚 Install dependencies |
| 82 | + run: pnpm install --frozen-lockfile |
| 83 | + |
| 84 | + - name: 🧪 Run test suite with coverage |
| 85 | + run: pnpm test:coverage |
| 86 | + env: |
| 87 | + NODE_ENV: test |
| 88 | + |
| 89 | + - name: 📦 Archive coverage reports |
| 90 | + uses: actions/upload-artifact@v4 |
| 91 | + if: always() |
| 92 | + with: |
| 93 | + name: coverage-report |
| 94 | + path: coverage/ |
| 95 | + retention-days: 7 |
| 96 | + |
| 97 | + # Job 3: Build Verification |
| 98 | + build: |
| 99 | + name: 🏗️ Production Build |
| 100 | + runs-on: ubuntu-latest |
| 101 | + timeout-minutes: 5 |
| 102 | + |
| 103 | + steps: |
| 104 | + - name: 📥 Checkout repository |
| 105 | + uses: actions/checkout@v5 |
| 106 | + |
| 107 | + - name: 📦 Setup pnpm |
| 108 | + uses: pnpm/action-setup@v4 |
| 109 | + with: |
| 110 | + version: ${{ env.PNPM_VERSION }} |
| 111 | + |
| 112 | + - name: ⚙️ Setup Node.js ${{ env.NODE_VERSION }} |
| 113 | + uses: actions/setup-node@v5 |
| 114 | + with: |
| 115 | + node-version: ${{ env.NODE_VERSION }} |
| 116 | + cache: "pnpm" |
| 117 | + |
| 118 | + - name: 📚 Install dependencies |
| 119 | + run: pnpm install --frozen-lockfile |
| 120 | + |
| 121 | + - name: 📦 Restore Next.js build cache |
| 122 | + uses: actions/cache@v4 |
| 123 | + with: |
| 124 | + path: .next/cache |
| 125 | + key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 126 | + |
| 127 | + - name: 🏗️ Build Next.js application |
| 128 | + run: pnpm build |
| 129 | + |
| 130 | + - name: ✅ Verify build output |
| 131 | + run: | |
| 132 | + if [ ! -d ".next" ]; then |
| 133 | + echo "❌ Error: .next directory not found" |
| 134 | + exit 1 |
| 135 | + fi |
| 136 | + echo "✅ Build successful! Output directory size:" |
| 137 | + du -sh .next |
| 138 | +
|
| 139 | + - name: 📦 Archive build artifacts |
| 140 | + uses: actions/upload-artifact@v4 |
| 141 | + with: |
| 142 | + name: build-output |
| 143 | + path: .next/ |
| 144 | + retention-days: 7 |
0 commit comments