Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
node-version: 16.x
- run: npm ci
- name: build stats
run: npm run build -- -s
run: npm run build
- name: persist
id: b
uses: actions/github-script@v6
Expand All @@ -36,7 +36,7 @@ jobs:
script: |
const fs = require('fs');
return JSON.stringify({
size: JSON.parse(fs.readFileSync('cli_output/build_size.json'))
size: { fabric: { minified: fs.statSync('dist/fabric.min.js').size, bundled: fs.statSync('dist/fabric.js').size } }
});
- name: checkout src files
run: git checkout origin/master -- src
Expand All @@ -50,15 +50,15 @@ jobs:
script: |
const fs = require('fs');
return JSON.stringify({
size: JSON.parse(fs.readFileSync('cli_output/build_size.json'))
size: { fabric: { minified: fs.statSync('dist/fabric.min.js').size, bundled: fs.statSync('dist/fabric.js').size } }
});
- name: process
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const { run } = await import('${{ github.workspace }}/scripts/buildStats.mjs');
const res = await run({
const { run_simple } = await import('${{ github.workspace }}/scripts/buildStats.mjs');
const res = await run_simple({
github,
context,
core,
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [next]

- ci(): Simplify filestats even more [#8449](https://github.com/fabricjs/fabric.js/pull/8449)
- chore(TS): migrate filter backends [#8403](https://github.com/fabricjs/fabric.js/pull/8403)
- chore(TS): migrate Text classes/mixins [#8408](https://github.com/fabricjs/fabric.js/pull/8408)
- chore(TS): migrate Path [#8412](https://github.com/fabricjs/fabric.js/pull/8412)
Expand Down
61 changes: 54 additions & 7 deletions scripts/buildStats.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import _ from 'lodash';

const REQUESTED_COMMENTS_PER_PAGE = 20;

const COMMENT_MARKER = '<!-- BUILD STATS COMMENT -->';
Expand All @@ -13,7 +11,7 @@ function printSize(a, b) {
)}**)`;
}

function printSizeByte(a, b) {
function printSizeKByte(a, b) {
return printSize(a / 1024, b / 1024);
}

Expand Down Expand Up @@ -48,7 +46,7 @@ export async function run({ github, context, a, b }) {
const table = [
['file / KB (diff)', 'bundled', 'minified', 'gzipped'],
['---', '---', '---', '---'],
..._.map(b.size, (_b, file) => {
...Object.entries(b.size).map(([file, _b]) => {
const _a = {
bundled: 0,
minified: 0,
Expand All @@ -57,9 +55,58 @@ export async function run({ github, context, a, b }) {
};
return [
file,
printSizeByte(_a.bundled, _b.bundled),
printSizeByte(_a.minified, _b.minified),
printSizeByte(_a.gzipped, _b.gzipped),
printSizeKByte(_a.bundled, _b.bundled),
printSizeKByte(_a.minified, _b.minified),
printSizeKByte(_a.gzipped, _b.gzipped),
];
}),
];

const body = [
COMMENT_MARKER,
'**Build Stats**',
'',
...table.map((row) => ['', ...row, ''].join(' | ')),
'',
]
.join('\n')
.slice(0, MAX_COMMENT_CHARS);

const commentId = await findCommentId(github, context);

await (commentId
? github.rest.issues.updateComment({
repo,
owner,
comment_id: commentId,
body,
})
: github.rest.issues.createComment({
repo,
owner,
issue_number: context.payload.pull_request.number,
body,
}));
}

export async function run_simple({ github, context, a, b }) {
const {
repo: { owner, repo },
} = context;

const table = [
['file / KB (diff)', 'bundled', 'minified'],
['---', '---', '---'],
...Object.entries(b.size).map(([file, _b]) => {
const _a = {
bundled: 0,
minified: 0,
...(a.size[file] || {}),
};
return [
file,
printSizeKByte(_a.bundled, _b.bundled),
printSizeKByte(_a.minified, _b.minified),
];
}),
];
Expand Down