-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ci] Check package size for Pull Requests (#17739)
- Loading branch information
Showing
6 changed files
with
92 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const fs = require('fs-extra'); | ||
const ps = require('path'); | ||
const { buildEngine } = require('@cocos/ccbuild'); | ||
|
||
const engineRoot = ps.resolve(__dirname, '..', '..'); | ||
console.log(`Engine root: ${engineRoot}`); | ||
|
||
const exportsDir = ps.join(engineRoot, 'exports'); | ||
const files = fs.readdirSync(exportsDir); | ||
const features = []; | ||
files.forEach(file => { | ||
const filePath = ps.join(exportsDir, file); | ||
const feature = ps.parse(ps.basename(filePath)).name; | ||
features.push(feature); | ||
}); | ||
|
||
console.log(`features: [ ${features.join(', ')} ]`); | ||
|
||
(async () => { | ||
const outDir = ps.join(engineRoot, 'build-cc-out'); | ||
|
||
const options = { | ||
engine: engineRoot, | ||
out: outDir, | ||
platform: "WECHAT", | ||
moduleFormat: "system", | ||
compress: true, | ||
split: false, | ||
nativeCodeBundleMode: "wasm", | ||
assetURLFormat: "runtime-resolved", | ||
noDeprecatedFeatures: true, | ||
sourceMap: false, | ||
features, | ||
loose: true, | ||
mode: "BUILD", | ||
flags: { | ||
DEBUG: false, | ||
NET_MODE: 0, | ||
SERVER_MODE: false | ||
}, | ||
wasmCompressionMode: 'brotli', | ||
inlineEnum: true, | ||
}; | ||
|
||
await fs.ensureDir(outDir); | ||
await fs.emptyDir(outDir); | ||
|
||
await buildEngine(options); | ||
})(); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,9 @@ jobs: | |
working-directory: ./engine | ||
run: | | ||
npm install | ||
if [ -e ./.github/workflows/package-size-check.js ]; then | ||
node ./.github/workflows/package-size-check.js | ||
fi | ||
- name: Clear npm Cache | ||
run: | | ||
|
@@ -68,6 +71,7 @@ jobs: | |
working-directory: ./engine-HEAD | ||
run: | | ||
npm install | ||
node ./.github/workflows/package-size-check.js | ||
- uses: LouisBrunner/[email protected] | ||
with: | ||
|
@@ -77,6 +81,25 @@ jobs: | |
tolerance: worse | ||
output: ./engine/interface-diff.txt | ||
|
||
- name: Check package size | ||
run: | | ||
BASE_SIZE=0 | ||
if [ -d ./engine/build-cc-out ]; then | ||
BASE_SIZE=$(du -sk ./engine/build-cc-out | awk '{print $1 * 1024}') | ||
fi | ||
HEAD_SIZE=$(du -sk ./engine-HEAD/build-cc-out | awk '{print $1 * 1024}') | ||
DIFF_SIZE=$((HEAD_SIZE - BASE_SIZE)) | ||
if [ "$DIFF_SIZE" -gt 0 ]; then | ||
PACKAGE_SIZE_INFO="📈📈📈 Package Size increased by $DIFF_SIZE bytes, OLD: $BASE_SIZE, NEW: $HEAD_SIZE" | ||
elif [ "$DIFF_SIZE" -lt 0 ]; then | ||
PACKAGE_SIZE_INFO="📉📉📉 Package Size decreased by $DIFF_SIZE bytes, OLD: $BASE_SIZE, NEW: $HEAD_SIZE" | ||
else | ||
PACKAGE_SIZE_INFO="🟢🟢🟢 Package Size is not changed, BASE: $BASE_SIZE, HEAD: $HEAD_SIZE" | ||
fi | ||
echo "PACKAGE_SIZE_INFO: ${PACKAGE_SIZE_INFO}" | ||
sed -i "1s/^/$PACKAGE_SIZE_INFO\n/" ./engine/interface-diff.txt | ||
- name: optimize interface check report | ||
working-directory: ./engine | ||
run: | | ||
|
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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