|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + lint-and-type-check: |
| 11 | + name: Lint and Type Check |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout code |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Setup Node.js |
| 19 | + uses: actions/setup-node@v4 |
| 20 | + with: |
| 21 | + node-version: '20' |
| 22 | + |
| 23 | + - name: Setup pnpm |
| 24 | + uses: pnpm/action-setup@v2 |
| 25 | + with: |
| 26 | + version: 8 |
| 27 | + |
| 28 | + - name: Get pnpm store directory |
| 29 | + id: pnpm-cache |
| 30 | + shell: bash |
| 31 | + run: | |
| 32 | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT |
| 33 | +
|
| 34 | + - name: Setup pnpm cache |
| 35 | + uses: actions/cache@v4 |
| 36 | + with: |
| 37 | + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} |
| 38 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 39 | + restore-keys: | |
| 40 | + ${{ runner.os }}-pnpm-store- |
| 41 | +
|
| 42 | + - name: Install dependencies |
| 43 | + run: pnpm install --frozen-lockfile |
| 44 | + |
| 45 | + - name: Run ESLint |
| 46 | + run: pnpm lint || echo "ESLint found issues but continuing..." |
| 47 | + continue-on-error: true |
| 48 | + |
| 49 | + - name: Type check |
| 50 | + run: pnpm tsc --noEmit || echo "TypeScript check found issues but continuing..." |
| 51 | + continue-on-error: true |
| 52 | + |
| 53 | + build: |
| 54 | + name: Build |
| 55 | + runs-on: ubuntu-latest |
| 56 | + needs: lint-and-type-check |
| 57 | + |
| 58 | + steps: |
| 59 | + - name: Checkout code |
| 60 | + uses: actions/checkout@v4 |
| 61 | + |
| 62 | + - name: Setup Node.js |
| 63 | + uses: actions/setup-node@v4 |
| 64 | + with: |
| 65 | + node-version: '20' |
| 66 | + |
| 67 | + - name: Setup pnpm |
| 68 | + uses: pnpm/action-setup@v2 |
| 69 | + with: |
| 70 | + version: 8 |
| 71 | + |
| 72 | + - name: Get pnpm store directory |
| 73 | + id: pnpm-cache |
| 74 | + shell: bash |
| 75 | + run: | |
| 76 | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT |
| 77 | +
|
| 78 | + - name: Setup pnpm cache |
| 79 | + uses: actions/cache@v4 |
| 80 | + with: |
| 81 | + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} |
| 82 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 83 | + restore-keys: | |
| 84 | + ${{ runner.os }}-pnpm-store- |
| 85 | +
|
| 86 | + - name: Install dependencies |
| 87 | + run: pnpm install --frozen-lockfile |
| 88 | + |
| 89 | + - name: Create .env.local for build |
| 90 | + run: | |
| 91 | + cat > .env.local << EOF |
| 92 | + NEXT_PUBLIC_SUPABASE_URL=https://placeholder.supabase.co |
| 93 | + NEXT_PUBLIC_SUPABASE_ANON_KEY=placeholder-key |
| 94 | + OLLAMA_URL=http://localhost:11434 |
| 95 | + OLLAMA_MODEL=deepseek-r1:7b |
| 96 | + EOF |
| 97 | +
|
| 98 | + - name: Build Next.js app |
| 99 | + run: pnpm build |
| 100 | + env: |
| 101 | + NEXT_PUBLIC_SUPABASE_URL: https://placeholder.supabase.co |
| 102 | + NEXT_PUBLIC_SUPABASE_ANON_KEY: placeholder-key |
| 103 | + |
| 104 | + check-format: |
| 105 | + name: Check Code Formatting |
| 106 | + runs-on: ubuntu-latest |
| 107 | + |
| 108 | + steps: |
| 109 | + - name: Checkout code |
| 110 | + uses: actions/checkout@v4 |
| 111 | + |
| 112 | + - name: Setup Node.js |
| 113 | + uses: actions/setup-node@v4 |
| 114 | + with: |
| 115 | + node-version: '20' |
| 116 | + |
| 117 | + - name: Setup pnpm |
| 118 | + uses: pnpm/action-setup@v2 |
| 119 | + with: |
| 120 | + version: 8 |
| 121 | + |
| 122 | + - name: Install dependencies |
| 123 | + run: pnpm install --frozen-lockfile |
| 124 | + |
| 125 | + - name: Check formatting (if prettier is configured) |
| 126 | + run: | |
| 127 | + if command -v prettier &> /dev/null; then |
| 128 | + echo "Prettier found, checking formatting..." |
| 129 | + pnpm prettier --check . || echo "Formatting issues found but continuing..." |
| 130 | + else |
| 131 | + echo "Prettier not installed, skipping format check" |
| 132 | + fi |
| 133 | + shell: bash |
| 134 | + continue-on-error: true |
| 135 | + |
| 136 | + security-scan: |
| 137 | + name: Security Scan |
| 138 | + runs-on: ubuntu-latest |
| 139 | + |
| 140 | + steps: |
| 141 | + - name: Checkout code |
| 142 | + uses: actions/checkout@v4 |
| 143 | + |
| 144 | + - name: Setup Node.js |
| 145 | + uses: actions/setup-node@v4 |
| 146 | + with: |
| 147 | + node-version: '20' |
| 148 | + |
| 149 | + - name: Setup pnpm |
| 150 | + uses: pnpm/action-setup@v2 |
| 151 | + with: |
| 152 | + version: 8 |
| 153 | + |
| 154 | + - name: Install dependencies |
| 155 | + run: pnpm install --frozen-lockfile |
| 156 | + |
| 157 | + - name: Run security audit |
| 158 | + run: pnpm audit --audit-level=high |
| 159 | + continue-on-error: true |
| 160 | + |
| 161 | + status-check: |
| 162 | + name: All Checks Passed |
| 163 | + runs-on: ubuntu-latest |
| 164 | + needs: [lint-and-type-check, build, check-format, security-scan] |
| 165 | + if: always() |
| 166 | + |
| 167 | + steps: |
| 168 | + - name: Check status |
| 169 | + run: | |
| 170 | + echo "Lint and Type Check: ${{ needs.lint-and-type-check.result }}" |
| 171 | + echo "Build: ${{ needs.build.result }}" |
| 172 | + echo "Check Format: ${{ needs.check-format.result }}" |
| 173 | + echo "Security Scan: ${{ needs.security-scan.result }}" |
| 174 | + |
| 175 | + if [ "${{ needs.build.result }}" != "success" ]; then |
| 176 | + echo "Build failed! This is required." |
| 177 | + exit 1 |
| 178 | + fi |
| 179 | + |
| 180 | + if [ "${{ needs.lint-and-type-check.result }}" != "success" ]; then |
| 181 | + echo "Lint/Type check had issues (non-blocking)" |
| 182 | + fi |
| 183 | + |
| 184 | + echo "All required checks passed!" |
0 commit comments