refactor(coverage): Replace per-package thresholds with GitHub Actions workflow #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Coverage Report | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| concurrency: | |
| group: coverage-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # Runs on both push to main and PRs | |
| coverage: | |
| name: Coverage | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup environment | |
| uses: MetaMask/action-checkout-and-setup@v2 | |
| with: | |
| is-high-risk-environment: false | |
| node-version: 24.x | |
| env: | |
| PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 | |
| - name: Build | |
| run: yarn build | |
| - name: Run tests with coverage | |
| run: yarn vitest run --coverage | |
| # On push to main, upload as the baseline for future PRs | |
| - name: Upload baseline coverage | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: coverage-baseline | |
| path: coverage/ | |
| retention-days: 90 | |
| # On push to main, deploy HTML coverage report to GitHub Pages | |
| - name: Deploy coverage to GitHub Pages | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./coverage | |
| destination_dir: coverage | |
| # On PRs, upload as PR coverage for the report job | |
| - name: Upload PR coverage | |
| if: github.event_name == 'pull_request' | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: coverage-pr | |
| path: coverage/ | |
| retention-days: 7 | |
| # Only runs on PRs to generate the comparison report | |
| report: | |
| name: Report | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| needs: coverage | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Download PR coverage | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: coverage-pr | |
| path: coverage/ | |
| - name: Download baseline coverage from main | |
| uses: actions/download-artifact@v7 | |
| with: | |
| branch: main | |
| name: coverage-baseline | |
| path: coverage-base/ | |
| workflow_conclusion: success | |
| if_no_artifact_found: warn | |
| - name: Post coverage report | |
| uses: davelosert/vitest-coverage-report-action@5b6122e3a819a3be7b27fc961b7faafb3bf00e4d | |
| with: | |
| json-summary-path: coverage/coverage-summary.json | |
| json-final-path: coverage/coverage-final.json | |
| json-summary-compare-path: coverage-base/coverage-summary.json | |
| file-coverage-mode: changes | |
| - name: Post coverage report link | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: '📊 [View full HTML coverage report for `main`](https://metamask.github.io/ocap-kernel/coverage/)' | |
| }) |