Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

Commit 5c01101

Browse files
committed
fix: fix bug in summary table construction
1 parent f6bd481 commit 5c01101

5 files changed

Lines changed: 29 additions & 19 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules/
22
coverage/
3+
*.social-preview*
4+
.DS_Store

dist/post/index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27845,16 +27845,18 @@ function formatMs(ms) {
2784527845

2784627846
function makeSummaryTable(resources) {
2784727847
const summaryTable = [
27848-
{ data: 'Bucket', header: true },
27849-
{ data: 'Used', header: true },
27850-
{ data: 'Remaining', header: true }
27848+
[
27849+
{ data: 'Bucket', header: true },
27850+
{ data: 'Used', header: true },
27851+
{ data: 'Remaining', header: true }
27852+
]
2785127853
];
2785227854
for (const [bucket, info] of Object.entries(resources)) {
27853-
summaryTable.push(
27855+
summaryTable.push([
2785427856
{ data: bucket },
2785527857
{ data: String(info.used) },
2785627858
{ data: String(info.remaining) }
27857-
);
27859+
]);
2785827860
}
2785927861

2786027862
return summaryTable;
@@ -28079,6 +28081,9 @@ async function run() {
2807928081
const outPath = (core.getInput('output_path') || '').trim();
2808028082
maybeWrite(outPath, output);
2808128083

28084+
log(
28085+
`[github-api-usage-tracker] Preparing summary table for ${Object.keys(data).length} bucket(s)`
28086+
);
2808228087
core.summary
2808328088
.addHeading('GitHub API Usage Tracker Summary')
2808428089
.addTable(makeSummaryTable(data))

src/post-utils.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@ function formatMs(ms) {
1818

1919
function makeSummaryTable(resources) {
2020
const summaryTable = [
21-
{ data: 'Bucket', header: true },
22-
{ data: 'Used', header: true },
23-
{ data: 'Remaining', header: true }
21+
[
22+
{ data: 'Bucket', header: true },
23+
{ data: 'Used', header: true },
24+
{ data: 'Remaining', header: true }
25+
]
2426
];
2527
for (const [bucket, info] of Object.entries(resources)) {
26-
summaryTable.push(
28+
summaryTable.push([
2729
{ data: bucket },
2830
{ data: String(info.used) },
2931
{ data: String(info.remaining) }
30-
);
32+
]);
3133
}
3234

3335
return summaryTable;

src/post.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ async function run() {
124124
const outPath = (core.getInput('output_path') || '').trim();
125125
maybeWrite(outPath, output);
126126

127+
log(
128+
`[github-api-usage-tracker] Preparing summary table for ${Object.keys(data).length} bucket(s)`
129+
);
127130
core.summary
128131
.addHeading('GitHub API Usage Tracker Summary')
129132
.addTable(makeSummaryTable(data))

tests/post-utils.test.mjs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@ describe('post utils', () => {
2727
});
2828

2929
expect(table).toEqual([
30-
{ data: 'Bucket', header: true },
31-
{ data: 'Used', header: true },
32-
{ data: 'Remaining', header: true },
33-
{ data: 'core' },
34-
{ data: '3' },
35-
{ data: '10' },
36-
{ data: 'search' },
37-
{ data: '1' },
38-
{ data: '2' }
30+
[
31+
{ data: 'Bucket', header: true },
32+
{ data: 'Used', header: true },
33+
{ data: 'Remaining', header: true }
34+
],
35+
[{ data: 'core' }, { data: '3' }, { data: '10' }],
36+
[{ data: 'search' }, { data: '1' }, { data: '2' }]
3937
]);
4038
});
4139
});

0 commit comments

Comments
 (0)