|
| 1 | +name: Code Coverage |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, 'release/*', 'feature/*'] |
| 6 | + pull_request: |
| 7 | + branches: [main, 'release/*'] |
| 8 | + |
| 9 | +jobs: |
| 10 | + coverage: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + name: Run tests and upload coverage |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 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: Install dependencies |
| 24 | + run: | |
| 25 | + echo "📦 Installing dependencies..." |
| 26 | + npm install |
| 27 | + echo "✅ Dependencies installed" |
| 28 | +
|
| 29 | + - name: Build TypeScript |
| 30 | + run: | |
| 31 | + echo "🔨 Building TypeScript..." |
| 32 | + npm run build |
| 33 | + echo "✅ Build complete" |
| 34 | +
|
| 35 | + - name: Run tests with coverage |
| 36 | + run: | |
| 37 | + echo "🧪 Running tests with coverage..." |
| 38 | + npm test -- --coverage --coverageReporters=lcov |
| 39 | + echo "✅ Tests complete" |
| 40 | +
|
| 41 | + - name: Upload coverage to Codecov |
| 42 | + uses: codecov/codecov-action@v4 |
| 43 | + with: |
| 44 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 45 | + files: ./coverage/lcov.info |
| 46 | + flags: unittests |
| 47 | + name: codecov-umbrella |
| 48 | + fail_ci_if_error: false |
| 49 | + verbose: true |
| 50 | + |
| 51 | + - name: Coverage summary |
| 52 | + run: | |
| 53 | + echo "" |
| 54 | + echo "==========================================" |
| 55 | + echo "📊 Code Coverage Report" |
| 56 | + echo "==========================================" |
| 57 | + if [ -f coverage/coverage-summary.json ]; then |
| 58 | + echo "Coverage data generated successfully" |
| 59 | + echo "Report uploaded to Codecov" |
| 60 | + else |
| 61 | + echo "⚠️ No coverage summary found" |
| 62 | + fi |
| 63 | + echo "" |
0 commit comments