Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Build hermes from source on PR against stable #34228

Merged
merged 1 commit into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -936,18 +936,9 @@ jobs:
- run:
name: Download Hermes tarball
command: |
node scripts/hermes/prepare-hermes-for-build
# If Hermes is not built from source, we don't have these folders.
DOWNLOAD_FOLDER=sdks/download/
if [[ -d $DOWNLOAD_FOLDER ]]; then
cp $DOWNLOAD_FOLDER* $HERMES_WS_DIR/download/.
fi
HERMES_FOLDER=sdks/hermes/
if [[ -d $HERMES_FOLDER ]]; then
cp -r $HERMES_FOLDER* $HERMES_WS_DIR/hermes/.
fi
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:
key: v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
paths:
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 @@ -190,12 +190,27 @@ function isOnAReleaseTag() {
return currentRemote.endsWith('facebook/react-native.git');
}

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) {
const hermesTag = readHermesTag();

return (
isOnAReleaseBranch() ||
isOnAReleaseTag() ||
isPRAgainstStable(pullRequest) ||
hermesTag === DEFAULT_HERMES_TAG
);
}
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);
});