Improvements to app bundle size reports (#28169)

Summary:
Make the Android app bundle size report more legible, and update existing reports if possible.

## Changelog

[Internal] [Changed] - Update existing app bundle size report if possible
[Internal] [Changed] - Generate table for APK sizes report
Pull Request resolved: https://github.com/facebook/react-native/pull/28169

Test Plan:
- App bundle size reports should be updated when possible
- Android apk sizes should be reported using a table

Reviewed By: cpojer

Differential Revision: D20141490

Pulled By: hramos

fbshipit-source-id: 3fc1b808b27e893c0a3e4e34eafc39094448799c
This commit is contained in:
Tommy Nguyen authored and Facebook Github Bot committed 2020-02-27 13:52:14 -08:00
1 parent 041ce53002
commit 32127e8160
2 files changed
+78 -27

No files matched your search

+60 -13
View File
@@ -30,18 +30,65 @@ if (!GITHUB_TOKEN || !GITHUB_OWNER || !GITHUB_REPO || !GITHUB_PR_NUMBER) {
process.exit(1);
}
const {[2]: body} = process.argv;
if (!body) {
process.exit(0);
async function updateComment(octokit, issueParams, body, replacePattern) {
if (!replacePattern) {
return false;
}
const authenticatedUser = await octokit.users.getAuthenticated();
if (authenticatedUser.status !== 200 || !authenticatedUser.data) {
console.warn(authenticatedUser);
return false;
}
const comments = await octokit.issues.listComments(issueParams);
if (comments.status !== 200 || !comments.data) {
console.warn(comments);
return false;
}
const authedUserId = authenticatedUser.data.id;
const pattern = new RegExp(replacePattern, 'g');
const comment = comments.data.find(
({user, body}) => user.id === authedUserId && pattern.test(body),
);
if (!comment) {
return false;
}
octokit.issues.updateComment({
...issueParams,
comment_id: comment.id,
body,
});
return true;
}
const {Octokit} = require('@octokit/rest');
const octokit = new Octokit({
auth: GITHUB_TOKEN,
});
octokit.issues.createComment({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
issue_number: GITHUB_PR_NUMBER,
body,
});
async function main(body, replacePattern) {
if (!body) {
return;
}
const {Octokit} = require('@octokit/rest');
const octokit = new Octokit({auth: GITHUB_TOKEN});
const issueParams = {
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
issue_number: GITHUB_PR_NUMBER,
};
if (await updateComment(octokit, issueParams, body, replacePattern)) {
return;
}
// We found no comments to replace, so we'll create a new one.
octokit.issues.createComment({
...issueParams,
body,
});
}
const {[2]: body, [3]: replacePattern} = process.argv;
main(body, replacePattern);
+18 -14
View File
@@ -15,46 +15,50 @@ function diskusage {
function comment {
local body=$1
local replace=$2
GITHUB_OWNER=${CIRCLE_PROJECT_USERNAME:-facebook} \
GITHUB_REPO=${CIRCLE_PROJECT_REPONAME:-react-native} \
GITHUB_PR_NUMBER="$CIRCLE_PR_NUMBER" \
node bots/make-comment.js "$body"
node bots/make-comment.js "$body" "$replace"
}
case $1 in
"android")
# Outputs:
# RNTester (Android/hermes/arm64-v8a): 9437184 bytes
# RNTester (Android/hermes/armeabi-v7a): 9015296 bytes
# RNTester (Android/hermes/x86): 9498624 bytes
# RNTester (Android/hermes/x86_64): 9965568 bytes
# RNTester (Android/jsc/arm64-v8a): 9236480 bytes
# RNTester (Android/jsc/armeabi-v7a): 8814592 bytes
# RNTester (Android/jsc/x86): 9297920 bytes
# RNTester (Android/jsc/x86_64): 9764864 bytes
# | App | Platform | Engine | Arch | Size (bytes) |
# |:---------|:---------|:-------|:------------|-------------:|
# | RNTester | Android | hermes | arm64-v8a | 9437184 |
# | RNTester | Android | hermes | armeabi-v7a | 9015296 |
# | RNTester | Android | hermes | x86 | 9498624 |
# | RNTester | Android | hermes | x86_64 | 9965568 |
# | RNTester | Android | jsc | arm64-v8a | 9236480 |
# | RNTester | Android | jsc | armeabi-v7a | 8814592 |
# | RNTester | Android | jsc | x86 | 9297920 |
# | RNTester | Android | jsc | x86_64 | 9764864 |
eol=$'\n'
size_report=""
size_report="| App | Platform | Engine | Arch | Size (bytes) |$eol"
size_report+="|:---------|:---------|:-------|:------------|-------------:|$eol"
for engine in hermes jsc; do
outputs="RNTester/android/app/build/outputs/apk/$engine/release"
if [[ -d "$outputs" ]]; then
for arch in arm64-v8a armeabi-v7a x86 x86_64; do
apk="$outputs/app-$engine-$arch-release.apk"
if [[ -f "$apk" ]]; then
size_report+="RNTester (Android/$engine/$arch): $(diskusage "$apk") bytes$eol"
size_report+="| RNTester | Android | $engine | $arch | $(diskusage "$apk") |$eol"
else
size_report+="RNTester (Android/$engine/$arch): n/a$eol"
size_report+="| RNTester | Android | $engine | $arch | n/a |$eol"
fi
done
fi
done
comment "$size_report"
comment "$size_report" "RNTester \\| Android"
;;
"ios")
# Outputs:
# RNTester.app (iOS): 9535488 bytes
binary='RNTester/build/Build/Products/Release-iphonesimulator/RNTester.app/RNTester'
if [[ -f "$binary" ]]; then
comment "RNTester.app (iOS): $(diskusage "$binary") bytes"
comment "RNTester.app (iOS): $(diskusage "$binary") bytes" "^RNTester.app \\(iOS\\)"
fi
;;
*)