From 9c731e852e04bc60ded38cf50e4745147bd6d383 Mon Sep 17 00:00:00 2001 From: Rohan Bansal Date: Mon, 24 Feb 2025 15:39:26 +0530 Subject: [PATCH] ci: add test coverage indicator --- .github/workflows/tests.yml | 48 +++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7a8d8b86..a5099f02 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,17 +26,28 @@ jobs: beam: beam/** test: - name: ${{ matrix.package }} + name: ${{ matrix.package }} (test) needs: changes runs-on: ubuntu-latest strategy: matrix: package: ${{ fromJSON(needs.changes.outputs.packages) }} + include: + - branch: development + artifact: development + - branch: ${{ github.head_ref }} + artifact: pull-request + + permissions: + # Required to checkout the code + contents: read steps: - - name: Checkout + - name: Checkout (${{ matrix.branch }}) uses: actions/checkout@v4 + with: + ref: ${{ matrix.branch }} - name: Install Node uses: actions/setup-node@v4 @@ -55,10 +66,39 @@ jobs: working-directory: ./${{ matrix.package }} run: node ../common/scripts/install-run-rushx.js test:coverage - - name: Coverage Report - if: always() # generate the coverage report even if tests are failing + - name: Upload Coverage + if: always() # upload the coverage report even if tests are failing + uses: actions/upload-artifact@v4 + with: + name: coverage-${{ matrix.package }}-${{ matrix.artifact }} + path: ./${{ matrix.package }}/coverage + + coverage: + name: ${{ matrix.package }} (coverage) + needs: [changes, test] + runs-on: ubuntu-latest + + strategy: + matrix: + package: ${{ fromJSON(needs.changes.outputs.packages) }} + + steps: + - name: Download PR Branch Coverage + uses: actions/download-artifact@v4 + with: + name: coverage-${{ matrix.package }}-pull-request + path: coverage + + - name: Download Base Branch Coverage + uses: actions/download-artifact@v4 + with: + name: coverage-${{ matrix.package }}-development + path: coverage-${{ matrix.package }}-development + + - name: Report Coverage uses: davelosert/vitest-coverage-report-action@v2 with: working-directory: ./${{ matrix.package }} file-coverage-mode: 'all' vite-config-path: './vite.config.ts' + json-summary-compare-path: coverage-${{ matrix.package }}-development/coverage-summary.json