|
71 | 71 | - name: Test
|
72 | 72 | id: test
|
73 | 73 | run: |
|
74 |
| - pnpm test:vitest --shard=${{ matrix.shardIndex}}/${{ matrix.shardTotal }} |
| 74 | + ARGS="--shard=${{ matrix.shardIndex}}/${{ matrix.shardTotal }}" |
| 75 | + if [ "${{ matrix.node }}" == "20" ]; then |
| 76 | + # We only gather coverage from a single Node version. |
| 77 | + # We pass in `--reporter=blob` so that we can combine the results from all shards. |
| 78 | + ARGS="$ARGS --coverage --reporter=default --reporter=blob" |
| 79 | + fi |
| 80 | + pnpm test:vitest $ARGS |
75 | 81 | env:
|
76 | 82 | GITHUB_SHARD_IDENTIFIER: ${{ matrix.shardIndex }}-${{ matrix.shardTotal }}
|
| 83 | + |
| 84 | + - name: Upload blob report to GitHub Actions Artifacts |
| 85 | + if: ${{ !cancelled() && matrix.node == '20' }} |
| 86 | + uses: actions/upload-artifact@v4 |
| 87 | + with: |
| 88 | + name: blob-report-${{ github.run_id }}-${{ matrix.shardIndex }} |
| 89 | + path: '.vitest-reports/*' |
| 90 | + include-hidden-files: true |
| 91 | + retention-days: 1 |
| 92 | + |
| 93 | + report-coverage: |
| 94 | + if: ${{ !cancelled() }} |
| 95 | + needs: test |
| 96 | + runs-on: ubuntu-latest |
| 97 | + |
| 98 | + steps: |
| 99 | + - name: Checkout |
| 100 | + uses: actions/checkout@v4 |
| 101 | + |
| 102 | + - name: Setup node |
| 103 | + uses: actions/setup-node@v4 |
| 104 | + with: |
| 105 | + node-version: 20 |
| 106 | + |
| 107 | + - uses: pnpm/action-setup@v4 |
| 108 | + name: Install pnpm |
| 109 | + id: pnpm-install |
| 110 | + with: |
| 111 | + run_install: false |
| 112 | + |
| 113 | + - name: Get pnpm store directory |
| 114 | + id: pnpm-cache |
| 115 | + shell: bash |
| 116 | + run: | |
| 117 | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT |
| 118 | +
|
| 119 | + - name: Cache node modules |
| 120 | + id: cache-node-modules |
| 121 | + uses: actions/cache@v4 |
| 122 | + env: |
| 123 | + cache-name: cache-node-modules |
| 124 | + with: |
| 125 | + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} |
| 126 | + key: ${{ runner.os }}-pnpm-store-${{ env.cache-name }}-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 127 | + restore-keys: | |
| 128 | + v1-${{ runner.os }}-pnpm-store-${{ env.cache-name }}- |
| 129 | + v1-${{ runner.os }}-pnpm-store- |
| 130 | + v1-${{ runner.os }}- |
| 131 | +
|
| 132 | + - name: Install project dependencies |
| 133 | + run: pnpm install |
| 134 | + |
| 135 | + - name: "Download coverage artifacts" |
| 136 | + uses: actions/download-artifact@v4 |
| 137 | + with: |
| 138 | + path: .vitest-reports |
| 139 | + pattern: blob-report-${{ github.run_id }}-* |
| 140 | + merge-multiple: true |
| 141 | + |
| 142 | + - name: Merged report |
| 143 | + run: | |
| 144 | + pnpm vitest run --merge-reports --coverage |
| 145 | +
|
| 146 | + - name: Report coverage |
| 147 | + uses: davelosert/vitest-coverage-report-action@v2 |
| 148 | + |
0 commit comments