|
12 | 12 | matrix: |
13 | 13 | node_version: |
14 | 14 | - 18 # end of life 2025-04-30 |
15 | | - - 20 # end of life 2025-04-30 |
| 15 | + - 20 # end of life 2025-04-30 # please update "Upload coverage file" step if you change this |
16 | 16 | name: build-lint-test - node ${{ matrix.node_version }} |
17 | 17 | steps: |
18 | 18 | - name: Check out Git repository |
|
44 | 44 | run: yarn lint |
45 | 45 |
|
46 | 46 | - name: Unit tests |
47 | | - run: yarn test:unit |
| 47 | + run: yarn test:unit --coverage |
48 | 48 |
|
49 | 49 | - name: Integration tests |
50 | | - run: (yarn server &) && sleep 1 && yarn test:integration |
| 50 | + run: (yarn server &) && sleep 1 && yarn test:integration --coverage |
| 51 | + |
| 52 | + - name: Merge coverage reports and generate lcov.info |
| 53 | + run: | |
| 54 | + mkdir -p .nyc_output |
| 55 | + npx nyc merge ./coverage |
| 56 | + npx nyc report --reporter=lcov --temp-dir ./coverage |
| 57 | +
|
| 58 | + - name: Upload coverage file |
| 59 | + uses: actions/upload-artifact@v4 |
| 60 | + if: ${{ matrix.node_version == '20' }} |
| 61 | + with: |
| 62 | + name: coverage-report |
| 63 | + path: ./coverage/lcov.info |
| 64 | + retention-days: 1 |
| 65 | + |
| 66 | + sonarcloud: |
| 67 | + name: Test and Code Quality Report (SonarCloud) |
| 68 | + needs: |
| 69 | + - build-lint-test |
| 70 | + runs-on: ubuntu-latest |
| 71 | + steps: |
| 72 | + - name: Check out Git repository |
| 73 | + uses: actions/checkout@v4 |
| 74 | + with: |
| 75 | + fetch-depth: 0 |
| 76 | + |
| 77 | + - name: Download coverage file |
| 78 | + uses: actions/download-artifact@v4 |
| 79 | + with: |
| 80 | + name: coverage-report |
| 81 | + |
| 82 | + - name: Move the coverage file to a proper location |
| 83 | + run: | |
| 84 | + mkdir -p coverage |
| 85 | + mv lcov.info coverage/lcov.info |
| 86 | +
|
| 87 | + - name: Verify coverage file ready |
| 88 | + run: ls -lah ./coverage/lcov.info |
| 89 | + |
| 90 | + - name: SonarCloud Scan |
| 91 | + uses: SonarSource/sonarcloud-github-action@v2 |
| 92 | + with: |
| 93 | + args: > |
| 94 | + -Dsonar.projectVersion=${{ github.run_id }} |
| 95 | + env: |
| 96 | + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |
| 97 | + SONAR_TOKEN: ${{ secrets.SONAR_CLOUD_TOKEN }} |
0 commit comments