-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,8 @@ def generate | |
parts = prefix | ||
parts << "xcodebuild" | ||
parts += options | ||
parts += actions | ||
parts += suffix | ||
parts += buildactions | ||
parts += setting | ||
parts += pipe | ||
|
||
parts | ||
|
@@ -46,26 +46,25 @@ def options | |
options | ||
end | ||
|
||
def actions | ||
def buildactions | ||
config = Gym.config | ||
|
||
actions = [] | ||
actions << :clean if config[:clean] | ||
actions << :archive unless config[:skip_archive] | ||
buildactions = [] | ||
buildactions << :clean if config[:clean] | ||
buildactions << :archive unless config[:skip_archive] | ||
|
||
actions | ||
buildactions | ||
end | ||
|
||
def suffix | ||
suffix = [] | ||
suffix << "CODE_SIGN_IDENTITY=#{Gym.config[:codesigning_identity].shellescape}" if Gym.config[:codesigning_identity] | ||
suffix | ||
def setting | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. renamed to match more closely with
|
||
setting = [] | ||
setting << "CODE_SIGN_IDENTITY=#{Gym.config[:codesigning_identity].shellescape}" if Gym.config[:codesigning_identity] | ||
setting | ||
end | ||
|
||
def pipe | ||
pipe = [] | ||
pipe << "| tee #{xcodebuild_log_path.shellescape}" | ||
pipe << "| grep .[0-9]ms | grep -v ^0.[0-9]ms | sort -nr > culprits.txt" if Gym.config[:analyze_build_time] | ||
unless Gym.config[:disable_xcpretty] | ||
formatter = Gym.config[:xcpretty_formatter] | ||
pipe << "| xcpretty" | ||
|
@@ -89,10 +88,15 @@ def pipe | |
end | ||
end | ||
pipe << "> /dev/null" if Gym.config[:suppress_xcode_output] | ||
|
||
pipe | ||
end | ||
|
||
def post_build | ||
commands = [] | ||
commands << %{grep -E '^[0-9.]+ms' #{xcodebuild_log_path.shellescape} | grep -vE '^0\.[0-9]' | sort -nr > culprits.txt} if Gym.config[:analyze_build_time] | ||
commands | ||
end | ||
|
||
def xcodebuild_log_path | ||
file_name = "#{Gym.project.app_name}-#{Gym.config[:scheme]}.log" | ||
containing = File.expand_path(Gym.config[:buildlog_path]) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a good enough place to me 😊 |
||
end | ||
|
||
# Post-processing of build_app | ||
def post_build_app | ||
command = BuildCommandGenerator.post_build | ||
print_command(command, "Generated Post-Build Command") if FastlaneCore::Globals.verbose? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @allewun I did just catch one bug there 😊 Things go 💥 if the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch! I added a guard here. |
||
FastlaneCore::CommandExecutor.execute(command: command, | ||
print_all: true, | ||
print_command: !Gym.config[:silent], | ||
error: proc do |output| | ||
ErrorHandler.handle_build_error(output) | ||
end) | ||
end | ||
|
||
# Makes sure the archive is there and valid | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -197,9 +197,11 @@ | |
end | ||
|
||
describe "Analyze Build Time Example" do | ||
it "uses the correct build command with the example project", requires_xcodebuild: true do | ||
log_path = File.expand_path("#{FastlaneCore::Helper.buildlog_path}/gym/ExampleProductName-Example.log") | ||
before do | ||
@log_path = File.expand_path("#{FastlaneCore::Helper.buildlog_path}/gym/ExampleProductName-Example.log") | ||
end | ||
|
||
it "uses the correct build command with the example project when option is enabled", requires_xcodebuild: true do | ||
options = { project: "./gym/examples/standard/Example.xcodeproj", analyze_build_time: true, scheme: 'Example' } | ||
Gym.config = FastlaneCore::Configuration.create(Gym::Options.available_options, options) | ||
|
||
|
@@ -213,10 +215,35 @@ | |
"-archivePath #{Gym::BuildCommandGenerator.archive_path.shellescape}", | ||
"OTHER_SWIFT_FLAGS=\"-Xfrontend -debug-time-function-bodies\"", | ||
:archive, | ||
"| tee #{log_path.shellescape}", | ||
"| grep .[0-9]ms | grep -v ^0.[0-9]ms | sort -nr > culprits.txt", | ||
"| tee #{@log_path.shellescape}", | ||
"| xcpretty" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a duplicate since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the git diff is misleading here. The I added another test case, which pushed the old There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My bad, that was in a spec 😝 You good 👍 |
||
]) | ||
|
||
result = Gym::BuildCommandGenerator.post_build | ||
expect(result).to eq([ | ||
"grep -E '^[0-9.]+ms' #{@log_path.shellescape} | grep -vE '^0\.[0-9]' | sort -nr > culprits.txt" | ||
]) | ||
end | ||
|
||
it "uses the correct build command with the example project when option is disabled", requires_xcodebuild: true do | ||
options = { project: "./gym/examples/standard/Example.xcodeproj", analyze_build_time: false, scheme: 'Example' } | ||
Gym.config = FastlaneCore::Configuration.create(Gym::Options.available_options, options) | ||
|
||
result = Gym::BuildCommandGenerator.generate | ||
expect(result).to eq([ | ||
"set -o pipefail &&", | ||
"xcodebuild", | ||
"-scheme Example", | ||
"-project ./gym/examples/standard/Example.xcodeproj", | ||
"-destination 'generic/platform=iOS'", | ||
"-archivePath #{Gym::BuildCommandGenerator.archive_path.shellescape}", | ||
:archive, | ||
"| tee #{@log_path.shellescape}", | ||
"| xcpretty" | ||
]) | ||
|
||
result = Gym::BuildCommandGenerator.post_build | ||
expect(result).to eq([]) | ||
end | ||
end | ||
end | ||
|
There was a problem hiding this comment.
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: