From f4e04eb98351d66279d69b3deaefc9492ca64490 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Fri, 15 Mar 2024 10:03:14 -0700 Subject: [PATCH] Fix RNTester Podfile.lock update in release workflow Summary: The previous `update_podfile_lock.sh` script would fail as executed from the repo root (could not locate RNTester dir). Delete this and replace with direct calls in `prepare-package-for-release.js`, which will fail script on error. {F1469216632} Changelog: [Internal] Reviewed By: cortinico Differential Revision: D54949214 --- scripts/consts.js | 10 +++++++ .../prepare-package-for-release.js | 22 +++++++++++---- scripts/update_podfile_lock.sh | 27 ------------------- 3 files changed, 27 insertions(+), 32 deletions(-) delete mode 100755 scripts/update_podfile_lock.sh diff --git a/scripts/consts.js b/scripts/consts.js index a4528fea7dceb6..6c127fc56c967a 100644 --- a/scripts/consts.js +++ b/scripts/consts.js @@ -36,9 +36,19 @@ const REACT_NATIVE_PACKAGE_DIR /*: string */ = path.join( 'react-native', ); +/** + * The absolute path to the rn-tester package. + */ +const RN_TESTER_DIR /*: string */ = path.join( + REPO_ROOT, + 'packages', + 'rn-tester', +); + module.exports = { PACKAGES_DIR, REACT_NATIVE_PACKAGE_DIR, REPO_ROOT, + RN_TESTER_DIR, SCRIPTS_DIR, }; diff --git a/scripts/releases-ci/prepare-package-for-release.js b/scripts/releases-ci/prepare-package-for-release.js index ae8b54c3fdee3e..80362844cd6c40 100755 --- a/scripts/releases-ci/prepare-package-for-release.js +++ b/scripts/releases-ci/prepare-package-for-release.js @@ -11,12 +11,14 @@ 'use strict'; +const {RN_TESTER_DIR} = require('../consts'); const {setReactNativeVersion} = require('../releases/set-rn-version'); const {failIfTagExists} = require('../releases/utils/release-utils'); const { isReleaseBranch, parseVersion, } = require('../releases/utils/version-utils'); +const {execSync} = require('child_process'); const {echo, exec, exit} = require('shelljs'); const yargs = require('yargs'); @@ -95,11 +97,21 @@ async function main() { } // Release builds should commit the version bumps, and create tags. - echo('Updating RNTester Podfile.lock...'); - if (exec('source scripts/update_podfile_lock.sh && update_pods').code) { - echo('Failed to update RNTester Podfile.lock.'); - echo('Fix the issue, revert and try again.'); - exit(1); + try { + console.log('Updating RNTester Podfile.lock'); + execSync( + ` + bundle install; + bundle exec pod install; + `, + {cwd: RN_TESTER_DIR, stdio: 'inherit'}, + ); + } catch (e) { + console.error('Failed to update RNTester Podfile.lock.'); + console.error('Fix the issue, revert and try again.'); + + process.exitCode = 1; + return; } echo(`Local checkout has been prepared for release version ${version}.`); diff --git a/scripts/update_podfile_lock.sh b/scripts/update_podfile_lock.sh deleted file mode 100755 index 4a65df8c9d909a..00000000000000 --- a/scripts/update_podfile_lock.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -# Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -# This script updates RNTester Podfile.lock after verifying the CocoaPods environment. -# Usage: -# source scripts/update_podfile_lock && update_pods - -THIS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -RNTESTER_DIR="$THIS_DIR/../packages/rn-tester" - -# Keep this separate for FB internal access. -validate_env () { - cd "$RNTESTER_DIR" || exit - bundle check || exit - cd "$THIS_DIR" || exit -} - -update_pods () { - cd "$RNTESTER_DIR" || exit - bundle install || exit - bundle check || exit - bundle exec pod install - cd "$THIS_DIR" || exit -}