diff --git a/.gitignore b/.gitignore index f3776ec..3882e93 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ xcuserdata/ *.xcscmblueprint xcuserdata -/fastlane/*.xcresult +/fastlane/xcresult /fastlane/*.xml /vendor diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..ec08ab7 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,35 @@ +inherit_mode: + merge: + - Include + +AllCops: + Exclude: + - 'Carthage/**/*' + - 'Demo/Carthage/**/*' + - 'vendor/**/*' + Include: + - 'fastlane/Pluginfile' + +# this would cause errors with long lanes +Metrics/BlockLength: + Enabled: true + ExcludedMethods: ['platform', 'for_platform'] + +# Lane description and gem lines can be long +Layout/LineLength: + Enabled: true + Max: 100 + IgnoredPatterns: ['^gem', '^(\s+|)desc', '^(\s+|)UI.'] + +# They have not to be snake_case +Naming/FileName: + Exclude: + - '**/Appfile' + - '**/Gemfile' + - '**/Pluginfile' + - '**/Fastfile' + +# Variables have to be as described in fastlane documentation +Style/RedundantInterpolation: + Exclude: + - '**/Appfile' diff --git a/.swiftpm/xcode/xcshareddata/xcschemes/SRGContentProtection.xcscheme b/.swiftpm/xcode/xcshareddata/xcschemes/SRGContentProtection.xcscheme index c78c51d..5a3909a 100644 --- a/.swiftpm/xcode/xcshareddata/xcschemes/SRGContentProtection.xcscheme +++ b/.swiftpm/xcode/xcshareddata/xcschemes/SRGContentProtection.xcscheme @@ -1,6 +1,6 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default + UISceneDelegateClassName + SceneDelegate + + + + diff --git a/Demo/Resources/MediaDemoConfiguration.plist b/Demo/Resources/MediaDemoConfiguration.plist index 5705e63..d77ac77 100644 --- a/Demo/Resources/MediaDemoConfiguration.plist +++ b/Demo/Resources/MediaDemoConfiguration.plist @@ -8,7 +8,7 @@ name Unprotected Akamai HLS stream url - https://rtsvodww-vh.akamaihd.net/i/genhi/2018/genhi_20180126_full_f_1067247-,301k,101k,701k,1201k,2001k,fra-ad,.mp4.csmil/master.m3u8 + https://rts-vod-amd.akamaized.net/ww/hls/10080791/545cbc27-0798-3d5e-ae1b-1aba03c9a5b5/master.m3u8 name @@ -20,7 +20,7 @@ name FairPlay-protected HLS live stream url - https://rtsun-euwe.akamaized.net/5f6cc644-70fa-4adf-9f94-b673f9fe486f/rts1.ism/manifest(format=m3u8-aapl,encryption=cbcs-aapl,filter=nodvr) + https://rtsun-euwe.akamaized.net/31b0cff3-6652-4359-948c-9aa9063a7e9c/rts1.ism/manifest(format=m3u8-aapl,encryption=cbcs-aapl) certificateUrl https://srg.live.ott.irdeto.com/licenseServer/streaming/v1/SRG/getcertificate?applicationId=live diff --git a/Demo/SRGContentProtection-demo.xcodeproj/project.pbxproj b/Demo/SRGContentProtection-demo.xcodeproj/project.pbxproj index eb5556b..c0ad1b0 100644 --- a/Demo/SRGContentProtection-demo.xcodeproj/project.pbxproj +++ b/Demo/SRGContentProtection-demo.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 08E2AF6423108D8F00DCCE74 /* MediaDemoConfiguration.plist in Resources */ = {isa = PBXBuildFile; fileRef = 08E2AF6323108D8F00DCCE74 /* MediaDemoConfiguration.plist */; }; 08E2AF6923108EBA00DCCE74 /* Media.m in Sources */ = {isa = PBXBuildFile; fileRef = 08E2AF6823108EBA00DCCE74 /* Media.m */; }; + 6F28354226E0A30C0079246B /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 6F28354126E0A30C0079246B /* SceneDelegate.m */; }; 6F8A93FB20FDCAA800AA6434 /* LaunchScreen~ios.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6F8A93F020FDCAA800AA6434 /* LaunchScreen~ios.storyboard */; }; 6F8A93FC20FDCAA800AA6434 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6F8A93F120FDCAA800AA6434 /* Images.xcassets */; }; 6F8A93FD20FDCAA800AA6434 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 6F8A93F520FDCAA800AA6434 /* main.m */; }; @@ -25,6 +26,8 @@ 08E2AF6723108EBA00DCCE74 /* Media.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Media.h; sourceTree = ""; }; 08E2AF6823108EBA00DCCE74 /* Media.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Media.m; sourceTree = ""; }; 6F0432BC21006E7A002B090A /* SRGNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SRGNetwork.framework; path = Carthage/Build/iOS/SRGNetwork.framework; sourceTree = ""; }; + 6F28354026E0A30C0079246B /* SceneDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SceneDelegate.h; sourceTree = ""; }; + 6F28354126E0A30C0079246B /* SceneDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SceneDelegate.m; sourceTree = ""; }; 6F8A93D820FDCA0800AA6434 /* SRGContentProtection-demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "SRGContentProtection-demo.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 6F8A93F020FDCAA800AA6434 /* LaunchScreen~ios.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = "LaunchScreen~ios.storyboard"; sourceTree = ""; }; 6F8A93F120FDCAA800AA6434 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; @@ -107,6 +110,8 @@ 6F8A93F420FDCAA800AA6434 /* AppDelegate.h */, 6F8A93F620FDCAA800AA6434 /* AppDelegate.m */, 6F8A93F520FDCAA800AA6434 /* main.m */, + 6F28354026E0A30C0079246B /* SceneDelegate.h */, + 6F28354126E0A30C0079246B /* SceneDelegate.m */, ); path = Application; sourceTree = ""; @@ -161,7 +166,7 @@ 6F0EB52820FC7F58009C02CF /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1200; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = "SRG SSR"; TargetAttributes = { 6F8A93D720FDCA0800AA6434 = { @@ -211,6 +216,7 @@ files = ( 6F8A93FE20FDCAA800AA6434 /* AppDelegate.m in Sources */, 6F8A93FD20FDCAA800AA6434 /* main.m in Sources */, + 6F28354226E0A30C0079246B /* SceneDelegate.m in Sources */, 08E2AF6923108EBA00DCCE74 /* Media.m in Sources */, 6F8A93FF20FDCAA800AA6434 /* DemosViewController.m in Sources */, ); diff --git a/Demo/SRGContentProtection-demo.xcodeproj/xcshareddata/xcschemes/SRGContentProtection-demo.xcscheme b/Demo/SRGContentProtection-demo.xcodeproj/xcshareddata/xcschemes/SRGContentProtection-demo.xcscheme index da2ca08..2aee805 100644 --- a/Demo/SRGContentProtection-demo.xcodeproj/xcshareddata/xcschemes/SRGContentProtection-demo.xcscheme +++ b/Demo/SRGContentProtection-demo.xcodeproj/xcshareddata/xcschemes/SRGContentProtection-demo.xcscheme @@ -1,6 +1,6 @@ + +@property (nonatomic) UIWindow *window; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Demo/Sources/Application/SceneDelegate.m b/Demo/Sources/Application/SceneDelegate.m new file mode 100644 index 0000000..109d0d6 --- /dev/null +++ b/Demo/Sources/Application/SceneDelegate.m @@ -0,0 +1,25 @@ +// +// Copyright (c) SRG SSR. All rights reserved. +// +// License information is available from the LICENSE file. +// + +#import "SceneDelegate.h" + +#import "DemosViewController.h" + +@implementation SceneDelegate + +- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions +{ + if ([scene isKindOfClass:UIWindowScene.class]) { + UIWindowScene *windowScene = (UIWindowScene *)scene; + self.window = [[UIWindow alloc] initWithWindowScene:windowScene]; + [self.window makeKeyAndVisible]; + + DemosViewController *demosViewController = [[DemosViewController alloc] init]; + self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:demosViewController]; + } +} + +@end diff --git a/Gemfile b/Gemfile index ea0afbf..5d378ba 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,7 @@ source 'https://rubygems.org' gem 'fastlane' +gem 'xcode-install' plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') eval_gemfile(plugins_path) if File.exist?(plugins_path) diff --git a/Gemfile.lock b/Gemfile.lock index 206ead3..a835d13 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,89 +1,97 @@ -GIT - remote: https://github.com/SRGSSR/trainer - revision: b39b3a996a18d87b8f19ce3e31a607198ce34581 - tag: 0.9.1.1 - specs: - fastlane-plugin-trainer (0.4.1) - trainer (>= 0.7.0) - trainer (0.9.1.1) - fastlane (>= 2.25.0) - plist (>= 3.1.0, < 4.0.0) - GEM remote: https://rubygems.org/ specs: - CFPropertyList (3.0.2) - addressable (2.7.0) + CFPropertyList (3.0.3) + addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) + artifactory (3.0.15) atomos (0.1.3) - aws-eventstream (1.1.0) - aws-partitions (1.298.0) - aws-sdk-core (3.94.0) + aws-eventstream (1.2.0) + aws-partitions (1.502.0) + aws-sdk-core (3.121.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.239.0) aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-kms (1.30.0) - aws-sdk-core (~> 3, >= 3.71.0) + aws-sdk-kms (1.48.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.61.2) - aws-sdk-core (~> 3, >= 3.83.0) + aws-sdk-s3 (1.103.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sdk-kms (~> 1) - aws-sigv4 (~> 1.1) - aws-sigv4 (1.1.2) - aws-eventstream (~> 1.0, >= 1.0.2) - babosa (1.0.3) + aws-sigv4 (~> 1.4) + aws-sigv4 (1.4.0) + aws-eventstream (~> 1, >= 1.0.2) + babosa (1.0.4) claide (1.0.3) colored (1.2) colored2 (3.1.2) - commander-fastlane (4.4.6) - highline (~> 1.7.2) - declarative (0.0.10) - declarative-option (0.1.0) - digest-crc (0.5.1) + commander (4.6.0) + highline (~> 2.0.0) + declarative (0.0.20) + digest-crc (0.6.4) + rake (>= 12.0.0, < 14.0.0) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) - dotenv (2.7.5) - emoji_regex (1.0.1) - excon (0.73.0) - faraday (0.17.3) + dotenv (2.7.6) + emoji_regex (3.2.2) + excon (0.85.0) + faraday (1.7.2) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-httpclient (~> 1.0.1) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.1) + faraday-patron (~> 1.0) + faraday-rack (~> 1.0) multipart-post (>= 1.2, < 3) - faraday-cookie_jar (0.0.6) - faraday (>= 0.7.4) + ruby2_keywords (>= 0.0.4) + faraday-cookie_jar (0.0.7) + faraday (>= 0.8.0) http-cookie (~> 1.0.0) - faraday_middleware (0.13.1) - faraday (>= 0.7.4, < 1.0) - fastimage (2.1.7) - fastlane (2.145.0) + faraday-em_http (1.0.0) + faraday-em_synchrony (1.0.0) + faraday-excon (1.1.0) + faraday-httpclient (1.0.1) + faraday-net_http (1.0.1) + faraday-net_http_persistent (1.2.0) + faraday-patron (1.0.0) + faraday-rack (1.0.0) + faraday_middleware (1.1.0) + faraday (~> 1.0) + fastimage (2.2.5) + fastlane (2.194.0) CFPropertyList (>= 2.3, < 4.0.0) - addressable (>= 2.3, < 3.0.0) + addressable (>= 2.8, < 3.0.0) + artifactory (~> 3.0) aws-sdk-s3 (~> 1.0) - babosa (>= 1.0.2, < 2.0.0) + babosa (>= 1.0.3, < 2.0.0) bundler (>= 1.12.0, < 3.0.0) colored - commander-fastlane (>= 4.4.6, < 5.0.0) + commander (~> 4.6) dotenv (>= 2.1.1, < 3.0.0) - emoji_regex (>= 0.1, < 2.0) + emoji_regex (>= 0.1, < 4.0) excon (>= 0.71.0, < 1.0.0) - faraday (~> 0.17) + faraday (~> 1.0) faraday-cookie_jar (~> 0.0.6) - faraday_middleware (~> 0.13.1) + faraday_middleware (~> 1.0) fastimage (>= 2.1.0, < 3.0.0) gh_inspector (>= 1.1.2, < 2.0.0) - google-api-client (>= 0.29.2, < 0.37.0) - google-cloud-storage (>= 1.15.0, < 2.0.0) - highline (>= 1.7.2, < 2.0.0) + google-apis-androidpublisher_v3 (~> 0.3) + google-apis-playcustomapp_v1 (~> 0.1) + google-cloud-storage (~> 1.31) + highline (~> 2.0) json (< 3.0.0) - jwt (~> 2.1.0) + jwt (>= 2.1.0, < 3) mini_magick (>= 4.9.4, < 5.0.0) - multi_xml (~> 0.5) multipart-post (~> 2.0.0) + naturally (~> 2.2) + optparse (~> 0.1.1) plist (>= 3.1.0, < 4.0.0) - public_suffix (~> 2.0.0) - rubyzip (>= 1.3.0, < 2.0.0) + rubyzip (>= 2.0.0, < 3.0.0) security (= 0.1.3) simctl (~> 1.6.3) - slack-notifier (>= 2.0.0, < 3.0.0) terminal-notifier (>= 2.0.0, < 3.0.0) terminal-table (>= 1.4.5, < 2.0.0) tty-screen (>= 0.6.3, < 1.0.0) @@ -92,93 +100,115 @@ GEM xcodeproj (>= 1.13.0, < 2.0.0) xcpretty (~> 0.3.0) xcpretty-travis-formatter (>= 0.0.3) - fastlane-plugin-xcconfig (2.0.0) + fastlane-plugin-trainer (0.4.1) + trainer (>= 0.7.0) gh_inspector (1.1.3) - google-api-client (0.36.4) + google-apis-androidpublisher_v3 (0.11.0) + google-apis-core (>= 0.4, < 2.a) + google-apis-core (0.4.1) addressable (~> 2.5, >= 2.5.1) - googleauth (~> 0.9) - httpclient (>= 2.8.1, < 3.0) + googleauth (>= 0.16.2, < 2.a) + httpclient (>= 2.8.1, < 3.a) mini_mime (~> 1.0) representable (~> 3.0) - retriable (>= 2.0, < 4.0) - signet (~> 0.12) - google-cloud-core (1.5.0) + retriable (>= 2.0, < 4.a) + rexml + webrick + google-apis-iamcredentials_v1 (0.7.0) + google-apis-core (>= 0.4, < 2.a) + google-apis-playcustomapp_v1 (0.5.0) + google-apis-core (>= 0.4, < 2.a) + google-apis-storage_v1 (0.6.0) + google-apis-core (>= 0.4, < 2.a) + google-cloud-core (1.6.0) google-cloud-env (~> 1.0) google-cloud-errors (~> 1.0) - google-cloud-env (1.3.1) + google-cloud-env (1.5.0) faraday (>= 0.17.3, < 2.0) - google-cloud-errors (1.0.0) - google-cloud-storage (1.26.0) + google-cloud-errors (1.1.0) + google-cloud-storage (1.34.1) addressable (~> 2.5) digest-crc (~> 0.4) - google-api-client (~> 0.33) - google-cloud-core (~> 1.2) - googleauth (~> 0.9) + google-apis-iamcredentials_v1 (~> 0.1) + google-apis-storage_v1 (~> 0.1) + google-cloud-core (~> 1.6) + googleauth (>= 0.16.2, < 2.a) mini_mime (~> 1.0) - googleauth (0.12.0) + googleauth (0.17.1) faraday (>= 0.17.3, < 2.0) jwt (>= 1.4, < 3.0) memoist (~> 0.16) multi_json (~> 1.11) os (>= 0.9, < 2.0) - signet (~> 0.14) - highline (1.7.10) - http-cookie (1.0.3) + signet (~> 0.15) + highline (2.0.3) + http-cookie (1.0.4) domain_name (~> 0.5) httpclient (2.8.3) jmespath (1.4.0) - json (2.3.0) - jwt (2.1.0) + json (2.5.1) + jwt (2.2.3) memoist (0.16.2) - mini_magick (4.10.1) - mini_mime (1.0.2) - multi_json (1.14.1) - multi_xml (0.6.0) + mini_magick (4.11.0) + mini_mime (1.1.1) + multi_json (1.15.0) multipart-post (2.0.0) - nanaimo (0.2.6) - naturally (2.2.0) - os (1.1.0) - plist (3.5.0) - public_suffix (2.0.5) - representable (3.0.4) + nanaimo (0.3.0) + naturally (2.2.1) + optparse (0.1.1) + os (1.1.1) + plist (3.6.0) + public_suffix (4.0.6) + rake (13.0.6) + representable (3.1.1) declarative (< 0.1.0) - declarative-option (< 0.2.0) + trailblazer-option (>= 0.1.1, < 0.2.0) uber (< 0.2.0) retriable (3.1.2) + rexml (3.2.5) rouge (2.0.7) - rubyzip (1.3.0) + ruby2_keywords (0.0.5) + rubyzip (2.3.2) security (0.1.3) - signet (0.14.0) - addressable (~> 2.3) + signet (0.16.0) + addressable (~> 2.8) faraday (>= 0.17.3, < 2.0) jwt (>= 1.5, < 3.0) multi_json (~> 1.10) simctl (1.6.8) CFPropertyList naturally - slack-notifier (2.3.2) terminal-notifier (2.0.0) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) + trailblazer-option (0.1.1) + trainer (0.9.1) + fastlane (>= 2.25.0) + plist (>= 3.1.0, < 4.0.0) tty-cursor (0.7.1) - tty-screen (0.7.1) + tty-screen (0.8.1) tty-spinner (0.9.3) tty-cursor (~> 0.7) uber (0.1.0) unf (0.1.4) unf_ext - unf_ext (0.0.7.7) - unicode-display_width (1.7.0) + unf_ext (0.0.8) + unicode-display_width (1.8.0) + webrick (1.7.0) word_wrap (1.0.0) - xcodeproj (1.16.0) + xcode-install (2.8.0) + claide (>= 0.9.1, < 1.1.0) + fastlane (>= 2.1.0, < 3.0.0) + xcodeproj (1.21.0) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) colored2 (~> 3.1) - nanaimo (~> 0.2.6) + nanaimo (~> 0.3.0) + rexml (~> 3.2.4) xcpretty (0.3.0) rouge (~> 2.0.7) - xcpretty-travis-formatter (1.0.0) + xcpretty-travis-formatter (1.0.1) xcpretty (~> 0.2, >= 0.0.7) PLATFORMS @@ -186,8 +216,8 @@ PLATFORMS DEPENDENCIES fastlane - fastlane-plugin-trainer! - fastlane-plugin-xcconfig + fastlane-plugin-trainer + xcode-install BUNDLED WITH 1.17.2 diff --git a/Package.resolved b/Package.resolved index 08e6bf8..7e08c61 100644 --- a/Package.resolved +++ b/Package.resolved @@ -24,8 +24,8 @@ "repositoryURL": "https://github.com/SRGSSR/srgdiagnostics-apple.git", "state": { "branch": null, - "revision": "5d2ef5c833a5cf6e56762a9c506e73f58ccad5e8", - "version": "3.0.0" + "revision": "9921cec150a83df60fe4cde41ffb9e3209b21e92", + "version": "3.0.2" } }, { @@ -33,8 +33,8 @@ "repositoryURL": "https://github.com/SRGSSR/srglogger-apple.git", "state": { "branch": null, - "revision": "cfc39d1223ed039aeb7df38c6c7570977b22d1aa", - "version": "3.0.0" + "revision": "5840af9ccbbc23a1269ff53feb3832f56ffde1eb", + "version": "3.0.2" } }, { @@ -42,8 +42,8 @@ "repositoryURL": "https://github.com/SRGSSR/srgnetwork-apple.git", "state": { "branch": null, - "revision": "734fe399088b2f846e9e69d48a43118f6a8dc0d2", - "version": "3.0.0" + "revision": "9d79d6649de885876577c28e7b19f24f7ce16399", + "version": "3.0.3" } } ] diff --git a/Package.swift b/Package.swift index 8e5082d..5b892a1 100644 --- a/Package.swift +++ b/Package.swift @@ -3,7 +3,7 @@ import PackageDescription struct ProjectSettings { - static let marketingVersion: String = "3.0.3" + static let marketingVersion: String = "3.0.4" } let package = Package( diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 9f3877d..76cb279 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -16,21 +16,32 @@ default_platform :ios platform :ios do before_all do ensure_git_status_clean - Dir.chdir('..') { sh 'make bootstrap' } + + xcversion(version: '~> 13') end desc 'Run library tests' lane :tests do clean_result_files + clean_derived_data + + Device = Struct.new(:platform, :name) + TestBuild = Struct.new(:scheme, :scheme_suffix, :in_workspace) + + iphone11 = Device.new('iOS', 'iPhone 11') + appletv = Device.new('tvOS', 'Apple TV') + devices = [iphone11, appletv] - override_test_product_names + scheme = swift_package_name + swift_package_tests = TestBuild.new(scheme, '', false) + test_builds = [swift_package_tests] - run_tests_with_devices(['iPhone 11', 'Apple TV']) + # Run all tests on various simulators + srg_run_tests(devices, test_builds) - trainer( - path: './fastlane', - output_directory: './fastlane' - ) + # Produce JUnit files for CI + srg_trainer + override_junit_test_suite_names(test_builds) end after_all do @@ -43,62 +54,92 @@ platform :ios do end end +def swift_package_name + JSON.parse((sh 'swift package dump-package'))['name'] +end + def clean_result_files Dir['*.xml'].each { |file| File.delete(file) } - Dir['*.xcresult'].each { |folder| FileUtils.remove_entry(folder, true) } + FileUtils.remove_entry('xcresult', true) end -# Override test product names to split iOS and tvOS test results -def override_test_product_names - set_xcconfig_value( - path: 'Tests/Tests.xcconfig', - name: 'PRODUCT_NAME[sdk=iphone*]', - value: '$(PROJECT_NAME)-iOS' - ) - set_xcconfig_value( - path: 'Tests/Tests.xcconfig', - name: 'PRODUCT_NAME[sdk=appletv*]', - value: '$(PROJECT_NAME)-tvOS' - ) +def clean_derived_data + Dir.chdir('..') { FileUtils.remove_entry(srg_xcodebuild_derived_data_path, true) } end -def run_tests_with_devices(devices) +def srg_run_tests(devices, test_builds) devices.each do |device| - srg_scan(device) - copy_last_xcresult + test_builds.each do |test_build| + begin + srg_xcodebuild(device, test_build) + rescue StandardError => e + raise e unless e.message.include? '** TEST FAILED **' + + UI.important('One or more tests failed on ' + device.platform + ' (' + srg_xcodebuild_scheme(test_build) + '). ⚠️') + end + end end - check_xcresult_count(devices) end -def srg_scan(device) - scan( - device: device, - output_types: '', - output_style: FastlaneCore::Env.truthy?('TRAVIS') ? 'raw' : 'standard', - fail_build: false, - clean: true +def srg_xcodebuild(device, test_build) + xcodebuild( + test: true, + workspace: srg_xcodebuild_workspace(test_build), + scheme: srg_xcodebuild_scheme(test_build), + destination: srg_xcodebuild_destination(device), + result_bundle_path: srg_xcodebuild_result_bundle_path(device, test_build), + derivedDataPath: srg_xcodebuild_derived_data_path ) end -def xcresults_path - derived_data_path = lane_context[SharedValues::SCAN_DERIVED_DATA_PATH] - derived_data_path + '/Logs/Test/' +def srg_xcodebuild_workspace(test_build) + test_build.in_workspace ? 'Tests/' + srg_xcodebuild_scheme(test_build) + '.xcworkspace' : nil end -def copy_last_xcresult - file = nil - Dir.chdir(xcresults_path) do - # max == sort.last - file = Dir['*.xcresult'].max - end - file_name = File.basename(file) - FileUtils.copy_entry(xcresults_path + file_name, file_name) +def srg_xcodebuild_scheme(test_build) + test_build.scheme + test_build.scheme_suffix end -def check_xcresult_count(devices) - return unless Dir['*.xcresult'].count != devices.count +def srg_xcodebuild_destination(device) + 'platform=' + device.platform + ' Simulator,name=' + device.name +end + +def srg_xcodebuild_result_bundle_path(device, test_build) + result_bundle_folder_path + test_build.scheme + '-' + device.platform +end + +def srg_xcodebuild_derived_data_path + '.build/DerivedData' +end + +# Convert xcresults to JUnit files +def srg_trainer + trainer( + path: result_bundle_folder_path, + output_directory: './fastlane', + fail_build: false + ) +end + +def result_bundle_folder_path + './fastlane/xcresult/' +end + +# Override JUnit test suite names to split iOS and tvOS test results +def override_junit_test_suite_names(test_builds) + test_builds.each do |test_build| + Dir[test_build.scheme + '-*.xml'].each do |file_name| + override_junit_test_suite_name(file_name) + end + end +end - UI.user_error!('Whoops, unexpected xcresult file count.') +def override_junit_test_suite_name(file_name) + platform = file_name.split('.').first.split('-').last + file = File.open(file_name, 'r') + xml = file.read.gsub('Tests" tests="', '-' + platform + '" tests="') + xml = xml.gsub('-tests" tests="', '-' + platform + '" tests="') + File.open(file_name, 'w') { |f| f.write(xml) } end # More information about multiple platforms in fastlane: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md diff --git a/fastlane/Pluginfile b/fastlane/Pluginfile index ac2f64b..72dfbbd 100644 --- a/fastlane/Pluginfile +++ b/fastlane/Pluginfile @@ -4,5 +4,4 @@ # # Ensure this file is checked in to source control! -gem 'fastlane-plugin-trainer', git: 'https://github.com/SRGSSR/trainer', tag: '0.9.1.1' -gem 'fastlane-plugin-xcconfig' +gem 'fastlane-plugin-trainer' diff --git a/fastlane/README.md b/fastlane/README.md index 26e446a..45a7da7 100644 --- a/fastlane/README.md +++ b/fastlane/README.md @@ -12,7 +12,7 @@ Install _fastlane_ using ``` [sudo] gem install fastlane -NV ``` -or alternatively using `brew cask install fastlane` +or alternatively using `brew install fastlane` # Available Actions ## iOS @@ -24,6 +24,6 @@ Run library tests ---- -This README.md is auto-generated and will be re-generated every time [fastlane](https://fastlane.tools) is run. +This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run. More information about fastlane can be found on [fastlane.tools](https://fastlane.tools). The documentation of fastlane can be found on [docs.fastlane.tools](https://docs.fastlane.tools).