[fastlane] Print better errors when exception occurring in Fastfile #21977
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist
bundle exec rspec
from the root directory to see all new and existing tests passbundle exec rubocop -a
to ensure the code style is validci/circleci
builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)Motivation and Context
When there is an error in the Fastfile, the error printed out isn't always clear which line from the fastfile the error comes from.
lane :foo do |readonly: true|
keyword syntax to declare my lanes in myFastfile
(see Add support for keyword arguments for lanes in Ruby 3 #21587) and noticed that calling that lane with incorrect arguments didn't show me the call site that needed fixing, but instead the line where the method was declared.🖼️ e.g.
Fastfile
calling a lane namedalpha_code_signing
which ends up callingupdate_code_signing_enterprise(read_only: true, app_identifiers: APP_IDS)
with wrong parameters, but logs doesn't show me that the problem is at the call site in thealpha_code_signing
lane🖼️ e.g. If I have a
boum!
in the code of one of my lane, it doesn't show me where in theFastfile
thatboum!
call isDescription
This PR improves the output of errors that happen when evaluating lanes in the
Fastfile
—be itArgumentError
for invalid lane parameters, invalid action names, etc—to print more code context, and print that context in more cases (e.g. even if the exception from the Fastfile evaluation is not at the top of the backtrace).Now the error reporting looks like this:
🖼️ Calling another lane with wrong keyword arguments
🖼️ Calling another Ruby function with wrong arguments
🖼️ Calling a non-existing method from the Fastfile
Testing Steps
Fastfile
in a test folderGemfile
in that test folder pointing to this branch offastlane
, runbundle install
bundle exec fastlane parent
and confirm that it worksbundle exec fastlane parent arg_1:oops
and confirm that the error is logged with a nice backtrace pointing to the definition oflane :parent
, and the full Ruby stacktrace isn't printedFastfile
to introduce an error in the call site ofchild
within theparent
lanebundle exec fastlane parent arg1:false
and confirm that the error is logged with two nice backtraces pointing to the definition oflane :child
then the erroneous call site of it withinlane :parent
Fastfile
, like in the call tocustom_func