Skip to content

Commit c94e144

Browse files
committed
ci: resolve statsDir + move checkout earlier
1 parent 5316bd4 commit c94e144

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

.github/workflows/size-comment.yml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,18 @@ jobs:
1919
with:
2020
node-version: latest
2121

22+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
23+
with:
24+
sparse-checkout: scripts/parse-sizes.ts
25+
sparse-checkout-cone-mode: false
26+
2227
- name: ⏬ Download artifacts from workflow run
2328
uses: actions/download-artifact@v4
2429
with:
2530
github-token: ${{ secrets.GITHUB_TOKEN }}
2631
run-id: ${{ github.event.workflow_run.id }}
2732
path: .
2833

29-
- name: 🔍 Debug downloaded artifacts
30-
run: |
31-
echo "=== Downloaded artifacts structure ==="
32-
ls -la
33-
echo "=== head-stats contents ==="
34-
ls -la head-stats/ || echo "head-stats not found"
35-
echo "=== base-stats contents ==="
36-
ls -la base-stats/ || echo "base-stats not found"
37-
echo "=== pr-number contents ==="
38-
ls -la pr-number/ || echo "pr-number not found"
39-
4034
- name: 🔍 Get PR number from artifact
4135
id: pr
4236
run: |
@@ -49,11 +43,6 @@ jobs:
4943
echo "result=" >> $GITHUB_OUTPUT
5044
fi
5145
52-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
53-
with:
54-
sparse-checkout: scripts/parse-sizes.ts
55-
sparse-checkout-cone-mode: false
56-
5746
- name: 📊 Generate size comparison
5847
id: sizes
5948
run: |

scripts/parse-sizes.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { readFileSync } from 'node:fs'
22
import process from 'node:process'
3+
import { fileURLToPath } from 'node:url'
34

45
interface RollupStatsNode {
56
renderedLength?: number
@@ -103,7 +104,7 @@ function comparePackage(name: string, headPath: string, basePath: string): Packa
103104
/**
104105
* Generate markdown comment for size comparison
105106
*/
106-
export function generateSizeComment(packages: string[], statsDir = '.'): string {
107+
export function generateSizeComment(packages: string[], statsDir = process.cwd()): string {
107108
let commentBody = '## 📦 Bundle Size Comparison\n\n'
108109

109110
for (const pkg of packages) {
@@ -151,6 +152,7 @@ if (isMainModule) {
151152
process.exit(1)
152153
}
153154

154-
const comment = generateSizeComment(packages)
155+
const rootDir = fileURLToPath(new URL('..', import.meta.url))
156+
const comment = generateSizeComment(packages, rootDir)
155157
console.log(comment)
156158
}

0 commit comments

Comments
 (0)