Skip to content

Ensure Podfile.lock is synced with project#13821

Merged
amyevans merged 18 commits into
Expensify:mainfrom
redstar504:Brayden-PodValidation
Jan 4, 2023
Merged

Ensure Podfile.lock is synced with project#13821
amyevans merged 18 commits into
Expensify:mainfrom
redstar504:Brayden-PodValidation

Conversation

@redstar504

@redstar504 redstar504 commented Dec 24, 2022

Copy link
Copy Markdown
Contributor

cc @mollfpr @roryabraham @amyevans

Details

This PR updates the verifyPodfile.sh workflow script to catch uncommitted Podfile.lock changes.

In addition to all of the changes we've discussed in the issue, it:

  • Modifies verifyPodfile.sh further to account for package removals. This adds some complexity so I broke the logic Rory wrote out into functions so it could be re-used for the removal logic. The removal logic mostly works as described in this comment.
  • To elaborate on one of the differences, in my finalized script I switch to main branch and grab the main branch podspecs at the beginning so we don't have to swap package-lock.json more than once in the script. This is done because the subtractions (main_branch_podspecs - feature_branch_podspecs) are ultimately evaluated against the feature branch's Podfile.lock at the end of the script.
  • Two flags have been added to the verifyPodfile.sh script. The first flag specifies the branch to compare against for removals. It should be origin/main in the production version. Since the GitHub checkout action only fetches the remote refs, it checks out the package-lock.json from origin/main. This flag eases testing of the script on development environments where you would likely be comparing against main.
  • The second flag is just -v for verbosity. It simply outputs the podspecs from the main branch, feature branch, and finally the subtracted packages between both to ease debugging. I have removed that argument in this PR as it was mostly for solving issues during testing.
  • This PR modifies the messages outputted by the original verifyPodfile.sh logic to clarify that the original portion of the script only compares the checksums to help avoid confusion.
  • I completed a sequence of tests on an example branch in my fork to demonstrate that it works for all cases in an actual runner. See here. My tests specified the verbose flag so you would see outputs of that in the runner logs. They were also performed before the change described in the previous point.
  • A good chunk of the script is just for debugging purposes and for easing testing. The logic for the validating itself is fairly straight forward, it just requires the specific state that the runner would be in.

Fixed Issues

$ #13397
PROPOSAL: #13397 (comment)

Tests

  1. Add/update/remove npm packages that have autolinked pods. Some examples are listed below that are already added to the project for you to try removing.
  2. Omit running pod install
  3. Run the script from %project_root%: ./.github/scripts/verifyPodfile.sh
  4. Verify the command outputs an error message related to the changes that were not committed to the Podfile.lock.
  5. Run the npx pod-install command, or switch to ios directory and run pod install.
  6. Return to the project root and run the script again as in step 3.
  7. Confirm script succeeds with pods are synced message.

Example packages:
react-native-image-picker
react-native-image-pan-zoom
react-native-render-html

I have also completed a sequence of tests in a Github runner in an example PR on my fork. Each commit to this branch corresponds to a stage of the Podfile.lock validation that passes or fails. See here.

  • Verify that no errors appear in the JS console

Offline tests

Not relevant to the proposed changes.

QA Steps

  1. Add/update/remove npm packages that are autolinked to Pods (see example packages below to try removing).
  2. Omit running pod install after completing these commands.
  3. Commit and push the changed package.json and package-json.lock to the staging branch.
  4. Observe the Github verifyPodfile workflow. It should fail with an error message.
  5. Run the npx pod-install command or switch to the ios directory and run pod install.
  6. Commit the updated Podfile.lock and push the commit to the staging branch.
  7. Confirm that the verifyPodfile workflow completes successfully.

Example packages:
react-native-image-picker
react-native-image-pan-zoom
react-native-render-html

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Not relevant to proposed changes.

@redstar504
redstar504 requested a review from a team as a code owner December 24, 2022 21:33
@melvin-bot
melvin-bot Bot requested review from amyevans and mollfpr and removed request for a team December 24, 2022 21:33
@melvin-bot

melvin-bot Bot commented Dec 24, 2022

Copy link
Copy Markdown

@amyevans @mollfpr One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@github-actions

github-actions Bot commented Dec 24, 2022

Copy link
Copy Markdown
Contributor

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@redstar504

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@redstar504

Copy link
Copy Markdown
Contributor Author

recheck

@mollfpr

mollfpr commented Dec 25, 2022

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is correct English and approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Pod check failed

Add package
Added package without run pod install

Update package
Updated package without run pod install

Remove package
Removed package without run pod install

Pod check passed

Add package
Added package with run pod install

Update package
Updated package with run pod install

Remove package
Removed package with run pod install

No packages updated 13821 No packages updated

@mollfpr

mollfpr commented Dec 25, 2022

Copy link
Copy Markdown
Contributor

@redstar504 @roryabraham I'm thinking we can skip the check if there are no changes to the package.json and package-lock.json where it's mean no updated packages in the PR.

@redstar504

redstar504 commented Dec 25, 2022

Copy link
Copy Markdown
Contributor Author

@mollfpr Sounds like a good idea. I've added a commit to include that logic. I also tested this in a runner on my fork: redstar504#6

@redstar504
redstar504 force-pushed the Brayden-PodValidation branch from bae6324 to 58e4cc2 Compare December 26, 2022 02:20
@redstar504
redstar504 force-pushed the Brayden-PodValidation branch from 26c4c1f to a106f81 Compare December 26, 2022 04:04
@mollfpr

mollfpr commented Dec 26, 2022

Copy link
Copy Markdown
Contributor

@redstar504 Great work on the current update! Let me know when it's ready to review and test.

@redstar504

redstar504 commented Dec 26, 2022

Copy link
Copy Markdown
Contributor Author

@mollfpr You can review/test now. I added a couple checks to help catch some testing issues.

Comment thread .github/scripts/verifyPodfile.sh Outdated
mollfpr
mollfpr previously approved these changes Dec 27, 2022

@mollfpr mollfpr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍

Here’s the checklist.

@mollfpr

mollfpr commented Dec 28, 2022

Copy link
Copy Markdown
Contributor

@redstar504 We should give an example of what package that have auto-linked on the test case.

mollfpr
mollfpr previously approved these changes Dec 28, 2022

@mollfpr mollfpr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM and test well again 👍

@mollfpr

mollfpr commented Dec 28, 2022

Copy link
Copy Markdown
Contributor

Updated screenshot for add, update and remove package scenario.

All yours @amyevans @roryabraham

@amyevans amyevans left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Still testing but the code lgtm. @roryabraham do you want the chance to review?

Comment thread .github/scripts/verifyPodfile.sh Outdated
Co-authored-by: Amy Evans <amy@expensify.com>
Comment thread .github/scripts/verifyPodfile.sh Outdated
Comment thread .github/scripts/verifyPodfile.sh Outdated
Comment thread .github/scripts/verifyPodfile.sh Outdated
Comment thread .github/scripts/verifyPodfile.sh Outdated
Comment thread .github/scripts/verifyPodfile.sh Outdated
Comment thread .github/scripts/verifyPodfile.sh Outdated
@redstar504
redstar504 dismissed stale reviews from mollfpr and amyevans via 3553ba2 January 3, 2023 20:39
@redstar504

Copy link
Copy Markdown
Contributor Author

I have completed the refactors notwithstanding our discussion on the removal check.

@redstar504
redstar504 force-pushed the Brayden-PodValidation branch from 1529df5 to e9194f3 Compare January 4, 2023 02:01
@mollfpr

mollfpr commented Jan 4, 2023

Copy link
Copy Markdown
Contributor

Just retest it again and it seems now the check is much faster 👍

Add package without pod install ❌ Add package without pod install - failed
Add package with pod install ✅ Add package with pod install - success
Update package without pod install ❌ Update package without pod install - failed
Update package with pod install ✅ Update package with pod install - success
Remove package without pod install ❌ Remove package without pod install - failed
Remove package with pod install ✅ Remove package with pod install - success

@roryabraham roryabraham left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks way better. Haven't tested but this code looks good to me. Thanks for your flexibility in finding another solution, happy we landed with something much faster than the last draft.

@roryabraham
roryabraham requested a review from amyevans January 4, 2023 19:20
@roryabraham

Copy link
Copy Markdown
Contributor

All yours @amyevans

@amyevans amyevans left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Question for my own understanding: how are jq and yq available in the script? Locally I installed with homebrew, but I don't understand how they're provided to the CI runner.

Looks good though, thanks @redstar504 for sticking with it and @mollfpr and @roryabraham for your thorough reviews and helpful improvements!

@redstar504

redstar504 commented Jan 4, 2023 via email

Copy link
Copy Markdown
Contributor Author

@amyevans

amyevans commented Jan 4, 2023

Copy link
Copy Markdown
Contributor

Okay cool, confirmed that in the docs as well.

Merging!

@amyevans
amyevans merged commit 7ac39f0 into Expensify:main Jan 4, 2023
@OSBotify

OSBotify commented Jan 4, 2023

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@mvtglobally

Copy link
Copy Markdown

@redstar504 @roryabraham @amyevans Can you please QA this internally

@OSBotify

OSBotify commented Jan 5, 2023

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by @amyevans in version: 1.2.49-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@amyevans

amyevans commented Jan 5, 2023

Copy link
Copy Markdown
Contributor

@mvtglobally Yep, I'll handle QA. Thanks!

@luacmartins

Copy link
Copy Markdown
Contributor

@amyevans did you get a chance to QA this?

@amyevans

amyevans commented Jan 6, 2023

Copy link
Copy Markdown
Contributor

@luacmartins Sorry for the delay! I'm handling it now in #14059 and will update the QA checklist when I'm done.

@OSBotify

OSBotify commented Jan 6, 2023

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by @luacmartins in version: 1.2.49-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

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.

7 participants