Skip to content

Commit

Permalink
Build Hermes in CI also when it is against stable branch
Browse files Browse the repository at this point in the history
Summary:
This Diff is a copy of this [PR](facebook#34228) that we have against 0.69-stable.

This Diff makes sure we can build Hermes also in PR that are created against a stable branch

## Changelog

[General] [Changed] - Make sure we can build Hermes from source when PR are opened agains -stable

Differential Revision: D37961092

fbshipit-source-id: f9f9c9a71fa39303ddb775c10f9ad3d3ea2843f2
  • Loading branch information
Riccardo Cipolleschi authored and facebook-github-bot committed Jul 20, 2022
1 parent d0b1d49 commit 5d7a490
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ jobs:
- run:
name: Download Hermes tarball
command: |
node scripts/hermes/prepare-hermes-for-build
node scripts/hermes/prepare-hermes-for-build $CIRCLE_PULL_REQUEST
cp sdks/download/* $HERMES_WS_DIR/download/.
cp -r sdks/hermes/* $HERMES_WS_DIR/hermes/.
- save_cache:
Expand Down
17 changes: 16 additions & 1 deletion scripts/hermes/hermes-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,26 @@ function isRequestingLatestCommitFromHermesMainBranch() {
return hermesTag === DEFAULT_HERMES_TAG;
}

function shouldBuildHermesFromSource() {
function isPRAgainstStable(pullRequest) {
if (pullRequest == null) {
return false;
}

const prComponents = pullRequest.split('/');
const prNumber = prComponents[prComponents.length - 1];
const apiURL = `https://api.github.com/repos/facebook/react-native/pulls/${prNumber}`;
const prJson = JSON.parse(execSync(`curl ${apiURL}`).toString());
const baseBranch = prJson.base.label;

return baseBranch.endsWith('-stable');
}

function shouldBuildHermesFromSource(pullRequest) {
return (
!isTestingAgainstLocalHermesTarball() &&
(isOnAReactNativeReleaseBranch() ||
isOnAReactNativeReleaseTag() ||
isPRAgainstStable(pullRequest) ||
isRequestingLatestCommitFromHermesMainBranch())
);
}
Expand Down
8 changes: 5 additions & 3 deletions scripts/hermes/prepare-hermes-for-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const {
shouldBuildHermesFromSource,
} = require('./hermes-utils');

async function main() {
if (!shouldBuildHermesFromSource()) {
async function main(pullRequest) {
if (!shouldBuildHermesFromSource(pullRequest)) {
copyPodSpec();
return;
}
Expand All @@ -40,6 +40,8 @@ async function main() {
}
}

main().then(() => {
const pullRequest = process.argv.length > 2 ? process.argv[2] : null;
console.log(`Pull request detected: ${pullRequest}`);
main(pullRequest).then(() => {
process.exit(0);
});

0 comments on commit 5d7a490

Please sign in to comment.