-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Report size of app bundles on PRs (#28019)
Summary: Report size of app bundles on PRs. See [React Native Benchmark Suite](react-native-community/discussions-and-proposals#186) for further discussion. ## Changelog [Internal] [Added] - Report size of app bundles on PRs Pull Request resolved: #28019 Test Plan: PRs should start seeing comments from a bot with app bundle sizes, given that they got built successfully. Differential Revision: D19859187 Pulled By: hramos fbshipit-source-id: 48ba25903356b219135716f989a4a3c05140abfb
- Loading branch information
1 parent
66f89e2
commit a8cd516
Showing
4 changed files
with
142 additions
and
5 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,48 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const {GITHUB_TOKEN, GITHUB_OWNER, GITHUB_REPO, GITHUB_PR_NUMBER} = process.env; | ||
if (!GITHUB_TOKEN || !GITHUB_OWNER || !GITHUB_REPO || !GITHUB_PR_NUMBER) { | ||
if (!GITHUB_TOKEN) { | ||
console.error( | ||
'Missing GITHUB_TOKEN. Example: 5fd88b964fa214c4be2b144dc5af5d486a2f8c1e. PR feedback cannot be provided on GitHub without a valid token.', | ||
); | ||
} | ||
if (!GITHUB_OWNER) { | ||
console.error('Missing GITHUB_OWNER. Example: facebook'); | ||
} | ||
if (!GITHUB_REPO) { | ||
console.error('Missing GITHUB_REPO. Example: react-native'); | ||
} | ||
if (!GITHUB_PR_NUMBER) { | ||
console.error( | ||
'Missing GITHUB_PR_NUMBER. Example: 4687. PR feedback cannot be provided on GitHub without a valid pull request number.', | ||
); | ||
} | ||
process.exit(1); | ||
} | ||
|
||
const {[2]: body} = process.argv; | ||
if (!body) { | ||
process.exit(0); | ||
} | ||
|
||
const octokit = require('@octokit/rest')(); | ||
octokit.authenticate({ | ||
type: 'oauth', | ||
token: GITHUB_TOKEN, | ||
}); | ||
octokit.issues.createComment({ | ||
owner: GITHUB_OWNER, | ||
repo: GITHUB_REPO, | ||
issue_number: GITHUB_PR_NUMBER, | ||
body, | ||
}); |
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 |
---|---|---|
|
@@ -9,6 +9,6 @@ | |
"minimatch": "^3.0.4" | ||
}, | ||
"dependencies": { | ||
"@octokit/rest": "15.18.0" | ||
"@octokit/rest": "^16.43.0" | ||
} | ||
} |
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,63 @@ | ||
#!/bin/bash | ||
# Copyright (c) Facebook, Inc. and its affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
function diskusage { | ||
# If the environment variable BLOCKSIZE is set, and the -k option is not | ||
# specified, the block counts will be displayed in units of that size block. | ||
# If BLOCKSIZE is not set, and the -k option is not specified, the block | ||
# counts will be displayed in 512-byte blocks. | ||
local path=$1 | ||
du -s "$path" | awk "{size = \$0 * ${BLOCKSIZE:-512}} END {print size}" | ||
} | ||
|
||
function comment { | ||
local body=$1 | ||
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" | ||
} | ||
|
||
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 | ||
eol=$'\n' | ||
size_report="" | ||
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" | ||
else | ||
size_report+="RNTester (Android/$engine/$arch): n/a$eol" | ||
fi | ||
done | ||
fi | ||
done | ||
comment "$size_report" | ||
;; | ||
"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" | ||
fi | ||
;; | ||
*) | ||
echo "Syntax: $0 [android | ios]" | ||
exit 1 | ||
esac |