Skip to content

Conversation

@mokagio
Copy link
Contributor

@mokagio mokagio commented Jan 16, 2026

What does it do?

I tried running the screenshot annotation on my end and it failed. Internal ref p1768453313053599/1768288277.528279-slack-CC7L49W13.

The reason it failed is that I didn't have screenshots images to annotate. That's obvious in hindsight, but it took me a bit to understand in between the dense logs.

This PR tracks the changes I made to cleanup the logs.

Note

As discussed in the thread, I haven't been able to test the changes yet in terms of actually calling down to ImageMagick. Still, I'd appreciate your feedback.

Update: This has now been tested locally, but I closed the session with the successful outcome so I don't have a screenshot (pun not intended) to share.

I sampled the generated annotated screenshots and they LGTM.

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. — N.A.
  • 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. — N.A.

Otherwise, every hit (and there are many) of the method would print the
path in the logs. Example:

```
[20:09:25]: -------------------------------
[20:09:25]: --- Step: promo_screenshots ---
[20:09:25]: -------------------------------
[20:09:25]: Creating Promo Screenshots
/opt/homebrew/bin/drawText
[20:09:25]: ✅ Original Screenshot Source: /Users/gio/Developer/a8c/wcios/fastlane/screenshots
/opt/homebrew/bin/drawText
[20:09:25]: ✅ Translation source: /Users/gio/Developer/a8c/wcios/fastlane/metadata
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
[20:09:26]: ▸  ✅ Font "Helvetica Neue" found and active
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
[20:09:26]: ✅ Output Folder: /Users/gio/Developer/a8c/wcios/fastlane/promo_screenshots
/opt/homebrew/bin/drawText
[20:09:26]: 💙 Creating Promo Screenshots for: ar-SA, de-DE, en-US
[20:09:26]: Do you want to overwrite the existing promo screenshots? (y/n)
y
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/opt/homebrew/bin/drawText
/Users/gio/Developer/a8c/wcios/vendor/bundle/ruby/3.2.0/gems/fastlane-plugin-wpmreleasetoolkit-13.8.1/lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb:410: warning: passing a block without an image argument is deprecated
...
```
Felt pretty dumb when I looked in the screenshots folder and realized
that it was empty because, duh, I didn't run the automation.
Doing so prevents printing the long `drawText` message and making the
logs noisy.

I tried using `command:` and `log: false` to silence that (as per
fastlane/fastlane#14945) but it didn't work.
end

UI.user_error!('`drawText` not found – install it using `brew install automattic/build-tools/drawText`.') unless system('command -v drawText')
UI.user_error!('`drawText` not found – install it using `brew install automattic/build-tools/drawText`.') unless system('command -v drawText > /dev/null')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Otherwise, we'd get a long list of command -v drawText output.

As a side note, this line seems to be called many times. We should cache, memoize, or otherwise implement a way to run this check only once.

Copy link
Contributor

Choose a reason for hiding this comment

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

So I guess we should consider something like:

UI.user_error!('`drawText` not found – install it using `brew install automattic/build-tools/drawText`.') unless self.drawText_available?

And then:

def self.drawText_available?
  @drawText_available ||= system('command -v drawText')
end

Comment on lines -410 to 422
Image.new(width, height) do
self.background_color = working_background
Image.new(width, height) do |info|
info.background_color = working_background
end
end
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 addresses a deprecation warning. See commit message for more details.

message = <<~MESSAGE
Unable to locate #{path}.
Did you run the automation to generate the screenshots?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just in case I go through the same process of pondering why annotating non existing screenshots fails again.

Did you run the automation to generate the screenshots?
MESSAGE
UI.user_error!(message)
Copy link
Contributor Author

@mokagio mokagio Jan 16, 2026

Choose a reason for hiding this comment

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

Used user_error! instead of crash! because it makes less noise in the logs as it doesn't give a stacktrace.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good one 👍

@mokagio mokagio requested review from iangmaia and twstokes January 16, 2026 05:22
@mokagio mokagio enabled auto-merge January 19, 2026 00:35
This is just in case the `sh` error I'm experiencing has been fixed
recently.

I haven't actually checked the release notes, but an update like this is
beneficial anyway.
`Action.sh` delegates directly to `Actions.sh_control_output,` which accepts
`print_command:` and `print_command_output:`, not `log:`.

The delegation occurs in `fastlane/lib/fastlane/action.rb` using Ruby's
Forwardable module:

```
def_delegator(Actions, :sh_control_output, :sh)
```

`Actions.sh` is a wrapper that accepts `log:` and translates it to `print_command:` and
`print_command_output:` when calling `sh_control_output`.

See:

- https://github.com/fastlane/fastlane/blob/2.231.0/fastlane/lib/fastlane/action.rb#L32-L39
- https://github.com/fastlane/fastlane/blob/2.231.0/fastlane/lib/fastlane/helper/sh_helper.rb#L4-L28
elsif can_resolve_path(localized_file)
resolve_path(localized_file).realpath.to_s
else
UI.important("Could not identify '#{localized_file}' as a file path or the file was not found. Will use its value as a raw string. This may result in undesired annotations.")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In testing, I was surprised to find annotated screenshots with a path instead of of text as the title.

The reason was misconfiguration of the path on my end, but the fact remains that the tool, in being flexible, might hide missing files. This can be dangerous if automation runs unsupervised.

We might want to rethink the tool's behavior. But in the meantime, here's a warning in the logs.

Image

(Not sure yet why it's printed twice)

Copy link
Contributor

Choose a reason for hiding this comment

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

The reason was misconfiguration of the path on my end, but the fact remains that the tool, in being flexible, might hide missing files. This can be dangerous if automation runs unsupervised.

👍 I agree.


Not sure yet why it's printed twice

I see that if both paths are misconfigured and can't be resolved, we'll then have two warnings as resolve_text_into_path is called twice (draw_caption_to_canvas and draw_text_attachment_to_canvas).

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 see that if both paths are misconfigured

Oh, of course! Thanks @iangmaia !

In my tests, I had hardcoded only one language, but forgot Woo is configured to create promo screenshots for iPhone and iPad. Given the copy is the same, we'll obviously attempt two reads of that localization file. All clear now.

@iangmaia iangmaia disabled auto-merge January 19, 2026 15:13
Copy link
Contributor

@iangmaia iangmaia left a comment

Choose a reason for hiding this comment

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

Left a non blocking comment about avoiding command -v being called multiple times and there's also the CHANGELOG.md update.

Approving to unblock (I've disabled auto-merge in case you want to address anything before merging).

mokagio and others added 2 commits January 20, 2026 10:28
---

Generate with the help of Claude Code, https://code.claude.com

Co-Authored-By: Ian Maia <ian.maia@automattic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
From the docs:

Use this method to exit the program because of terminal state that is
neither the fault of fastlane, nor a problem with the user's input.
Using this method instead of user_error! will avoid tracking this
outcome as a fastlane failure.
Dir.mkdir(path)
else
UI.user_error!("Exiting to avoid overwriting #{description}.")
UI.abort_with_message!("Exiting to avoid overwriting #{description}.")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems more appropriate as an exit call resulting from a confirm user input than user_error!.

I'd actually argue we should not crash and simply terminate the execution (return, next). But that's out of scope at the moment because it would require restructuring the entire method to bubble up the intention of terminating. Simply calling return here would only result in the code continuing, which is not what we desire.

@mokagio
Copy link
Contributor Author

mokagio commented Jan 20, 2026

@iangmaia thanks again for the review. I implemented your suggestions and tested the code locally via the integration PR on WooCommerce iOS, woocommerce/woocommerce-ios#16517

I'm going to merge to keep the ball rolling. Then, I'll merge trunk into #684 to sort out the CHANGELOG conflicts that will arise.

@mokagio mokagio merged commit 7f6f5aa into trunk Jan 20, 2026
6 checks passed
@mokagio mokagio deleted the ainfra-1750-fix-repo-config-or-release-toolkit-issue-resulting-in-promo branch January 20, 2026 02:25
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