-
-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (82 loc) · 2.95 KB
/
bundle-size.yml
File metadata and controls
99 lines (82 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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"