Skip to content

Commit

Permalink
Report size of app bundles on PRs (#28041)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #28041

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.

Reviewed By: cpojer

Differential Revision: D19859187

Pulled By: hramos

fbshipit-source-id: 3920dc60e6fd073928388e6ae52fc2ba1bc745ac
  • Loading branch information
tido64 authored and facebook-github-bot committed Feb 13, 2020
1 parent 619d5d6 commit 1b56292
Show file tree
Hide file tree
Showing 5 changed files with 293 additions and 34 deletions.
34 changes: 30 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -381,6 +391,7 @@ jobs:
package: applesimutils
- brew_install:
package: watchman

# Configure Watchman
- run: touch .watchmanconfig

Expand All @@ -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: |
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
48 changes: 48 additions & 0 deletions bots/make-comment.js
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,
});
2 changes: 1 addition & 1 deletion bots/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"minimatch": "^3.0.4"
},
"dependencies": {
"@octokit/rest": "15.18.0"
"@octokit/rest": "^16.43.0"
}
}
Loading

0 comments on commit 1b56292

Please sign in to comment.