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

Refactor ios_check_beta_deps action to make it more resilient & detect Pods referenced by commit/branch #557

Merged
merged 9 commits into from
Apr 11, 2024

Conversation

AliSoftware
Copy link
Contributor

@AliSoftware AliSoftware commented Apr 10, 2024

What does it do?

Note

See discussion in p1712630806132789-slack-CC7L49W13

  • Allow detection of Pods referenced by commit or branch (while previous implementation only detected pods whose version was -beta, but not pods referenced by commit/branch)
  • Make detection more resilient by using Podfile.lock instead of the Podfile, thus addressing Make ios_check_beta_deps use Podfile.lock #216
  • Make the action return the list of detected pods as well as the message, so that the caller can then decide to e.g. call buildkite_annotate(message: result[:message]) to make the warning more visible in Buildkite.

Testing

  • Updated the Gemfile of woocommerce-ios to point the release-toolkit to this branch
  • Ran bundle install && bundle exec fastlane run ios_check_beta_deps
  • Got the following output:
    image
  • Did the same test on wordpress-ios repo, and got a green light:
    image

Checklist before requesting a review

  • Run bundle exec rubocop to test for code style violations and recommendations
  • Add Unit Tests (aka specs/*_spec.rb) if applicable
  • Run bundle exec rspec to run the whole test suite and ensure all your tests pass
  • Make sure you added an entry in the CHANGELOG.md file to describe your changes under the appropriate existing ### subsection of the existing ## Trunk section.
  • If applicable, add an entry in the MIGRATION.md file to describe how the changes will affect the migration from the previous major version and what the clients will need to change and consider.

Allow detection of Pods referenced by commits and branches

Make detection more resilient by using Podfile.lock instead of Podfile
@AliSoftware AliSoftware requested a review from a team April 10, 2024 17:46
@AliSoftware AliSoftware linked an issue Apr 10, 2024 that may be closed by this pull request
@AliSoftware AliSoftware marked this pull request as ready for review April 10, 2024 17:47
@AliSoftware AliSoftware changed the title Refactor ios_check_beta_deps action to make it more resilient Refactor ios_check_beta_deps action to make it more resilient & detect Pods referenced by commit/branch Apr 10, 2024
non_stable_pods = {} # Key will be pod name, value will be reason for flagging

# Find pods referenced by commit and branch to a repo
yaml['EXTERNAL SOURCES'].each do |pod, options|
Copy link
Contributor Author

@AliSoftware AliSoftware Apr 10, 2024

Choose a reason for hiding this comment

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

I just realized that some Podfile.lock files might not have this section at all (if they don't have any external dependency), so better cover for the nil case.

Suggested change
yaml['EXTERNAL SOURCES'].each do |pod, options|
yaml['EXTERNAL SOURCES']&.each do |pod, options|

Ideally we should add a spec example to cover that too—the one from Simplenote-macOS can serve as a fixture for that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@spencertransier I've fixed this (and added test coverage for it) via dc5992f + b1a13d9, so PR is now ready for review again 🙇

Comment on lines 51 to 52
ALL_PODS_STABLE_MESSAGE = 'All pods are pointing to a stable version. You can continue with the code freeze.'.freeze
NON_STABLE_PODS_MESSAGE = "Please create a new stable version of those pods and update the Podfile to the newly released version before continuing with the code freeze:\n".freeze
Copy link
Contributor

Choose a reason for hiding this comment

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

Why declare these constants here instead of at the top of the run method?

Copy link
Contributor Author

@AliSoftware AliSoftware Apr 10, 2024

Choose a reason for hiding this comment

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

We need those constant to be accessible from outside the code of def self.run because they are also referenced by our unit tests (here and here) 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While we couldn't move them at the top of the run method, I've moved them at the top of the class definition in 25420dd, at least

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, got it. Thank you!

@dangermattic
Copy link
Collaborator

1 Warning
⚠️ This PR is larger than 500 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

Copy link
Contributor

@spencertransier spencertransier left a comment

Choose a reason for hiding this comment

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

The refactor and tests look great to me. The logic makes sense and this will be a huge improvement to the code freeze automation. 👏

And move test about invalid regex closer to other regex-related tests
Copy link
Contributor

@mokagio mokagio left a comment

Choose a reason for hiding this comment

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

With tests, too 👨‍🍳 💋

CHANGELOG.md Outdated Show resolved Hide resolved
MIGRATION.md Outdated Show resolved Hide resolved
Comment on lines +6 to +7
ALL_PODS_STABLE_MESSAGE = 'All pods are pointing to a stable version. You can continue with the code freeze.'.freeze
NON_STABLE_PODS_MESSAGE = "Please create a new stable version of those pods and update the Podfile to the newly released version before continuing with the code freeze:\n".freeze
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick. These messages assume the action runs as part of the code freeze. That is true in practice, and the action name sort of suggests it, too. Still, I'd suggest removing the code freeze mention to make it agnostic.

regex = begin
Regexp.new(version_pattern)
rescue RegexpError
UI.user_error!("Invalid regex pattern: `#{version_pattern}`")
Copy link
Contributor

Choose a reason for hiding this comment

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

Side note. I wanted to share appreciation for this kind of error handling where the things that's wrong is clearly reported in the error message. Recently, I've bump my head against some vague error messages; seeing this is encouraging. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make ios_check_beta_deps use Podfile.lock
4 participants