Skip to content

Conversation

@mokagio
Copy link
Contributor

@mokagio mokagio commented Dec 4, 2025

Closes AINFRA-1614.

Description

Similar to woocommerce/woocommerce-android#15027, this PR adds an optional step that will appear on CI builds from trunk to deploy to Firebase App Distribution.

Test Steps

Given the step will appear only on trunk we can only test once this is merged... However, you can see an hacked version here #16431

Screenshots

fad.mov
image IMG_5772
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary. - N.A.

key: prototype_triggered
- label: Prototype Build
depends: prototype_triggered
command: .buildkite/commands/prototype-build.sh
Copy link
Contributor Author

@mokagio mokagio Dec 4, 2025

Choose a reason for hiding this comment

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

I considered splitting build from upload as part of this PR, but decided to save it log it as a nice to have for a future date instead.

Doing so would have required updating the existing prototype build step and I didn't want to grow the scope.

plugins: [$CI_TOOLKIT]
notify:
- github_commit_status:
context: Prototype Build From Trunk
Copy link
Contributor Author

@mokagio mokagio Dec 4, 2025

Choose a reason for hiding this comment

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

Notice the different name for the check, just in case the same commit already run from a PR (impossible with merge commits and squashes, but one never knows... rebase and merge? cherry pick and force push bypassing checks?) and also to keep things tidy.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it actually makes sense to have this notify at all. Given this step will only run on trunk, and not on PRs—while the github_commit_status are mostly (only?) used to report the status of CI steps on GitHub PRs' UI, right?

So maybe we might as well remove that notify attribute altogether on that one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there's marginal value in keeping this. GitHub shows the commit checks outside PRs, too.

Here's from example in the repo's landing page:

image

If clicked, it shows:

image

It might be useful at some point to have the check -> CI job link accessible this way.

But... I don't feel strongly about it. Happy to delete if this doesn't sound like a strong enough reason.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah good point, completely forgot about that UI in GitHub to show checks on any commit even outside PRs 👍

Comment on lines 779 to 783
release_notes = <<~NOTES
Pull Request: ##{pull_request_number || 'N/A'}
Branch: `#{ENV.fetch('BUILDKITE_BRANCH', 'N/A')}`
Commit: #{ENV.fetch('BUILDKITE_COMMIT', 'N/A')[0...7]}
NOTES
release_notes += "Pull Request: ##{PULL_REQUEST_NUMBER}" unless PULL_REQUEST_NUMBER.nil?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know what you think, but if we have builds from trunk which definitely won't have a PR, it would seem noisy to read "Pull Request: N/A" in the release notes, especially at the top.

pr_num == 'false' ? nil : Integer(pr_num)
end
# Buildkite sets this env var to the PR number if on a PR, but to 'false' (and not nil) if not on a PR
PULL_REQUEST_NUMBER = ENV['BUILDKITE_PULL_REQUEST']&.then { |n| n == 'false' ? nil : Integer(n) }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A micro-optimization for sure, but it seemed unnecessary to read a constant value from the env a number of times when we could have stored it in a Ruby constant.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am on two minds about this tbh.

I see your point of not recomputing the value multiple times, but OTOH, making it a constant (in the strict sense of the term, i.e. with all-uppercase syntax and all) feels a bit wrong to me conceptually, because it's not a value that is fixed and never changing across all runs (like e.g. FIREBASE_APP_ID or IOS_LOCALES or SIMULATOR_VERSION are), but instead something that will have a different value depending on the PR. I think that's the main rationale as to why that was exposed as a helper function rather than a Ruby constant in the first place.

My two cents:

  1. Either rename the variable to lowercase (pull_request_number = … )—to not technically make it a Ruby constant. Then move its declaration to the top of the Fastfile.
  2. Or keep it as a def pull_request_number helper, but add memoization to avoid recomputing the value (not worth it imho)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point.

@copilot address this comment by renaming PULL_REQUEST_NUMBER to pull_request_number

@mokagio mokagio marked this pull request as ready for review December 4, 2025 03:49
@mokagio mokagio added this to the 23.9 milestone Dec 4, 2025
@mokagio mokagio added the category: tooling Anything that involves building & maintaining the project, including scripts, `Fastfile`, etc. label Dec 4, 2025
@mokagio mokagio force-pushed the ainfra-1614-build-wc-ios-prototypes-from-trunk branch from 46780f7 to 52f78e1 Compare December 4, 2025 03:53
@mokagio mokagio force-pushed the ainfra-1614-build-wc-ios-prototypes-from-trunk branch from 52f78e1 to 0a28f5e Compare December 4, 2025 03:54
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 4, 2025

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Numberpr16432-66961b3
Version23.8
Bundle IDcom.automattic.alpha.woocommerce
Commit66961b3
Installation URL656u3kd61spco
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

Branch: `#{ENV.fetch('BUILDKITE_BRANCH', 'N/A')}`
Commit: #{ENV.fetch('BUILDKITE_COMMIT', 'N/A')[0...7]}
NOTES
release_notes += "Pull Request: ##{PULL_REQUEST_NUMBER}" unless PULL_REQUEST_NUMBER.nil?
Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be a newline there?

Suggested change
release_notes += "Pull Request: ##{PULL_REQUEST_NUMBER}" unless PULL_REQUEST_NUMBER.nil?
release_notes += "\nPull Request: ##{PULL_REQUEST_NUMBER}" unless PULL_REQUEST_NUMBER.nil?

Copy link
Contributor

Choose a reason for hiding this comment

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

Tested this quickly in irb, and seems the heredoc syntax already includes a trailing \n:
Image
So no need for an extra one at the start there (but one could argue we might need one at the end, for consistency of always ending the release_notes string with a newline?)

Suggested change
release_notes += "Pull Request: ##{PULL_REQUEST_NUMBER}" unless PULL_REQUEST_NUMBER.nil?
release_notes += "Pull Request: ##{PULL_REQUEST_NUMBER}\n" unless PULL_REQUEST_NUMBER.nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but one could argue we might need one at the end, for consistency of always ending the release_notes string with a newline?

It wouldn't hurt, but for what is worth, not having the new line does not affect how Firebase renders the release notes. They look the same with (via old version using one heredoc) or without (via this branch's implementation)

IMG_5773 IMG_5774

plugins: [$CI_TOOLKIT]
notify:
- github_commit_status:
context: Prototype Build From Trunk
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it actually makes sense to have this notify at all. Given this step will only run on trunk, and not on PRs—while the github_commit_status are mostly (only?) used to report the status of CI steps on GitHub PRs' UI, right?

So maybe we might as well remove that notify attribute altogether on that one?

pr_num == 'false' ? nil : Integer(pr_num)
end
# Buildkite sets this env var to the PR number if on a PR, but to 'false' (and not nil) if not on a PR
PULL_REQUEST_NUMBER = ENV['BUILDKITE_PULL_REQUEST']&.then { |n| n == 'false' ? nil : Integer(n) }
Copy link
Contributor

Choose a reason for hiding this comment

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

I am on two minds about this tbh.

I see your point of not recomputing the value multiple times, but OTOH, making it a constant (in the strict sense of the term, i.e. with all-uppercase syntax and all) feels a bit wrong to me conceptually, because it's not a value that is fixed and never changing across all runs (like e.g. FIREBASE_APP_ID or IOS_LOCALES or SIMULATOR_VERSION are), but instead something that will have a different value depending on the PR. I think that's the main rationale as to why that was exposed as a helper function rather than a Ruby constant in the first place.

My two cents:

  1. Either rename the variable to lowercase (pull_request_number = … )—to not technically make it a Ruby constant. Then move its declaration to the top of the Fastfile.
  2. Or keep it as a def pull_request_number helper, but add memoization to avoid recomputing the value (not worth it imho)

mokagio and others added 2 commits December 5, 2025 11:17
Copy link
Contributor

Copilot AI commented Dec 5, 2025

@mokagio I've opened a new pull request, #16435, to work on those changes. Once the pull request is ready, I'll request review from you.

@mokagio
Copy link
Contributor Author

mokagio commented Dec 5, 2025

@AliSoftware @twstokes I should have implemented or commented on all your feedback. Thanks.

@mokagio mokagio enabled auto-merge December 5, 2025 01:31
@mokagio mokagio merged commit 2989fb8 into trunk Dec 5, 2025
13 checks passed
@mokagio mokagio deleted the ainfra-1614-build-wc-ios-prototypes-from-trunk branch December 5, 2025 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: tooling Anything that involves building & maintaining the project, including scripts, `Fastfile`, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants