Skip to content

Commit

Permalink
Adding Danger xcode_sumary (#1680)
Browse files Browse the repository at this point in the history
* Squash: Adding xcode_summary to see the build logs

* Commenting ignore ld and testing sticky summary

* Putting labels on the test summary

* removing first original character and pass parameters as string.

* handle as string

* fixing sintax error

* Removing \t for test porpuses

* Testing with string

* Fixing ruby issues

* Formatting label right way

* Removing stick summary

* New line after config

* Double quotes to maintain consistence  in dangerfile
  • Loading branch information
LucianoPAlmeida authored and SD10 committed Jun 23, 2018
1 parent edaabb3 commit 465c4c3
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 17 deletions.
39 changes: 37 additions & 2 deletions Dangerfile
Expand Up @@ -65,10 +65,10 @@ end

if (cartfile_updated && !cartfile_resolved_updated)
warn("The `Cartfile` was updated, but `Cartfile.resolved` was not. Did you forget to update `Cartfile.resolved`?" )

end
if (package_updated && !package_resolved_updated)
warn("The `Package.swift` was updated, but `Package.resolved` was not. Did you forget to update `Package.resolved`?" )

end
# Warn when library files has been updated but not tests.
tests_updated = !git.modified_files.grep(/Tests/).empty?
if has_app_changes && !tests_updated
Expand All @@ -77,3 +77,38 @@ end

# Run SwiftLint
swiftlint.lint_files

# Xcode summary
def config_xcode_summary()
xcode_summary.ignored_results { |result|
result.message.start_with?("ld") # Ignore ld_warnings
}
end

def summary(platform:)
xcode_summary.report "xcodebuild-#{platform}.json"
end

def label_tests_summary(label:, platform:)
file_name = "xcodebuild-#{platform}.json"
json = File.read(file_name)
data = JSON.parse(json)
data["tests_summary_messages"].each { |message|
if !message.empty?
message.insert(1, " " + label + ":")
end
}
File.open(file_name,"w") do |f|
f.puts JSON.pretty_generate(data)
end
end

config_xcode_summary()

label_tests_summary(label: "iOS", platform: "ios")
label_tests_summary(label: "tvOS", platform: "tvos")
label_tests_summary(label: "macOS", platform: "macos")

summary(platform: "ios")
summary(platform: "tvos")
summary(platform: "macos")
2 changes: 2 additions & 0 deletions Gemfile
Expand Up @@ -8,3 +8,5 @@ gem 'octokit', '~> 4.3'

gem 'danger'
gem 'danger-swiftlint'
gem 'danger-xcode_summary'
gem 'xcpretty-json-formatter'
22 changes: 15 additions & 7 deletions Gemfile.lock
Expand Up @@ -52,7 +52,7 @@ GEM
concurrent-ruby (1.0.5)
cork (0.3.0)
colored2 (~> 3.1)
danger (5.5.10)
danger (5.6.2)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored2 (~> 3.1)
Expand All @@ -64,30 +64,34 @@ GEM
no_proxy_fix
octokit (~> 4.7)
terminal-table (~> 1)
danger-plugin-api (1.0.0)
danger (> 2.0)
danger-swiftlint (0.13.1)
danger
rake (> 10)
thor (~> 0.19)
danger-xcode_summary (0.5.0)
danger-plugin-api (~> 1.0)
escape (0.0.4)
faraday (0.14.0)
faraday (0.15.2)
multipart-post (>= 1.2, < 3)
faraday-http-cache (1.3.1)
faraday (~> 0.8)
fourflusher (2.0.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.2)
git (1.3.0)
git (1.4.0)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
kramdown (1.16.2)
kramdown (1.17.0)
minitest (5.11.3)
molinillo (0.6.4)
multipart-post (2.0.0)
nanaimo (0.2.3)
nap (1.1.0)
netrc (0.11.0)
no_proxy_fix (0.1.2)
octokit (4.8.0)
octokit (4.9.0)
sawyer (~> 0.8.0, >= 0.5.3)
open4 (1.3.4)
public_suffix (3.0.2)
Expand All @@ -103,7 +107,7 @@ GEM
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
unicode-display_width (1.3.0)
unicode-display_width (1.4.0)
xcodeproj (1.5.6)
CFPropertyList (~> 2.3.3)
atomos (~> 0.1.2)
Expand All @@ -112,6 +116,8 @@ GEM
nanaimo (~> 0.2.3)
xcpretty (0.2.8)
rouge (~> 2.0.7)
xcpretty-json-formatter (0.1.0)
xcpretty (~> 0.2, >= 0.0.7)

PLATFORMS
ruby
Expand All @@ -120,9 +126,11 @@ DEPENDENCIES
cocoapods
danger
danger-swiftlint
danger-xcode_summary
octokit (~> 4.3)
rake
xcpretty
xcpretty-json-formatter

BUNDLED WITH
1.16.0
1.16.2
6 changes: 4 additions & 2 deletions Moya.xcodeproj/project.pbxproj
Expand Up @@ -29,8 +29,8 @@
149749431F8923EC00FA4900 /* AnyEncodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 149749421F8923EC00FA4900 /* AnyEncodable.swift */; };
149749451F892E2F00FA4900 /* URLRequest+Encoding.swift in Sources */ = {isa = PBXBuildFile; fileRef = 149749441F892E2F00FA4900 /* URLRequest+Encoding.swift */; };
15D3A2BD1223B59E2BBE09F0 /* MoyaError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2D47F3DC51C28D950491FAAB /* MoyaError.swift */; };
1F8AA0BC1FE0630300C9D7B6 /* ValidationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F8AA0BB1FE0630300C9D7B6 /* ValidationType.swift */; };
1F24393320125F8200C9D813 /* EndpointClosureSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F24393220125F8200C9D813 /* EndpointClosureSpec.swift */; };
1F8AA0BC1FE0630300C9D7B6 /* ValidationType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F8AA0BB1FE0630300C9D7B6 /* ValidationType.swift */; };
1FD44D9E21CEA6B6221807EF /* NetworkLoggerPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4553E5591EE96535C5310C02 /* NetworkLoggerPlugin.swift */; };
2ADDFC96D7F7912333534C46 /* SignalProducer+Response.swift in Sources */ = {isa = PBXBuildFile; fileRef = 269C64D1ABED61A91DD873D3 /* SignalProducer+Response.swift */; };
2C7132B56A7B129E12BAACAC /* EndpointSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = E825A32256FC030B8BA2684D /* EndpointSpec.swift */; };
Expand Down Expand Up @@ -150,8 +150,8 @@
149749421F8923EC00FA4900 /* AnyEncodable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyEncodable.swift; sourceTree = "<group>"; };
149749441F892E2F00FA4900 /* URLRequest+Encoding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URLRequest+Encoding.swift"; sourceTree = "<group>"; };
14FB7A3E1F3E089900308949 /* Single+Response.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Single+Response.swift"; sourceTree = "<group>"; };
1F8AA0BB1FE0630300C9D7B6 /* ValidationType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValidationType.swift; sourceTree = "<group>"; };
1F24393220125F8200C9D813 /* EndpointClosureSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EndpointClosureSpec.swift; sourceTree = "<group>"; };
1F8AA0BB1FE0630300C9D7B6 /* ValidationType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ValidationType.swift; sourceTree = "<group>"; };
225C397C03E17F7DFBCA2848 /* MoyaProvider+Internal.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = "MoyaProvider+Internal.swift"; sourceTree = "<group>"; };
269C64D1ABED61A91DD873D3 /* SignalProducer+Response.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = "SignalProducer+Response.swift"; sourceTree = "<group>"; };
2AD20F6A819D899E3278E903 /* NetworkActivityPlugin.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = NetworkActivityPlugin.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1087,6 +1087,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
Expand Down Expand Up @@ -1398,6 +1399,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
Expand Down
14 changes: 8 additions & 6 deletions Rakefile
Expand Up @@ -73,13 +73,15 @@ def open_simulator_and_sleep(platform)
sh "xcrun instruments -w '#{device_names[platform]} (#{device_os[platform]})' || sleep 15"
end

def xcodebuild(tasks, platform, xcprety_args: '')
def xcodebuild(tasks, platform, xcprety_args: '', xcode_summary: false)
sdk = sdks[platform]
scheme = schemes[platform]
destination = devices[platform]

open_simulator_and_sleep(platform)
safe_sh "set -o pipefail && xcodebuild -project '#{moya_project}' -scheme '#{scheme}' -configuration '#{configuration}' -sdk #{sdk} -destination '#{destination}' #{tasks} | bundle exec xcpretty -c #{xcprety_args}"
xcpretty_json_output_name = xcode_summary == true ? " XCPRETTY_JSON_FILE_OUTPUT=\"xcodebuild-#{platform}.json\"" : ""
xcpretty_formatter = xcode_summary == true ? " -f `bundle exec xcpretty-json-formatter`" : ""
safe_sh "set -o pipefail && xcodebuild -project '#{moya_project}' -scheme '#{scheme}' -configuration '#{configuration}' -sdk #{sdk} -destination '#{destination}' #{tasks} |#{xcpretty_json_output_name} bundle exec xcpretty -c #{xcprety_args}#{xcpretty_formatter}"
end

def xcodebuild_example(tasks, xcprety_args: '')
Expand Down Expand Up @@ -112,7 +114,7 @@ desc 'Build, then run all tests.'
task :test do
targets.map do |platform|
puts "Testing on #{platform}."
xcodebuild 'build test', platform, xcprety_args: '--test'
xcodebuild 'build test', platform, xcprety_args: '--test', xcode_summary: true
next unless platform == :mac
sh "killall Simulator"
end
Expand All @@ -122,18 +124,18 @@ desc 'Individual test tasks.'
namespace :test do
desc 'Test on iOS.'
task :ios do
xcodebuild 'build test', :ios, xcprety_args: '--test'
xcodebuild 'build test', :ios, xcprety_args: '--test', xcode_summary: true
sh "killall Simulator"
end

desc 'Test on macOS.'
task :macos do
xcodebuild 'build test', :macos, xcprety_args: '--test'
xcodebuild 'build test', :macos, xcprety_args: '--test', xcode_summary: true
end

desc 'Test on tvOS.'
task :tvos do
xcodebuild 'build test', :tvos, xcprety_args: '--test'
xcodebuild 'build test', :tvos, xcprety_args: '--test', xcode_summary: true
sh "killall Simulator"
end

Expand Down

0 comments on commit 465c4c3

Please sign in to comment.