docs: recommend job summary reports #53
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: Bundle Size Check | |
| on: | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| jobs: | |
| bundle-size: | |
| name: Check Bundle Size | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| checks: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: false | |
| - name: Set up pnpm | |
| uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8 | |
| with: | |
| version: 11.1.2 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: 24 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Run lint | |
| run: pnpm run lint | |
| - name: Run typecheck | |
| run: pnpm run typecheck | |
| - name: Run tests with coverage | |
| run: pnpm run test:ci | |
| - name: Publish test report | |
| uses: dorny/test-reporter@a43b3a5f7366b97d083190328d2c652e1a8b6aa2 # v3.0.0 | |
| if: ${{ !cancelled() && github.event.pull_request.head.repo.full_name == github.repository && hashFiles('reports/vitest-junit.xml') != '' }} | |
| with: | |
| name: Vitest Tests | |
| path: reports/vitest-junit.xml | |
| reporter: java-junit | |
| fail-on-error: false | |
| - name: Add coverage summary | |
| if: ${{ !cancelled() && hashFiles('coverage/coverage-summary.json') != '' }} | |
| run: | | |
| node <<'EOF' | |
| const fs = require('node:fs'); | |
| const summary = JSON.parse(fs.readFileSync('coverage/coverage-summary.json', 'utf8')).total; | |
| const metrics = ['lines', 'statements', 'functions', 'branches']; | |
| const rows = metrics.map((metric) => { | |
| const value = summary[metric]; | |
| const label = metric.charAt(0).toUpperCase() + metric.slice(1); | |
| return `| ${label} | ${value.covered} | ${value.total} | ${value.pct}% |`; | |
| }); | |
| fs.appendFileSync(process.env.GITHUB_STEP_SUMMARY, [ | |
| '## Coverage Summary', | |
| '', | |
| '| Metric | Covered | Total | Percent |', | |
| '|---|---:|---:|---:|', | |
| ...rows, | |
| '', | |
| ].join('\n')); | |
| EOF | |
| - name: Build action bundle | |
| run: pnpm run build | |
| - name: Prepare comparison fixture | |
| run: | | |
| mkdir -p bundle-size-fixture | |
| printf 'module.exports = true;\n' > bundle-size-fixture/index.js | |
| # Run the bundle-size action that lives in this repository. | |
| # Because the action is defined here, we reference it with the | |
| # special `./` prefix so GitHub Actions resolves it locally. | |
| - name: Run Bundle Size Action | |
| uses: ./ | |
| with: | |
| path: "bundle-size-fixture" | |
| package-name: "is-number" | |
| files: | | |
| index.js | |
| output-file: "bundle-size-comparison.json" |