From 667ccfdbba6bbc2f27b1930b508c3338db249bb3 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen Date: Wed, 12 Feb 2020 21:32:09 -0800 Subject: [PATCH] Report size of app bundles on PRs (#28041) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/28041 Report size of app bundles on PRs. See [React Native Benchmark Suite](https://github.com/react-native-community/discussions-and-proposals/issues/186) for further discussion. ## Changelog [Internal] [Added] - Report size of app bundles on PRs Pull Request resolved: https://github.com/facebook/react-native/pull/28019 Test Plan: PRs should start seeing comments from a bot with app bundle sizes, given that they got built successfully. Reviewed By: cpojer Differential Revision: D19859187 Pulled By: hramos fbshipit-source-id: 0eb510287ba2001895d66d038fc1e7b8a722d9a8 --- .circleci/config.yml | 34 ++++- bots/make-comment.js | 48 +++++++ bots/package.json | 2 +- bots/yarn.lock | 180 +++++++++++++++++++++---- scripts/circleci/report-bundle-size.sh | 63 +++++++++ 5 files changed, 293 insertions(+), 34 deletions(-) create mode 100644 bots/make-comment.js create mode 100755 scripts/circleci/report-bundle-size.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index dcdade1ef2f52f..29ec4d3ce4eb8d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -94,6 +94,12 @@ commands: - ~/okbuck key: v3-buck-v2019.01.10.01-{{ checksum "scripts/circleci/buck_fetch.sh" }} + install_github_bot_deps: + steps: + - run: + name: Install GitHub bot dependencies + command: cd bots && yarn install --non-interactive --cache-folder ~/.cache/yarn + brew_install: parameters: package: @@ -217,11 +223,11 @@ jobs: checkout_type: node - run_yarn + - install_github_bot_deps + - run: - name: Install dependencies - command: | - sudo apt update && sudo apt install -y shellcheck jq - cd bots && yarn install --non-interactive --cache-folder ~/.cache/yarn + name: Install additional GitHub bot dependencies + command: sudo apt update && sudo apt install -y shellcheck jq - run: name: Run linters against modified files (analysis-bot) @@ -355,6 +361,10 @@ jobs: # Runs iOS end-to-end tests test_ios_e2e: executor: reactnativeios + # The public github tokens are publicly visible by design + environment: + - PUBLIC_GITHUB_TOKEN_A: "78a72af35445ca3f8180" + - PUBLIC_GITHUB_TOKEN_B: "b1a98e0bbd56ff1ccba1" steps: - restore_cache_checkout: checkout_type: ios @@ -381,6 +391,7 @@ jobs: package: applesimutils - brew_install: package: watchman + # Configure Watchman - run: touch .watchmanconfig @@ -400,6 +411,12 @@ jobs: command: yarn run build-ios-e2e && yarn run test-ios-e2e when: always + - install_github_bot_deps + - run: + name: Report size of RNTester.app + command: GITHUB_TOKEN="$PUBLIC_GITHUB_TOKEN_A""$PUBLIC_GITHUB_TOKEN_B" scripts/circleci/report-bundle-size.sh ios + when: always + - run: name: Run iOS End-to-End Tests command: | @@ -440,6 +457,10 @@ jobs: # Run Android tests test_android: executor: reactnativeandroid + # The public github tokens are publicly visible by design + environment: + - PUBLIC_GITHUB_TOKEN_A: "78a72af35445ca3f8180" + - PUBLIC_GITHUB_TOKEN_B: "b1a98e0bbd56ff1ccba1" steps: - restore_cache_checkout: checkout_type: android @@ -511,6 +532,11 @@ jobs: name: Build Android RNTester App command: ./gradlew RNTester:android:app:assembleRelease + - install_github_bot_deps + - run: + name: Report size of RNTester.apk + command: GITHUB_TOKEN="$PUBLIC_GITHUB_TOKEN_A""$PUBLIC_GITHUB_TOKEN_B" scripts/circleci/report-bundle-size.sh android + # Collect Results - run: name: Collect Test Results diff --git a/bots/make-comment.js b/bots/make-comment.js new file mode 100644 index 00000000000000..88a6e428ddcaa8 --- /dev/null +++ b/bots/make-comment.js @@ -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, +}); diff --git a/bots/package.json b/bots/package.json index 51cfe34eadeac1..ef26cc581576ba 100644 --- a/bots/package.json +++ b/bots/package.json @@ -9,6 +9,6 @@ "minimatch": "^3.0.4" }, "dependencies": { - "@octokit/rest": "15.18.0" + "@octokit/rest": "^16.43.0" } } diff --git a/bots/yarn.lock b/bots/yarn.lock index f7b51e9cfcce2b..70bad996cf40d1 100644 --- a/bots/yarn.lock +++ b/bots/yarn.lock @@ -10,6 +10,13 @@ core-js "^2.5.7" regenerator-runtime "^0.12.0" +"@octokit/auth-token@^2.4.0": + version "2.4.0" + resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.4.0.tgz#b64178975218b99e4dfe948253f0673cbbb59d9f" + integrity sha512-eoOVMjILna7FVQf96iWc3+ZtE/ZT6y8ob8ZzcqKY1ibSQCnu4O/B7pJvzMx5cyZ/RjAff6DAdEb0O0Cjcxidkg== + dependencies: + "@octokit/types" "^2.0.0" + "@octokit/endpoint@^3.1.1": version "3.1.2" resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-3.1.2.tgz#22b5aa8596482fbefc3f1ce22c24ad217aed60fa" @@ -20,6 +27,44 @@ universal-user-agent "^2.0.1" url-template "^2.0.8" +"@octokit/endpoint@^5.5.0": + version "5.5.2" + resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-5.5.2.tgz#ed19d01fe85ac58bc2b774661658f9e5429b8164" + integrity sha512-ICDcRA0C2vtTZZGud1nXRrBLXZqFayodXAKZfo3dkdcLNqcHsgaz3YSTupbURusYeucSVRjjG+RTcQhx6HPPcg== + dependencies: + "@octokit/types" "^2.0.0" + is-plain-object "^3.0.0" + universal-user-agent "^4.0.0" + +"@octokit/plugin-paginate-rest@^1.1.1": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-1.1.2.tgz#004170acf8c2be535aba26727867d692f7b488fc" + integrity sha512-jbsSoi5Q1pj63sC16XIUboklNw+8tL9VOnJsWycWYR78TKss5PVpIPb1TUUcMQ+bBh7cY579cVAWmf5qG+dw+Q== + dependencies: + "@octokit/types" "^2.0.1" + +"@octokit/plugin-request-log@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.0.tgz#eef87a431300f6148c39a7f75f8cfeb218b2547e" + integrity sha512-ywoxP68aOT3zHCLgWZgwUJatiENeHE7xJzYjfz8WI0goynp96wETBF+d95b8g/uL4QmS6owPVlaxiz3wyMAzcw== + +"@octokit/plugin-rest-endpoint-methods@2.4.0": + version "2.4.0" + resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-2.4.0.tgz#3288ecf5481f68c494dd0602fc15407a59faf61e" + integrity sha512-EZi/AWhtkdfAYi01obpX0DF7U6b1VRr30QNQ5xSFPITMdLSfhcBqjamE3F+sKcxPbD7eZuMHu3Qkk2V+JGxBDQ== + dependencies: + "@octokit/types" "^2.0.1" + deprecation "^2.3.1" + +"@octokit/request-error@^1.0.1", "@octokit/request-error@^1.0.2": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-1.2.1.tgz#ede0714c773f32347576c25649dc013ae6b31801" + integrity sha512-+6yDyk1EES6WK+l3viRDElw96MvwfJxCt45GvmjDUKWjYIb3PJZQkq3i46TwGwoPD4h8NmTrENmtyA1FwbmhRA== + dependencies: + "@octokit/types" "^2.0.0" + deprecation "^2.0.0" + once "^1.4.0" + "@octokit/request@2.3.0": version "2.3.0" resolved "https://registry.yarnpkg.com/@octokit/request/-/request-2.3.0.tgz#da2672308bcf0b9376ef66f51bddbe5eb87cc00a" @@ -30,20 +75,19 @@ node-fetch "^2.3.0" universal-user-agent "^2.0.1" -"@octokit/rest@15.18.0": - version "15.18.0" - resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-15.18.0.tgz#e6de702b57dec94c71e806f1cff0ecb9725b3054" - integrity sha512-D1dDJMbvT4dok9++vc8uwCr92ndadwfz6vHK+IklzBHKSsuLlhpv2/dzx97Y4aRlm0t74LeXKDp4j0b4M2vmQw== +"@octokit/request@^5.2.0": + version "5.3.1" + resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.3.1.tgz#3a1ace45e6f88b1be4749c5da963b3a3b4a2f120" + integrity sha512-5/X0AL1ZgoU32fAepTfEoggFinO3rxsMLtzhlUX+RctLrusn/CApJuGFCd0v7GMFhF+8UiCsTTfsu7Fh1HnEJg== dependencies: - before-after-hook "^1.1.0" - btoa-lite "^1.0.0" - debug "^3.1.0" - http-proxy-agent "^2.1.0" - https-proxy-agent "^2.2.0" - lodash "^4.17.4" - node-fetch "^2.1.1" - universal-user-agent "^2.0.0" - url-template "^2.0.8" + "@octokit/endpoint" "^5.5.0" + "@octokit/request-error" "^1.0.1" + "@octokit/types" "^2.0.0" + deprecation "^2.0.0" + is-plain-object "^3.0.0" + node-fetch "^2.3.0" + once "^1.4.0" + universal-user-agent "^4.0.0" "@octokit/rest@^16.14.1": version "16.15.0" @@ -60,6 +104,40 @@ universal-user-agent "^2.0.0" url-template "^2.0.8" +"@octokit/rest@^16.43.0": + version "16.43.1" + resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-16.43.1.tgz#3b11e7d1b1ac2bbeeb23b08a17df0b20947eda6b" + integrity sha512-gfFKwRT/wFxq5qlNjnW2dh+qh74XgTQ2B179UX5K1HYCluioWj8Ndbgqw2PVqa1NnVJkGHp2ovMpVn/DImlmkw== + dependencies: + "@octokit/auth-token" "^2.4.0" + "@octokit/plugin-paginate-rest" "^1.1.1" + "@octokit/plugin-request-log" "^1.0.0" + "@octokit/plugin-rest-endpoint-methods" "2.4.0" + "@octokit/request" "^5.2.0" + "@octokit/request-error" "^1.0.2" + atob-lite "^2.0.0" + before-after-hook "^2.0.0" + btoa-lite "^1.0.0" + deprecation "^2.0.0" + lodash.get "^4.4.2" + lodash.set "^4.3.2" + lodash.uniq "^4.5.0" + octokit-pagination-methods "^1.1.0" + once "^1.4.0" + universal-user-agent "^4.0.0" + +"@octokit/types@^2.0.0", "@octokit/types@^2.0.1": + version "2.1.1" + resolved "https://registry.yarnpkg.com/@octokit/types/-/types-2.1.1.tgz#77e80d1b663c5f1f829e5377b728fa3c4fe5a97d" + integrity sha512-89LOYH+d/vsbDX785NOfLxTW88GjNd0lWRz1DVPVsZgg9Yett5O+3MOvwo7iHgvUwbFz0mf/yPIjBkUbs4kxoQ== + dependencies: + "@types/node" ">= 8" + +"@types/node@>= 8": + version "13.7.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-13.7.1.tgz#238eb34a66431b71d2aaddeaa7db166f25971a0d" + integrity sha512-Zq8gcQGmn4txQEJeiXo/KiLpon8TzAl0kmKH4zdWctPj05nWwp1ClMdAVEloqrQKfaC48PNLdgN/aVaLqUrluA== + agent-base@4, agent-base@^4.1.0: version "4.2.1" resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.1.tgz#d89e5999f797875674c07d87f260fc41e83e8ca9" @@ -109,6 +187,11 @@ assign-symbols@^1.0.0: resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c= +atob-lite@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/atob-lite/-/atob-lite-2.0.0.tgz#0fef5ad46f1bd7a8502c65727f0367d5ee43d696" + integrity sha1-D+9a1G8b16hQLGVyfwNn1e5D1pY= + atob@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" @@ -132,16 +215,16 @@ base@^0.11.1: mixin-deep "^1.2.0" pascalcase "^0.1.1" -before-after-hook@^1.1.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-1.4.0.tgz#2b6bf23dca4f32e628fd2747c10a37c74a4b484d" - integrity sha512-l5r9ir56nda3qu14nAXIlyq1MmUSs0meCIaFAh8HwkFwP1F8eToOuS3ah2VAHHcY04jaYD7FpJC5JTXHYRbkzg== - before-after-hook@^1.2.0: version "1.3.2" resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-1.3.2.tgz#7bfbf844ad670aa7a96b5a4e4e15bd74b08ed66b" integrity sha512-zyPgY5dgbf99c0uGUjhY4w+mxqEGxPKg9RQDl34VvrVh2bM31lFN+mwR1ZHepq/KA3VCPk1gwJZL6IIJqjLy2w== +before-after-hook@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.1.0.tgz#b6c03487f44e24200dd30ca5e6a1979c5d2fb635" + integrity sha512-IWIbu7pMqyw3EAJHzzHbWa85b6oud/yfKYg5rqB5hNE8CeMi3nX+2C2sj0HswfblST86hpVEOAb9x34NZd6P7A== + brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -399,6 +482,11 @@ define-property@^2.0.2: is-descriptor "^1.0.2" isobject "^3.0.1" +deprecation@^2.0.0, deprecation@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919" + integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ== + ecdsa-sig-formatter@1.0.10: version "1.0.10" resolved "https://registry.yarnpkg.com/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.10.tgz#1c595000f04a8897dfb85000892a0f4c33af86c3" @@ -617,7 +705,7 @@ http-proxy-agent@^2.1.0: agent-base "4" debug "3.1.0" -https-proxy-agent@^2.2.0, https-proxy-agent@^2.2.1: +https-proxy-agent@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz#51552970fa04d723e04c56d04178c3f92592bbc0" integrity sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ== @@ -729,6 +817,13 @@ is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4: dependencies: isobject "^3.0.1" +is-plain-object@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-3.0.0.tgz#47bfc5da1b5d50d64110806c199359482e75a928" + integrity sha512-tZIpofR+P05k8Aocp7UI/2UTa9lTJSebCXpFFoR9aibpokDj/uXBsJ8luUu0tTVYKkMU6URDUuOfJZ7koewXvg== + dependencies: + isobject "^4.0.0" + is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" @@ -761,6 +856,11 @@ isobject@^3.0.0, isobject@^3.0.1: resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= +isobject@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-4.0.0.tgz#3f1c9155e73b192022a80819bacd0343711697b0" + integrity sha512-S/2fF5wH8SJA/kmwr6HYhK/RI/OkhD84k8ntalo0iJjZikgq1XFvR5M8NPT1x5F7fBwCG3qHfnzeP/Vh/ZxCUA== + jsome@^2.3.25: version "2.5.0" resolved "https://registry.yarnpkg.com/jsome/-/jsome-2.5.0.tgz#5e417eef4341ffeb83ee8bfa9265b36d56fe49ed" @@ -933,11 +1033,6 @@ lodash.uniq@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= -lodash@^4.17.4: - version "4.17.11" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" - integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== - lru-cache@^4.0.1: version "4.1.5" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd" @@ -951,6 +1046,11 @@ macos-release@^2.0.0: resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-2.0.0.tgz#7dddf4caf79001a851eb4fba7fb6034f251276ab" integrity sha512-iCM3ZGeqIzlrH7KxYK+fphlJpCCczyHXc+HhRVbEu9uNTCrzYJjvvtefzeKTCVHd5AP/aD/fzC80JZ4ZP+dQ/A== +macos-release@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/macos-release/-/macos-release-2.3.0.tgz#eb1930b036c0800adebccd5f17bc4c12de8bb71f" + integrity sha512-OHhSbtcviqMPt7yfw5ef5aghS2jzFVKEFyCJndQt2YpSQ9qRVSEv2axSJI1paVThEu+FFGs584h/1YhxjVqajA== + map-cache@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" @@ -1056,11 +1156,6 @@ node-cleanup@^2.1.2: resolved "https://registry.yarnpkg.com/node-cleanup/-/node-cleanup-2.1.2.tgz#7ac19abd297e09a7f72a71545d951b517e4dde2c" integrity sha1-esGavSl+Caf3KnFUXZUbUX5N3iw= -node-fetch@^2.1.1: - version "2.6.0" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" - integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== - node-fetch@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.3.0.tgz#1a1d940bbfb916a1d3e0219f037e89e71f8c5fa5" @@ -1106,6 +1201,13 @@ octokit-pagination-methods@^1.1.0: resolved "https://registry.yarnpkg.com/octokit-pagination-methods/-/octokit-pagination-methods-1.1.0.tgz#cf472edc9d551055f9ef73f6e42b4dbb4c80bea4" integrity sha512-fZ4qZdQ2nxJvtcasX7Ghl+WlWS/d9IgnBIwFZXVNNZUmzpno91SX5bc5vuxiuKoCtK78XxGGNuSCrDC7xYB3OQ== +once@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= + dependencies: + wrappy "1" + os-locale@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-2.1.0.tgz#42bc2900a6b5b8bd17376c8e882b65afccf24bf2" @@ -1123,6 +1225,14 @@ os-name@^3.0.0: macos-release "^2.0.0" windows-release "^3.1.0" +os-name@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/os-name/-/os-name-3.1.0.tgz#dec19d966296e1cd62d701a5a66ee1ddeae70801" + integrity sha512-h8L+8aNjNcMpo/mAIBPn5PXCM16iyPGjHNWo6U1YO8sJTMHtEtyczI6QJnLoplswm6goopQkqc7OAnjhWcugVg== + dependencies: + macos-release "^2.2.0" + windows-release "^3.1.0" + override-require@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/override-require/-/override-require-1.1.1.tgz#6ae22fadeb1f850ffb0cf4c20ff7b87e5eb650df" @@ -1501,6 +1611,13 @@ universal-user-agent@^2.0.0, universal-user-agent@^2.0.1: dependencies: os-name "^3.0.0" +universal-user-agent@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-4.0.0.tgz#27da2ec87e32769619f68a14996465ea1cb9df16" + integrity sha512-eM8knLpev67iBDizr/YtqkJsF3GK8gzDc6st/WKzrTuPtcsOKW/0IdL4cnMBsU69pOx0otavLWBDGTwg+dB0aA== + dependencies: + os-name "^3.1.0" + unset-value@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559" @@ -1551,6 +1668,11 @@ wrap-ansi@^2.0.0: string-width "^1.0.1" strip-ansi "^3.0.1" +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= + xtend@~4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" diff --git a/scripts/circleci/report-bundle-size.sh b/scripts/circleci/report-bundle-size.sh new file mode 100755 index 00000000000000..7cb6ac06eb1323 --- /dev/null +++ b/scripts/circleci/report-bundle-size.sh @@ -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