|
| 1 | +# Continuous Integration Workflow |
| 2 | +# |
| 3 | +# This workflow runs on every push and pull request to ensure code quality. |
| 4 | +# It performs the following checks: |
| 5 | +# 1. Type checking (TypeScript compilation without emitting files) |
| 6 | +# 2. Linting (ESLint) |
| 7 | +# 3. Testing (Jest) |
| 8 | +# 4. Building (TypeScript compilation) |
| 9 | +# |
| 10 | +# The workflow uses pnpm as the package manager and supports multiple Node.js versions. |
| 11 | + |
| 12 | +name: CI |
| 13 | + |
| 14 | +# Trigger the workflow on push and pull requests |
| 15 | +on: |
| 16 | + push: |
| 17 | + branches: |
| 18 | + - main |
| 19 | + - develop |
| 20 | + - 'feature/**' |
| 21 | + - 'fix/**' |
| 22 | + - 'hotfix/**' |
| 23 | + - 'release/**' |
| 24 | + pull_request: |
| 25 | + branches: |
| 26 | + - main |
| 27 | + - develop |
| 28 | + |
| 29 | +# Allow only one concurrent workflow per branch |
| 30 | +concurrency: |
| 31 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 32 | + cancel-in-progress: true |
| 33 | + |
| 34 | +jobs: |
| 35 | + # Main CI job that runs all checks |
| 36 | + ci: |
| 37 | + name: CI Checks |
| 38 | + runs-on: ubuntu-latest |
| 39 | + |
| 40 | + # Strategy to test against multiple Node.js versions |
| 41 | + strategy: |
| 42 | + matrix: |
| 43 | + node-version: [20.x, 22.x] |
| 44 | + fail-fast: false |
| 45 | + |
| 46 | + steps: |
| 47 | + # Checkout the repository code |
| 48 | + - name: Checkout code |
| 49 | + uses: actions/checkout@v4 |
| 50 | + |
| 51 | + # Setup pnpm package manager |
| 52 | + - name: Setup pnpm |
| 53 | + uses: pnpm/action-setup@v4 |
| 54 | + with: |
| 55 | + version: 8 |
| 56 | + |
| 57 | + # Setup Node.js with the version from matrix |
| 58 | + - name: Setup Node.js ${{ matrix.node-version }} |
| 59 | + uses: actions/setup-node@v4 |
| 60 | + with: |
| 61 | + node-version: ${{ matrix.node-version }} |
| 62 | + cache: 'pnpm' |
| 63 | + |
| 64 | + # Install dependencies |
| 65 | + - name: Install dependencies |
| 66 | + run: pnpm install --frozen-lockfile |
| 67 | + |
| 68 | + # Run TypeScript type checking |
| 69 | + - name: Type check |
| 70 | + run: pnpm check |
| 71 | + |
| 72 | + # Run ESLint to check code quality |
| 73 | + - name: Lint |
| 74 | + run: pnpm lint |
| 75 | + continue-on-error: false |
| 76 | + |
| 77 | + # Run tests with Jest |
| 78 | + - name: Test |
| 79 | + run: pnpm test |
| 80 | + env: |
| 81 | + NODE_ENV: test |
| 82 | + |
| 83 | + # Build the TypeScript project |
| 84 | + - name: Build |
| 85 | + run: pnpm build |
| 86 | + |
| 87 | + # Upload test coverage reports (optional, for coverage visualization) |
| 88 | + - name: Upload coverage reports |
| 89 | + if: matrix.node-version == '20.x' |
| 90 | + uses: codecov/codecov-action@v4 |
| 91 | + with: |
| 92 | + file: ./coverage/lcov.info |
| 93 | + flags: unittests |
| 94 | + name: codecov-umbrella |
| 95 | + fail_ci_if_error: false |
| 96 | + |
| 97 | + # Separate job for security checks (dependencies vulnerability scanning) |
| 98 | + security: |
| 99 | + name: Security Audit |
| 100 | + runs-on: ubuntu-latest |
| 101 | + |
| 102 | + steps: |
| 103 | + - name: Checkout code |
| 104 | + uses: actions/checkout@v4 |
| 105 | + |
| 106 | + - name: Setup pnpm |
| 107 | + uses: pnpm/action-setup@v4 |
| 108 | + with: |
| 109 | + version: 8 |
| 110 | + |
| 111 | + - name: Setup Node.js |
| 112 | + uses: actions/setup-node@v4 |
| 113 | + with: |
| 114 | + node-version: '20.x' |
| 115 | + cache: 'pnpm' |
| 116 | + |
| 117 | + - name: Install dependencies |
| 118 | + run: pnpm install --frozen-lockfile |
| 119 | + |
| 120 | + # Run pnpm audit to check for known vulnerabilities |
| 121 | + - name: Run security audit |
| 122 | + run: pnpm audit --audit-level=moderate |
| 123 | + continue-on-error: true |
0 commit comments