Skip to content

Conversation

@mokagio
Copy link
Contributor

@mokagio mokagio commented Sep 5, 2022

This makes the lane parameter using the same name as the buildkite_trigger_build action, avoiding confusion in the rare cases we need to call it manually.

If you called the trigger_release_build or trigger_beta_build lane without a parameter, you'll get prompted to pass a branch one, by the underlying buildkite_trigger_build action.

But if you next time called the lane with a branch parameter, you'd still get prompted to pass one, because the lane expected branch_to_build , but this was not made clear by the messages Fastlane prompted.

Screen Shot 2022-09-05 at 3 17 53 pm

For some reason, Preview doesn't open the screenshot I uploaded above, so I can't highlight the parts that show the branch input inconsistencies.

Rather than adding extra code for this, I thought aligning the parameters name would sort out the issue.

The approach I took leans a bit into the convention over configuration realm, though. There's nothing stopping future developers to reintroduce the same confusion by renaming the parameter either at the lane or action level. Given the limited userbase of this code and the relative slow pace at which it changes, I think that's an acceptable tradeoff to have convenience for the time being.

Regression Notes

  1. Potential unintended areas of impact – N.A.
  2. What I did to test those areas of impact (or what existing automated tests I relied on) – N.A.
  3. What automated tests I added (or what prevented me from doing so) – N.A.

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes. N.A.
  • I have considered adding accessibility improvements for my changes. N.A.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary. N.A.

This makes the lane parameter using the same name as the
`buildkite_trigger_build` action, avoiding confusion in the rare cases
we need to call it manually.

If you called the `trigger_release_build` or `trigger_beta_build` lane
without a parameter, you'll get prompted to pass a `branch` one, by the
underlying `buildkite_trigger_build` action.

But if you next time called the lane with a `branch` parameter, you'd
still get prompted to pass one, because the lane expected
`branch_to_build` , but this was not made clear by the messages Fastlane
prompted.

Rather than adding extra code for this, I thought aligning the
parameters name would sort out the issue. This leans a bit into the
convention over configuration realm, though. There's nothing stopping
future developers to reintroduce the same confusion by renaming the
parameter either at the lane or action level. Given the limited userbase
of this code and the relative slow pace at which it changes, I think
that's an acceptable tradeoff to have convenience for the time being.
end

UI.message("Gutenberg version: #{(res.scan(/'([^']*)'/))[0][0]}")
UI.message("Gutenberg version: #{res.scan(/'([^']*)'/)[0][0]}")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is unrelated to the PR, but a tiny RuboCop violation fix that I though valuable to sneak in.

@mokagio mokagio requested a review from a team September 5, 2022 05:34
@mokagio mokagio self-assigned this Sep 5, 2022
@mokagio mokagio added the Tooling Build, Release, and Validation Tools label Sep 5, 2022
@mokagio mokagio added this to the 20.7 ❄️ milestone Sep 5, 2022
#
lane :trigger_beta_build do |options|
trigger_buildkite_release_build(branch: options[:branch_to_build], beta: true)
trigger_buildkite_release_build(branch: options[:branch], beta: true)
Copy link
Contributor

Choose a reason for hiding this comment

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

tbh in the couple of cases I need to call this lane manually, I'm already often annoyed that I have to provide the branch name explicitly… and I've pondered a while ago if we shouldn't default it to "release/#{ios_get_app_version}" if we don't provide a branch: parameter explicitly from the CLI, to make things even easier to call?

Suggested change
trigger_buildkite_release_build(branch: options[:branch_to_build], beta: true)
trigger_buildkite_release_build(branch: options[:branch], beta: true)
branch_to_build = options[:branch] || "release/#{ios_get_app_version}"
trigger_buildkite_release_build(branch: branch_to_build, beta: true)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea. This default value is particularly appropriate for "beta" and "release" builds as release/... is the expected branch for them.

Also using ios_get_app_version would work most of the time, the only case I can think of resulting in an unexpected build would be if the branch from which we run this is not up-to-date with trunk, or if we run from trunk in the middle of a code freeze. Both are super-edge cases. Besides, an unexpected value in that way would be rejected by ASC, so no harm done 👍

@mokagio mokagio marked this pull request as ready for review September 5, 2022 10:07
@mokagio
Copy link
Contributor Author

mokagio commented Sep 5, 2022

Added some further refinements:

  • Leverage the default value being release/#{ios_get_app_version} to call the lanes with no parameters
  • Centralize the logic to compute the release branch name

This, IMHO, makes the code nicer to read. That comes at the cost of jumping here and there if you want to know the details of an individual call, but it's worth if each top-level lane can read like a set of instructions.

@peril-wordpress-mobile
Copy link

Warnings
⚠️ This PR is assigned to a milestone which is closing in less than 4 days Please, make sure to get it merged by then or assign it to a later expiring milestone

Generated by 🚫 dangerJS

@wpmobilebot
Copy link
Contributor

You can test the changes in Jetpack from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr19281-aab6779 on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@wpmobilebot
Copy link
Contributor

You can test the changes in WordPress from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr19281-aab6779 on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@mokagio mokagio merged commit b037b8d into release/20.7 Sep 6, 2022
@mokagio mokagio deleted the mokagio/align-parameters-names-in-buildkite-actions branch September 6, 2022 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Tooling Build, Release, and Validation Tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants