Merge pull request #8 from iddhi-sulakshana/main #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| jobs: | |
| lint-and-build: | |
| name: Lint and Build | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [18.x, 20.x] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Cache Bun dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.bun/install/cache | |
| key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }} | |
| restore-keys: | | |
| ${{ runner.os }}-bun- | |
| - name: Cache Next.js build | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ github.workspace }}/.next/cache | |
| key: ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lockb') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lockb') }}- | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Run ESLint | |
| run: bun run lint | |
| - name: Type check | |
| run: bun run type-check | |
| - name: Build project | |
| run: bun run build | |
| env: | |
| NODE_ENV: production | |
| - name: Upload build artifacts | |
| if: matrix.node-version == '20.x' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-output | |
| path: .next | |
| retention-days: 7 | |
| code-quality: | |
| name: Code Quality Checks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Check for console statements | |
| run: | | |
| echo "Checking for console statements..." | |
| ! git grep -n "console\." -- "*.ts" "*.tsx" "*.js" "*.jsx" || echo "Warning: Console statements found" | |
| continue-on-error: true | |
| - name: Check for TODO comments | |
| run: | | |
| echo "Checking for TODO comments..." | |
| git grep -n "TODO" -- "*.ts" "*.tsx" "*.js" "*.jsx" || echo "No TODOs found" | |
| continue-on-error: true | |
| status-check: | |
| name: All Checks Passed | |
| runs-on: ubuntu-latest | |
| needs: [lint-and-build, code-quality] | |
| if: always() | |
| steps: | |
| - name: Check if all jobs passed | |
| if: needs.lint-and-build.result != 'success' || needs.code-quality.result != 'success' | |
| run: | | |
| echo "One or more checks failed" | |
| exit 1 | |
| - name: All checks passed | |
| run: echo "✅ All CI checks passed successfully!" |