|
| 1 | +name: CI - Build and Test |
| 2 | + |
| 3 | +on: |
| 4 | + # Trigger on pull requests to main branch |
| 5 | + pull_request: |
| 6 | + branches: [ main, master ] |
| 7 | + |
| 8 | + # Trigger on pushes to main branch (merges) |
| 9 | + push: |
| 10 | + branches: [ main, master ] |
| 11 | + |
| 12 | + # Allow manual trigger |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +jobs: |
| 16 | + build-and-test: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + node-version: [18.x, 20.x] |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout code |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Setup Node.js ${{ matrix.node-version }} |
| 28 | + uses: actions/setup-node@v4 |
| 29 | + with: |
| 30 | + node-version: ${{ matrix.node-version }} |
| 31 | + cache: 'npm' |
| 32 | + |
| 33 | + - name: Install dependencies |
| 34 | + run: npm ci |
| 35 | + |
| 36 | + - name: Run tests |
| 37 | + run: npm test |
| 38 | + continue-on-error: false |
| 39 | + env: |
| 40 | + CI: true |
| 41 | + |
| 42 | + - name: Build application |
| 43 | + run: npm run build |
| 44 | + continue-on-error: false |
| 45 | + env: |
| 46 | + CI: true |
| 47 | + |
| 48 | + - name: Check build output |
| 49 | + run: | |
| 50 | + if [ ! -d ".next" ]; then |
| 51 | + echo "Build failed - .next directory not found" |
| 52 | + exit 1 |
| 53 | + fi |
| 54 | + echo "Build successful - .next directory exists" |
| 55 | + |
| 56 | + - name: Upload build artifacts (on failure) |
| 57 | + if: failure() |
| 58 | + uses: actions/upload-artifact@v4 |
| 59 | + with: |
| 60 | + name: build-logs-${{ matrix.node-version }} |
| 61 | + path: | |
| 62 | + .next/ |
| 63 | + npm-debug.log* |
| 64 | + yarn-debug.log* |
| 65 | + yarn-error.log* |
| 66 | + retention-days: 5 |
| 67 | + |
| 68 | + # Additional job for documentation build (if needed) |
| 69 | + build-docs: |
| 70 | + runs-on: ubuntu-latest |
| 71 | + if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' |
| 72 | + |
| 73 | + steps: |
| 74 | + - name: Checkout code |
| 75 | + uses: actions/checkout@v4 |
| 76 | + |
| 77 | + - name: Setup Node.js |
| 78 | + uses: actions/setup-node@v4 |
| 79 | + with: |
| 80 | + node-version: '20.x' |
| 81 | + cache: 'npm' |
| 82 | + |
| 83 | + - name: Install main dependencies |
| 84 | + run: npm ci |
| 85 | + |
| 86 | + - name: Install documentation dependencies |
| 87 | + run: | |
| 88 | + cd documentation |
| 89 | + npm ci |
| 90 | + |
| 91 | + - name: Build documentation |
| 92 | + run: | |
| 93 | + cd documentation |
| 94 | + npm run build |
| 95 | + continue-on-error: false |
| 96 | + |
| 97 | + # Security and quality checks |
| 98 | + security-audit: |
| 99 | + runs-on: ubuntu-latest |
| 100 | + |
| 101 | + steps: |
| 102 | + - name: Checkout code |
| 103 | + uses: actions/checkout@v4 |
| 104 | + |
| 105 | + - name: Setup Node.js |
| 106 | + uses: actions/setup-node@v4 |
| 107 | + with: |
| 108 | + node-version: '20.x' |
| 109 | + cache: 'npm' |
| 110 | + |
| 111 | + - name: Install dependencies |
| 112 | + run: npm ci |
| 113 | + |
| 114 | + - name: Run security audit |
| 115 | + run: npm audit --audit-level=high |
| 116 | + continue-on-error: true |
| 117 | + |
| 118 | + - name: Check for outdated packages |
| 119 | + run: npm outdated || true |
0 commit comments