|
| 1 | +name: Test Suite |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, develop] |
| 6 | + pull_request: |
| 7 | + branches: [main, develop] |
| 8 | + schedule: |
| 9 | + # Run tests daily at 2 AM UTC |
| 10 | + - cron: "0 2 * * *" |
| 11 | + |
| 12 | +env: |
| 13 | + NODE_ENV: test |
| 14 | + |
| 15 | +jobs: |
| 16 | + unit-tests: |
| 17 | + name: Unit Tests (Node ${{ matrix.node-version }}) |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + node-version: [18.x, 20.x, 22.x] |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout repository |
| 27 | + uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - name: Setup Node.js ${{ matrix.node-version }} |
| 30 | + uses: actions/setup-node@v4 |
| 31 | + with: |
| 32 | + node-version: ${{ matrix.node-version }} |
| 33 | + cache: "npm" |
| 34 | + |
| 35 | + - name: Install dependencies |
| 36 | + run: npm ci |
| 37 | + |
| 38 | + - name: Run unit tests |
| 39 | + run: npm test |
| 40 | + |
| 41 | + - name: Generate coverage report |
| 42 | + if: matrix.node-version == '20.x' |
| 43 | + run: npm run test:coverage |
| 44 | + |
| 45 | + - name: Upload coverage to Codecov |
| 46 | + if: matrix.node-version == '20.x' |
| 47 | + uses: codecov/codecov-action@v3 |
| 48 | + with: |
| 49 | + file: ./coverage/lcov.info |
| 50 | + flags: unittests |
| 51 | + name: unit-tests |
| 52 | + fail_ci_if_error: false |
| 53 | + |
| 54 | + - name: Archive coverage artifacts |
| 55 | + if: matrix.node-version == '20.x' |
| 56 | + uses: actions/upload-artifact@v4 |
| 57 | + with: |
| 58 | + name: coverage-report |
| 59 | + path: coverage/ |
| 60 | + |
| 61 | + integration-tests: |
| 62 | + name: Integration Tests |
| 63 | + runs-on: ubuntu-latest |
| 64 | + needs: unit-tests |
| 65 | + |
| 66 | + steps: |
| 67 | + - name: Checkout repository |
| 68 | + uses: actions/checkout@v4 |
| 69 | + |
| 70 | + - name: Setup Node.js 20.x |
| 71 | + uses: actions/setup-node@v4 |
| 72 | + with: |
| 73 | + node-version: 20.x |
| 74 | + cache: "npm" |
| 75 | + |
| 76 | + - name: Install dependencies |
| 77 | + run: npm ci |
| 78 | + |
| 79 | + - name: Create test environment file |
| 80 | + run: | |
| 81 | + cp .env.example .env |
| 82 | + echo "NODE_ENV=test" >> .env |
| 83 | +
|
| 84 | + - name: Build project |
| 85 | + run: npm run build |
| 86 | + |
| 87 | + - name: Run integration tests |
| 88 | + run: npm test -- --testPathPattern=integration |
| 89 | + continue-on-error: true |
| 90 | + |
| 91 | + - name: Run demo scripts (dry run) |
| 92 | + run: | |
| 93 | + echo "Testing demo scripts..." |
| 94 | + # Add any demo script tests here if needed |
| 95 | + echo "Demo scripts validation completed" |
| 96 | +
|
| 97 | + code-quality: |
| 98 | + name: Code Quality Checks |
| 99 | + runs-on: ubuntu-latest |
| 100 | + |
| 101 | + steps: |
| 102 | + - name: Checkout repository |
| 103 | + uses: actions/checkout@v4 |
| 104 | + |
| 105 | + - name: Setup Node.js 20.x |
| 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 ESLint |
| 115 | + run: npm run lint |
| 116 | + |
| 117 | + - name: Check TypeScript compilation |
| 118 | + run: npm run build |
| 119 | + |
| 120 | + - name: Verify build artifacts |
| 121 | + run: | |
| 122 | + test -f dist/index.js || (echo "Missing dist/index.js" && exit 1) |
| 123 | + test -f dist/index.d.ts || (echo "Missing dist/index.d.ts" && exit 1) |
| 124 | + echo "Build artifacts verified successfully" |
| 125 | +
|
| 126 | + - name: Check for TypeScript errors |
| 127 | + run: npx tsc --noEmit |
| 128 | + |
| 129 | + dependency-audit: |
| 130 | + name: Security Audit |
| 131 | + runs-on: ubuntu-latest |
| 132 | + |
| 133 | + steps: |
| 134 | + - name: Checkout repository |
| 135 | + uses: actions/checkout@v4 |
| 136 | + |
| 137 | + - name: Setup Node.js 20.x |
| 138 | + uses: actions/setup-node@v4 |
| 139 | + with: |
| 140 | + node-version: 20.x |
| 141 | + cache: "npm" |
| 142 | + |
| 143 | + - name: Install dependencies |
| 144 | + run: npm ci |
| 145 | + |
| 146 | + - name: Run security audit |
| 147 | + run: npm audit --audit-level=moderate |
| 148 | + |
| 149 | + - name: Check for outdated packages |
| 150 | + run: npm outdated || true |
0 commit comments