Skip to content

Fix post_install hook to use the project directory when patching a ReactNative file#14239

Merged
jkmassel merged 1 commit intorelease/15.0from
15.0-fix-cocoapods-patch
Jun 3, 2020
Merged

Fix post_install hook to use the project directory when patching a ReactNative file#14239
jkmassel merged 1 commit intorelease/15.0from
15.0-fix-cocoapods-patch

Conversation

@pinarol
Copy link
Copy Markdown
Contributor

@pinarol pinarol commented Jun 3, 2020

Fixes #

We saw that the patch introduced with this PR was not getting applied. It manifested itself in the ActionSheet, mover buttons aren't disabled properly.

Reality:

Screen Shot 2020-06-03 at 10 14 59

Expected:
Screen Shot 2020-06-03 at 10 14 59

Root Cause

[12:56:13]: ▸ sh: patches/react-native+0.61.5.patch: No such file or directory
[12:56:13]: ▸ Patching RCTActionSheet to add possibility to disable action sheet buttons -
[12:56:13]: ▸ it could be removed once PR with that functionality will be merged into RN
[12:56:13]: ▸ sh: patches/react-native+0.61.5.patch: No such file or directory

It turns out fastlane builds are run from the WordPress/Scripts folder, so patch doesn't find the file since there's no dir as Scripts/patches.

(fastlane scripts that we use to build the releases live in the Scripts folder)

To fix this, we are updating the paths to use project_root.

To test:

  • Clear Pods folder
  • cd to Script folder and run bundle exec pod install
  • Check the logs to see that no errors are produced during patching
  • Open the patched file /Users/pinarolguc/Development/WordPress-iOS/Pods/React-RCTActionSheet/RCTActionSheetManager.m make sure this line exists:

NSArray<NSNumber *> *disabledButtonIndices = [RCTConvert NSArray:options[@"disabledButtonIndices"]];

  • clear Pods folder
  • run rake dependencies in the root folder(WordPress-iOS)
  • Check the logs again

bonus: It'd be good if we can open the app and see the mover buttons getting disabled as well

PR submission checklist:

  • I have considered adding unit tests where possible.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@pinarol pinarol self-assigned this Jun 3, 2020
@peril-wordpress-mobile
Copy link
Copy Markdown

You can trigger an installable build for these changes by visiting CircleCI here.

@pinarol pinarol added this to the 15.0 ❄️ milestone Jun 3, 2020
@pinarol pinarol requested a review from loremattei June 3, 2020 13:48
@peril-wordpress-mobile
Copy link
Copy Markdown

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

Copy link
Copy Markdown
Contributor

@loremattei loremattei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the issue 👍👍
As discussed in Slack, running shell commands this way is dangerous because it fails silently, so we may get in troubles again in the future.
I think this fix is good for moving the release ahead, but we should work at a more reliable solution in develop, either forking the original repository until the patch lands or improving the post_install hook so that it breaks when the shell command fails.

cc/ @jkmassel

@jkmassel jkmassel merged commit 48f45c5 into release/15.0 Jun 3, 2020
@jkmassel jkmassel deleted the 15.0-fix-cocoapods-patch branch June 3, 2020 16:32
@pinarol
Copy link
Copy Markdown
Contributor Author

pinarol commented Jun 3, 2020

Thank you @loremattei Opened another issue to tackle that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants