From 188d5ae0454fea3cf03babb746ac66ca27069534 Mon Sep 17 00:00:00 2001 From: Alex Chase Date: Thu, 10 Sep 2020 10:38:21 -0700 Subject: [PATCH 1/3] Add xcactivitylog path --- lib/xcprofiler/plugin.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/xcprofiler/plugin.rb b/lib/xcprofiler/plugin.rb index 73c6039..5a0b0f3 100644 --- a/lib/xcprofiler/plugin.rb +++ b/lib/xcprofiler/plugin.rb @@ -48,9 +48,16 @@ class DangerXcprofiler < Plugin # Search the latest .xcactivitylog by the passing product_name and profile compilation time # @param [String] product_name Product name for the target project. # @param [String] derived_data_path Path to the directory containing the DerivedData. + # @param [String] xcactivitylog Path to the xcactivitylog to process. # @return [void] - def report(product_name, derived_data_path = nil) - profiler = Xcprofiler::Profiler.by_product_name(product_name, derived_data_path) + def report(product_name, derived_data_path = nil, xcactivitylog = nil) + + if xcactivitylog + profiler = Xcprofiler::Profiler.by_path(xcactivitylog) + else + profiler = Xcprofiler::Profiler.by_product_name(product_name, derived_data_path) + end + profiler.reporters = [ DangerReporter.new(@dangerfile, thresholds, inline_mode, working_dir, ignored_files) ] From 40d1c8862fc03f9f630c988cf2d2af6bc7bec9df Mon Sep 17 00:00:00 2001 From: Alex Chase Date: Thu, 10 Sep 2020 10:52:43 -0700 Subject: [PATCH 2/3] Update paramater name and check file extension --- lib/xcprofiler/plugin.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/xcprofiler/plugin.rb b/lib/xcprofiler/plugin.rb index 5a0b0f3..818a7ba 100644 --- a/lib/xcprofiler/plugin.rb +++ b/lib/xcprofiler/plugin.rb @@ -48,12 +48,12 @@ class DangerXcprofiler < Plugin # Search the latest .xcactivitylog by the passing product_name and profile compilation time # @param [String] product_name Product name for the target project. # @param [String] derived_data_path Path to the directory containing the DerivedData. - # @param [String] xcactivitylog Path to the xcactivitylog to process. + # @param [String] log_path Path to the xcactivitylog to process. # @return [void] - def report(product_name, derived_data_path = nil, xcactivitylog = nil) + def report(product_name, derived_data_path = nil, log_path = nil) - if xcactivitylog - profiler = Xcprofiler::Profiler.by_path(xcactivitylog) + if log_path and log_path.end_with?('.xcactivitylog') + profiler = Xcprofiler::Profiler.by_path(log_path) else profiler = Xcprofiler::Profiler.by_product_name(product_name, derived_data_path) end From 6397d9bd10fef2301140cacd33024322a8ff5483 Mon Sep 17 00:00:00 2001 From: Alex Chase Date: Thu, 10 Sep 2020 11:01:21 -0700 Subject: [PATCH 3/3] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index d49429c..828c70c 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,12 @@ Just add this line to your Dangerfile: xcprofiler.report 'MyApp' ``` +Or specify an xcactivitylog path +```ruby +logDir = Dir[File.join('DerivedData/Logs/Build/', '*.xcactivitylog')].first +xcprofiler.report nil, nil, logDir +``` + If compilation times of each methods are exceeded the thresholds, `danger` adds inline comment to your PR. Default thresholds is 50ms for warning, 100ms for failure.