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

[gym] Fix analyze_build_time setting interfering with xcpretty log generation #12527

Merged
merged 5 commits into from May 18, 2018

Conversation

allewun
Copy link
Contributor

@allewun allewun commented May 15, 2018

Fixes #10187

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.

Motivation and Context

gym's analyze_build_time option interferes with its own xcpretty output, since the analysis steps are incorrectly inserted between the xcodebuild and xcpretty pipelines and it improperly consumes output that should be piped to xcpretty. Processes that depend on xcpretty will thus fail (e.g. the json-compilation-database isn't generated when analyze_build_time is on).

Description

I moved the analyze_build_time steps to a post_build step that waits until the main xcodebuild ... | xcpretty command has finished. It seems more fitting that any build analysis should happen after building has completed, not during the build process.

@@ -46,26 +46,25 @@ def options
options
end

def actions
def buildactions
Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed to match more closely with xcodebuild's own documentation:

buildaction ...
           Specify a build action (or actions) to perform on the target. Available build actions are:

suffix = []
suffix << "CODE_SIGN_IDENTITY=#{Gym.config[:codesigning_identity].shellescape}" if Gym.config[:codesigning_identity]
suffix
def setting
Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed to match more closely with xcodebuild's own documentation:

setting=value
           Set the build setting setting to value.

@@ -100,6 +100,20 @@ def build_app
mark_archive_as_built_by_gym(BuildCommandGenerator.archive_path)
UI.success("Successfully stored the archive. You can find it in the Xcode Organizer.") unless Gym.config[:archive_path].nil?
UI.verbose("Stored the archive in: " + BuildCommandGenerator.archive_path)

post_build_app
Copy link
Contributor Author

Choose a reason for hiding this comment

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

is there a better way to chain this after the success of line 93?

Copy link
Member

Choose a reason for hiding this comment

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

This seems like a good enough place to me 😊

@allewun
Copy link
Contributor Author

allewun commented May 15, 2018

Ha, I just saw #12523 which tackles the same bug. Please close this PR if needed.

Copy link
Member

@joshdholtz joshdholtz left a comment

Choose a reason for hiding this comment

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

Duplicate xcpretty?

"| tee #{log_path.shellescape}",
"| grep .[0-9]ms | grep -v ^0.[0-9]ms | sort -nr > culprits.txt",
"| tee #{@log_path.shellescape}",
"| xcpretty"
Copy link
Member

Choose a reason for hiding this comment

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

I think this is a duplicate since xcpretty gets added here - https://github.com/fastlane/fastlane/pull/12527/files?utf8=✓&diff=unified#diff-440c4122de8c51769dc40db14188f030R70... right? 🤔

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 the git diff is misleading here. The | xcpretty command is part of the pipe method, which does indeed manifest in the BuildCommandGenerator.generate output that this test is testing.

I added another test case, which pushed the old xcpretty down a few lines.

Copy link
Member

Choose a reason for hiding this comment

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

My bad, that was in a spec 😝 You good 👍

@allewun allewun changed the title Fix gym's analyze_build_time setting interfering with xcpretty log generation [gym] Fix analyze_build_time setting interfering with xcpretty log generation May 16, 2018
# Post-processing of build_app
def post_build_app
command = BuildCommandGenerator.post_build
print_command(command, "Generated Post-Build Command") if FastlaneCore::Globals.verbose?
Copy link
Member

Choose a reason for hiding this comment

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

@allewun I did just catch one bug there 😊 Things go 💥 if the command array here is empty since... Putting an unless command.empty? around this fixed it for me... Do you have this same issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch! I added a guard here.

@allewun
Copy link
Contributor Author

allewun commented May 18, 2018

@joshdholtz should be good to go, let me know if there's anything missing!

Copy link
Member

@joshdholtz joshdholtz left a comment

Choose a reason for hiding this comment

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

This looks fantastic! Thanks for making this change 😊

@joshdholtz joshdholtz merged commit 51c3758 into fastlane:master May 18, 2018
@fastlane-bot
Copy link

Hey @allewun 👋

Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉
The code change now lives in the master branch, however it wasn't released to RubyGems yet.
We usually ship about once a week, and your PR will be included in the next one.

Please let us know if this change requires an immediate release by adding a comment here 👍
We'll notify you once we shipped a new release with your changes 🚀

@fastlane-bot
Copy link

Congratulations! 🎉 This was released as part of fastlane 2.96.0 🚀

@fastlane fastlane locked and limited conversation to collaborators Jul 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

analyze_build_time option causes sh: inherited: command not found, blocks xcpretty
4 participants