From 3f8ec5b4537bb4e092002cd71936ff9109df38db Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Thu, 27 Jan 2022 20:45:28 +0100 Subject: [PATCH 01/20] WIP --- .github/workflows/ci.yaml | 2 + .gitignore | 6 +- Rakefile | 104 ++++ .../cocoapods-xcremotecache/command/hooks.rb | 2 +- .../project.pbxproj | 477 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../XCRemoteCacheSample/AppDelegate.swift | 48 ++ .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 98 ++++ .../Assets.xcassets/Contents.json | 6 + .../Base.lproj/LaunchScreen.storyboard | 25 + .../Base.lproj/Main.storyboard | 24 + .../XCRemoteCacheSample/Info.plist | 25 + .../XCRemoteCacheSample/SceneDelegate.swift | 64 +++ .../XCRemoteCacheSample/ViewController.swift | 31 ++ e2eTests/tests/default.Podfile | 8 + e2eTests/tests/multiplePods.Podfile | 11 + 18 files changed, 955 insertions(+), 2 deletions(-) create mode 100644 e2eTests/XCRemoteCacheSample/XCRemoteCacheSample.xcodeproj/project.pbxproj create mode 100644 e2eTests/XCRemoteCacheSample/XCRemoteCacheSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 e2eTests/XCRemoteCacheSample/XCRemoteCacheSample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/AppDelegate.swift create mode 100644 e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Assets.xcassets/Contents.json create mode 100644 e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Base.lproj/LaunchScreen.storyboard create mode 100644 e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Base.lproj/Main.storyboard create mode 100644 e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Info.plist create mode 100644 e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/SceneDelegate.swift create mode 100644 e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/ViewController.swift create mode 100644 e2eTests/tests/default.Podfile create mode 100644 e2eTests/tests/multiplePods.Podfile diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 49dffdb..5e3328a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,3 +23,5 @@ jobs: run: rake build[release] - name: Test run: rake test + - name: E2ETests + run: rake e2e diff --git a/.gitignore b/.gitignore index 27a6e4d..3ed07b4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,13 @@ .DS_Store /.build /Packages -/*.xcodeproj +*.xcodeproj/ +*.xcworkspace/ DerivedData /.swiftpm/ releases tmp/ .idea/ +xcuserdata +*.gem +Pods/ diff --git a/Rakefile b/Rakefile index 2563fe2..3051bd3 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,5 @@ # encoding: utf-8 +require 'json' ################################ # Rake configuration @@ -77,6 +78,109 @@ task :test do spm_test() end +desc 'run E2E tests with CocoaPods plugin' +task :e2e => [:build, :e2e_only] + +desc 'run E2E tests without building the XCRemoteCache binary' +task :e2e_only do + # Build a plugin + cocoapods_dir = 'cocoapods-plugin' + Dir.chdir(cocoapods_dir) do + gemspec_path = "cocoapods-xcremotecache.gemspec" + gemfile_path = "cocoapods-xcremotecache.gem" + system("gem build #{gemspec_path} -o #{gemfile_path}") + system("gem install #{gemfile_path}") + end + + # Build a docker image + system('docker build -t xcremotecache-demo-server backend-example') + current_branch = `git rev-parse --abbrev-ref HEAD`.chomp + producer_configuration = %{xcremotecache({ + 'cache_addresses' => ['http://localhost:8080/cache/pods'], + 'primary_repo' => '.', + 'primary_branch' => '#{current_branch}', + 'mode' => 'producer', + 'final_target' => 'XCRemoteCacheSample', + 'artifact_maximum_age' => 0 + })} + consumer_configuration = %{xcremotecache({ + 'cache_addresses' => ['http://localhost:8080/cache/pods'], + 'primary_repo' => '.', + 'primary_branch' => '#{current_branch}', + 'mode' => 'consumer', + 'final_target' => 'XCRemoteCacheSample', + 'artifact_maximum_age' => 0 + })} + # Configure remote + system('git remote add self . ; git fetch self') + + log_name = "xcodebuild.log" + # initalize Pods + for podfile_path in Dir.glob('e2eTests/**/*.Podfile') + p "****** Scenario: #{podfile_path}" + # Revert any local changes + system('git clean -xdf e2eTests/XCRemoteCacheSample') + # Link prebuild binaries to the Project + system('ln -s $(pwd)/releases e2eTests/XCRemoteCacheSample/XCRC') + # Run a docker server + system('docker run -it --rm -d -p 8080:8080 --name xcremotecache xcremotecache-demo-server') + + # Create producer Podfile + File.open('e2eTests/XCRemoteCacheSample/Podfile', 'w') do |f| + # Copy podfile + File.foreach(podfile_path) { |line| f.puts line } + + f.write(producer_configuration) + end + + Dir.chdir('e2eTests/XCRemoteCacheSample') do + system('pod install') + p "Building producer ..." + system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build > #{log_name}") + + # reset stats + system('XCRC/xcprepare stats --reset --format json') + # clean DerivedData + system('rm -rf ./build') + end + + + # Create consumer Podfile + File.open('e2eTests/XCRemoteCacheSample/Podfile', 'w') do |f| + # Copy podfile + File.foreach(podfile_path) { |line| f.puts line; p } + + f.write(consumer_configuration) + end + + Dir.chdir('e2eTests/XCRemoteCacheSample') do + system('pod install') + p "Building consumer ..." + system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build > #{log_name}") + + # clean DerivedData + system('rm -rf ./build') + + # validate 100% hit rate + stats_json_string = JSON.parse(`XCRC/xcprepare stats --format json`) + misses = stats_json_string.fetch('miss_count', 0) + hits = stats_json_string.fetch('hit_count', 0) + all_targets = misses + hits + raise "Failure: XCRemoteCache is disabled" if all_targets == 0 + hit_rate = hits * 100 / all_targets + raise "Failure: Hit rate is only #{hit_rate}%" if misses != 0 + p "hit rate: #{hit_rate}% (#{hits}/#{all_targets})" + end + + # Kill a docker + system('docker kill xcremotecache') + end + + # Revert remote + system('git origin delete self') +end + + ################################ # Helper functions ################################ diff --git a/cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb b/cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb index 0bcf801..1a287b3 100644 --- a/cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb +++ b/cocoapods-plugin/lib/cocoapods-xcremotecache/command/hooks.rb @@ -375,7 +375,7 @@ module CocoapodsXCRemoteCacheModifier # Always integrate XCRemoteCache to all Pods, in case it will be needed later unless installer_context.pods_project.nil? # Attach XCRemoteCache to Pods targets - installer_context.pods_project.targets.each do |target| + installer_context.pods_project.native_targets.each do |target| next if target.source_build_phase.files_references.empty? next if target.name.start_with?("Pods-") next if target.name.end_with?("Tests") diff --git a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample.xcodeproj/project.pbxproj b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample.xcodeproj/project.pbxproj new file mode 100644 index 0000000..4a122ca --- /dev/null +++ b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample.xcodeproj/project.pbxproj @@ -0,0 +1,477 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 55; + objects = { + +/* Begin PBXBuildFile section */ + 3695D9CC27A3218C007F3792 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3695D9CB27A3218C007F3792 /* AppDelegate.swift */; }; + 3695D9CE27A3218C007F3792 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3695D9CD27A3218C007F3792 /* SceneDelegate.swift */; }; + 3695D9D027A3218C007F3792 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3695D9CF27A3218C007F3792 /* ViewController.swift */; }; + 3695D9D327A3218C007F3792 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3695D9D127A3218C007F3792 /* Main.storyboard */; }; + 3695D9D527A3218D007F3792 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3695D9D427A3218D007F3792 /* Assets.xcassets */; }; + 3695D9D827A3218D007F3792 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3695D9D627A3218D007F3792 /* LaunchScreen.storyboard */; }; + E0A28FC0C12F263A640F955C /* Pods_XCRemoteCacheSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3FD0BAE1387E5E29B6D7E35 /* Pods_XCRemoteCacheSample.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 3695D9C827A3218C007F3792 /* XCRemoteCacheSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = XCRemoteCacheSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 3695D9CB27A3218C007F3792 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 3695D9CD27A3218C007F3792 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; + 3695D9CF27A3218C007F3792 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 3695D9D227A3218C007F3792 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 3695D9D427A3218D007F3792 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 3695D9D727A3218D007F3792 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 3695D9D927A3218D007F3792 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 3EE12A879EBE767C99B0FC32 /* Pods-XCRemoteCacheSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-XCRemoteCacheSample.debug.xcconfig"; path = "Target Support Files/Pods-XCRemoteCacheSample/Pods-XCRemoteCacheSample.debug.xcconfig"; sourceTree = ""; }; + A3FD0BAE1387E5E29B6D7E35 /* Pods_XCRemoteCacheSample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_XCRemoteCacheSample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + C7B900612D1F7BD7CA3DFDC9 /* Pods-XCRemoteCacheSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-XCRemoteCacheSample.release.xcconfig"; path = "Target Support Files/Pods-XCRemoteCacheSample/Pods-XCRemoteCacheSample.release.xcconfig"; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 3695D9C527A3218C007F3792 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + E0A28FC0C12F263A640F955C /* Pods_XCRemoteCacheSample.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 3695D9BF27A3218C007F3792 = { + isa = PBXGroup; + children = ( + 3695D9CA27A3218C007F3792 /* XCRemoteCacheSample */, + 3695D9C927A3218C007F3792 /* Products */, + 4FE2462282E9908CE0357DE3 /* Pods */, + 9736800B94F7D85ED1CA9F7E /* Frameworks */, + ); + sourceTree = ""; + }; + 3695D9C927A3218C007F3792 /* Products */ = { + isa = PBXGroup; + children = ( + 3695D9C827A3218C007F3792 /* XCRemoteCacheSample.app */, + ); + name = Products; + sourceTree = ""; + }; + 3695D9CA27A3218C007F3792 /* XCRemoteCacheSample */ = { + isa = PBXGroup; + children = ( + 3695D9CB27A3218C007F3792 /* AppDelegate.swift */, + 3695D9CD27A3218C007F3792 /* SceneDelegate.swift */, + 3695D9CF27A3218C007F3792 /* ViewController.swift */, + 3695D9D127A3218C007F3792 /* Main.storyboard */, + 3695D9D427A3218D007F3792 /* Assets.xcassets */, + 3695D9D627A3218D007F3792 /* LaunchScreen.storyboard */, + 3695D9D927A3218D007F3792 /* Info.plist */, + ); + path = XCRemoteCacheSample; + sourceTree = ""; + }; + 4FE2462282E9908CE0357DE3 /* Pods */ = { + isa = PBXGroup; + children = ( + 3EE12A879EBE767C99B0FC32 /* Pods-XCRemoteCacheSample.debug.xcconfig */, + C7B900612D1F7BD7CA3DFDC9 /* Pods-XCRemoteCacheSample.release.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; + 9736800B94F7D85ED1CA9F7E /* Frameworks */ = { + isa = PBXGroup; + children = ( + A3FD0BAE1387E5E29B6D7E35 /* Pods_XCRemoteCacheSample.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 3695D9C727A3218C007F3792 /* XCRemoteCacheSample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3695D9DC27A3218D007F3792 /* Build configuration list for PBXNativeTarget "XCRemoteCacheSample" */; + buildPhases = ( + E722BEC0D6AA112B0DC88BA5 /* [CP] Check Pods Manifest.lock */, + 3695D9C427A3218C007F3792 /* Sources */, + 3695D9C527A3218C007F3792 /* Frameworks */, + 3695D9C627A3218C007F3792 /* Resources */, + 181E10D369F1135B2514CC3B /* [CP] Embed Pods Frameworks */, + 785F3A1B596395970C430424 /* [XCRC] Postbuild */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = XCRemoteCacheSample; + productName = XCRemoteCacheSample; + productReference = 3695D9C827A3218C007F3792 /* XCRemoteCacheSample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 3695D9C027A3218C007F3792 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1320; + LastUpgradeCheck = 1320; + TargetAttributes = { + 3695D9C727A3218C007F3792 = { + CreatedOnToolsVersion = 13.2.1; + }; + }; + }; + buildConfigurationList = 3695D9C327A3218C007F3792 /* Build configuration list for PBXProject "XCRemoteCacheSample" */; + compatibilityVersion = "Xcode 13.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 3695D9BF27A3218C007F3792; + productRefGroup = 3695D9C927A3218C007F3792 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 3695D9C727A3218C007F3792 /* XCRemoteCacheSample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 3695D9C627A3218C007F3792 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3695D9D827A3218D007F3792 /* LaunchScreen.storyboard in Resources */, + 3695D9D527A3218D007F3792 /* Assets.xcassets in Resources */, + 3695D9D327A3218C007F3792 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 181E10D369F1135B2514CC3B /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-XCRemoteCacheSample/Pods-XCRemoteCacheSample-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-XCRemoteCacheSample/Pods-XCRemoteCacheSample-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-XCRemoteCacheSample/Pods-XCRemoteCacheSample-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 785F3A1B596395970C430424 /* [XCRC] Postbuild */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + dependencyFile = "$(TARGET_TEMP_DIR)/postbuild.d"; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "$SRCROOT/XCRC/xcpostbuild", + ); + name = "[XCRC] Postbuild"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(TARGET_BUILD_DIR)/$(MODULES_FOLDER_PATH)/$(PRODUCT_MODULE_NAME).swiftmodule/$(XCRC_PLATFORM_PREFERRED_ARCH).swiftmodule.md5", + "$(TARGET_BUILD_DIR)/$(MODULES_FOLDER_PATH)/$(PRODUCT_MODULE_NAME).swiftmodule/$(XCRC_PLATFORM_PREFERRED_ARCH)-$(LLVM_TARGET_TRIPLE_VENDOR)-$(SWIFT_PLATFORM_TARGET_PREFIX)$(LLVM_TARGET_TRIPLE_SUFFIX).swiftmodule.md5", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$SCRIPT_INPUT_FILE_0\""; + }; + E722BEC0D6AA112B0DC88BA5 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-XCRemoteCacheSample-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 3695D9C427A3218C007F3792 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3695D9D027A3218C007F3792 /* ViewController.swift in Sources */, + 3695D9CC27A3218C007F3792 /* AppDelegate.swift in Sources */, + 3695D9CE27A3218C007F3792 /* SceneDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 3695D9D127A3218C007F3792 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 3695D9D227A3218C007F3792 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 3695D9D627A3218D007F3792 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 3695D9D727A3218D007F3792 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 3695D9DA27A3218D007F3792 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.2; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 3695D9DB27A3218D007F3792 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.2; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 3695D9DD27A3218D007F3792 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 3EE12A879EBE767C99B0FC32 /* Pods-XCRemoteCacheSample.debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = XCRemoteCacheSample/Info.plist; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD = "$SRCROOT/XCRC/xcld"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + LIBTOOL = "$SRCROOT/XCRC/xclibtool"; + MARKETING_VERSION = 1.0; + OTHER_CFLAGS = ( + "$(inherited)", + " -fdebug-prefix-map=$(SRCROOT)=$(XCREMOTE_CACHE_FAKE_SRCROOT)", + ); + OTHER_SWIFT_FLAGS = "$(inherited) -debug-prefix-map $(SRCROOT)=$(XCREMOTE_CACHE_FAKE_SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = com.xcremotecache.XCRemoteCacheSample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_EXEC = "$SRCROOT/XCRC/xcswiftc"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + XCRC_PLATFORM_PREFERRED_ARCH = "$(LINK_FILE_LIST_$(CURRENT_VARIANT)_$(PLATFORM_PREFERRED_ARCH):dir:standardizepath:file:default=arm64)"; + XCREMOTE_CACHE_FAKE_SRCROOT = /xxxxxxxxxx; + }; + name = Debug; + }; + 3695D9DE27A3218D007F3792 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = C7B900612D1F7BD7CA3DFDC9 /* Pods-XCRemoteCacheSample.release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = XCRemoteCacheSample/Info.plist; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; + INFOPLIST_KEY_UIMainStoryboardFile = Main; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD = "$SRCROOT/XCRC/xcld"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + LIBTOOL = "$SRCROOT/XCRC/xclibtool"; + MARKETING_VERSION = 1.0; + OTHER_CFLAGS = ( + "$(inherited)", + " -fdebug-prefix-map=$(SRCROOT)=$(XCREMOTE_CACHE_FAKE_SRCROOT)", + ); + OTHER_SWIFT_FLAGS = "$(inherited) -debug-prefix-map $(SRCROOT)=$(XCREMOTE_CACHE_FAKE_SRCROOT)"; + PRODUCT_BUNDLE_IDENTIFIER = com.xcremotecache.XCRemoteCacheSample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_EXEC = "$SRCROOT/XCRC/xcswiftc"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + XCRC_PLATFORM_PREFERRED_ARCH = "$(LINK_FILE_LIST_$(CURRENT_VARIANT)_$(PLATFORM_PREFERRED_ARCH):dir:standardizepath:file:default=arm64)"; + XCREMOTE_CACHE_FAKE_SRCROOT = /xxxxxxxxxx; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 3695D9C327A3218C007F3792 /* Build configuration list for PBXProject "XCRemoteCacheSample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3695D9DA27A3218D007F3792 /* Debug */, + 3695D9DB27A3218D007F3792 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3695D9DC27A3218D007F3792 /* Build configuration list for PBXNativeTarget "XCRemoteCacheSample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3695D9DD27A3218D007F3792 /* Debug */, + 3695D9DE27A3218D007F3792 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 3695D9C027A3218C007F3792 /* Project object */; +} diff --git a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/AppDelegate.swift b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/AppDelegate.swift new file mode 100644 index 0000000..433b8f1 --- /dev/null +++ b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/AppDelegate.swift @@ -0,0 +1,48 @@ +// Copyright (c) 2021 Spotify AB. +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import UIKit + +@main +class AppDelegate: UIResponder, UIApplicationDelegate { + + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + // MARK: UISceneSession Lifecycle + + func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) + } + + func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. + } + + +} + diff --git a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Assets.xcassets/AccentColor.colorset/Contents.json b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Assets.xcassets/AppIcon.appiconset/Contents.json b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..9221b9b --- /dev/null +++ b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Assets.xcassets/Contents.json b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Base.lproj/LaunchScreen.storyboard b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..865e932 --- /dev/null +++ b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Base.lproj/Main.storyboard b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Base.lproj/Main.storyboard new file mode 100644 index 0000000..25a7638 --- /dev/null +++ b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Base.lproj/Main.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Info.plist b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Info.plist new file mode 100644 index 0000000..dd3c9af --- /dev/null +++ b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/Info.plist @@ -0,0 +1,25 @@ + + + + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + $(PRODUCT_MODULE_NAME).SceneDelegate + UISceneStoryboardFile + Main + + + + + + diff --git a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/SceneDelegate.swift b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/SceneDelegate.swift new file mode 100644 index 0000000..bc8ea2c --- /dev/null +++ b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/SceneDelegate.swift @@ -0,0 +1,64 @@ +// Copyright (c) 2021 Spotify AB. +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import UIKit + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). + guard let _ = (scene as? UIWindowScene) else { return } + } + + func sceneDidDisconnect(_ scene: UIScene) { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: UIScene) { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. + } + + func sceneWillResignActive(_ scene: UIScene) { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). + } + + func sceneWillEnterForeground(_ scene: UIScene) { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. + } + + func sceneDidEnterBackground(_ scene: UIScene) { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. + } + + +} + diff --git a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/ViewController.swift b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/ViewController.swift new file mode 100644 index 0000000..3447333 --- /dev/null +++ b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/ViewController.swift @@ -0,0 +1,31 @@ +// Copyright (c) 2021 Spotify AB. +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import UIKit + +class ViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view. + } + + +} + diff --git a/e2eTests/tests/default.Podfile b/e2eTests/tests/default.Podfile new file mode 100644 index 0000000..4814b2d --- /dev/null +++ b/e2eTests/tests/default.Podfile @@ -0,0 +1,8 @@ +plugin 'cocoapods-xcremotecache' + +target 'XCRemoteCacheSample' do + use_frameworks! + + pod 'Firebase/Analytics' + pod 'ReactiveSwift' +end diff --git a/e2eTests/tests/multiplePods.Podfile b/e2eTests/tests/multiplePods.Podfile new file mode 100644 index 0000000..4cd18da --- /dev/null +++ b/e2eTests/tests/multiplePods.Podfile @@ -0,0 +1,11 @@ +plugin 'cocoapods-xcremotecache' + +install! 'cocoapods', :generate_multiple_pod_projects => true + + +target 'XCRemoteCacheSample' do + use_frameworks! + + pod 'Firebase/Analytics' + pod 'ReactiveSwift' +end From d9c2213f508bda4c638d24527f6fcd80414f7396 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Wed, 2 Feb 2022 23:42:47 +0100 Subject: [PATCH 02/20] Log xcodebuild to stdout --- Rakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 3051bd3..0889b11 100644 --- a/Rakefile +++ b/Rakefile @@ -136,7 +136,7 @@ task :e2e_only do Dir.chdir('e2eTests/XCRemoteCacheSample') do system('pod install') p "Building producer ..." - system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build > #{log_name}") + system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build ") # reset stats system('XCRC/xcprepare stats --reset --format json') @@ -156,7 +156,7 @@ task :e2e_only do Dir.chdir('e2eTests/XCRemoteCacheSample') do system('pod install') p "Building consumer ..." - system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build > #{log_name}") + system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build ") # clean DerivedData system('rm -rf ./build') From 2160645f2cea6bf719d9c1574ec550b77b971712 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Wed, 2 Feb 2022 23:45:44 +0100 Subject: [PATCH 03/20] do not build again for e2e --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5e3328a..084822f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,4 +24,4 @@ jobs: - name: Test run: rake test - name: E2ETests - run: rake e2e + run: rake e2e_only From 3f8333c07b9658384f34e9b872044363b1a066a1 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Thu, 3 Feb 2022 17:02:52 +0100 Subject: [PATCH 04/20] print log times --- Rakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 0889b11..56ad916 100644 --- a/Rakefile +++ b/Rakefile @@ -136,7 +136,7 @@ task :e2e_only do Dir.chdir('e2eTests/XCRemoteCacheSample') do system('pod install') p "Building producer ..." - system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build ") + system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build | ts | tee #{log_name}") # reset stats system('XCRC/xcprepare stats --reset --format json') @@ -156,7 +156,7 @@ task :e2e_only do Dir.chdir('e2eTests/XCRemoteCacheSample') do system('pod install') p "Building consumer ..." - system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build ") + system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build | ts | tee #{log_name}") # clean DerivedData system('rm -rf ./build') From 97328144fd2e5b9f6aa459befef9a68c60f184e1 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Thu, 3 Feb 2022 17:40:42 +0100 Subject: [PATCH 05/20] Log remotes --- Rakefile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Rakefile b/Rakefile index 56ad916..14817d0 100644 --- a/Rakefile +++ b/Rakefile @@ -112,8 +112,10 @@ task :e2e_only do 'artifact_maximum_age' => 0 })} # Configure remote - system('git remote add self . ; git fetch self') - + system('git remote -v') + system('git remote add self . && git fetch self') + system('git remote -v') + ts_counterpart = " while IFS= read -r line; do printf '[%s] %s\n' \"$(date '+%Y-%m-%d %H:%M:%S')\" \"$line\"; done" log_name = "xcodebuild.log" # initalize Pods for podfile_path in Dir.glob('e2eTests/**/*.Podfile') @@ -136,7 +138,7 @@ task :e2e_only do Dir.chdir('e2eTests/XCRemoteCacheSample') do system('pod install') p "Building producer ..." - system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build | ts | tee #{log_name}") + system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build | #{ts_counterpart} | tee #{log_name}") # reset stats system('XCRC/xcprepare stats --reset --format json') @@ -156,7 +158,7 @@ task :e2e_only do Dir.chdir('e2eTests/XCRemoteCacheSample') do system('pod install') p "Building consumer ..." - system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build | ts | tee #{log_name}") + system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build | #{ts_counterpart} | tee #{log_name}") # clean DerivedData system('rm -rf ./build') From cde81d852f416ab8619abcf90a68d735f9089641 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Thu, 3 Feb 2022 18:24:05 +0100 Subject: [PATCH 06/20] add a branch --- Rakefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 14817d0..b00b528 100644 --- a/Rakefile +++ b/Rakefile @@ -94,7 +94,7 @@ task :e2e_only do # Build a docker image system('docker build -t xcremotecache-demo-server backend-example') - current_branch = `git rev-parse --abbrev-ref HEAD`.chomp + current_branch = 'e2e-test-branch' producer_configuration = %{xcremotecache({ 'cache_addresses' => ['http://localhost:8080/cache/pods'], 'primary_repo' => '.', @@ -112,6 +112,7 @@ task :e2e_only do 'artifact_maximum_age' => 0 })} # Configure remote + system("git branch -b #{current_branch}") system('git remote -v') system('git remote add self . && git fetch self') system('git remote -v') From 93a60b2b40b406bc11df469444e62413eef658f7 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Thu, 3 Feb 2022 18:52:40 +0100 Subject: [PATCH 07/20] Fix branch typo --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index b00b528..39311ab 100644 --- a/Rakefile +++ b/Rakefile @@ -112,7 +112,7 @@ task :e2e_only do 'artifact_maximum_age' => 0 })} # Configure remote - system("git branch -b #{current_branch}") + system("git checkout -b #{current_branch}") system('git remote -v') system('git remote add self . && git fetch self') system('git remote -v') From d8850b555a734eb959b97b25d1ecfee668631277 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Thu, 3 Feb 2022 19:11:05 +0100 Subject: [PATCH 08/20] Install docker --- .github/workflows/ci.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 084822f..cc93c88 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,6 +15,10 @@ jobs: env: XCODE_VERSION: ${{ '13.1' }} steps: + - name: Install docker + run: | + brew install docker-machine docker + sudo docker –version - name: Select Xcode run: "sudo xcode-select -s /Applications/Xcode_$XCODE_VERSION.app" - name: Checkout From 49be11184e33c102824066dc78b11105c69f8964 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Thu, 3 Feb 2022 19:29:41 +0100 Subject: [PATCH 09/20] Fix dash in docker installer --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index cc93c88..7121c8d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -18,7 +18,7 @@ jobs: - name: Install docker run: | brew install docker-machine docker - sudo docker –version + sudo docker --version - name: Select Xcode run: "sudo xcode-select -s /Applications/Xcode_$XCODE_VERSION.app" - name: Checkout From e54ce770e7c548f650559b3360dd8151625e2b5f Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Thu, 3 Feb 2022 19:39:06 +0100 Subject: [PATCH 10/20] Start docker --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7121c8d..60b463c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,6 +19,8 @@ jobs: run: | brew install docker-machine docker sudo docker --version + docker-machine create --driver virtualbox default + docker-machine env default - name: Select Xcode run: "sudo xcode-select -s /Applications/Xcode_$XCODE_VERSION.app" - name: Checkout From 408698f1e870f8555b1bf6194964d04bd30f4566 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Thu, 3 Feb 2022 20:10:51 +0100 Subject: [PATCH 11/20] Switch to nginx --- .github/workflows/ci.yaml | 6 ----- Rakefile | 15 ++++++++++--- e2eTests/nginx/nginx.conf | 47 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 e2eTests/nginx/nginx.conf diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 60b463c..084822f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,12 +15,6 @@ jobs: env: XCODE_VERSION: ${{ '13.1' }} steps: - - name: Install docker - run: | - brew install docker-machine docker - sudo docker --version - docker-machine create --driver virtualbox default - docker-machine env default - name: Select Xcode run: "sudo xcode-select -s /Applications/Xcode_$XCODE_VERSION.app" - name: Checkout diff --git a/Rakefile b/Rakefile index 39311ab..9d496b0 100644 --- a/Rakefile +++ b/Rakefile @@ -93,7 +93,10 @@ task :e2e_only do end # Build a docker image - system('docker build -t xcremotecache-demo-server backend-example') + # system('docker build -t xcremotecache-demo-server backend-example') + # Start an nginx server + system('nginx -c $PWD/e2eTests/nginx/nginx.conf') + current_branch = 'e2e-test-branch' producer_configuration = %{xcremotecache({ 'cache_addresses' => ['http://localhost:8080/cache/pods'], @@ -126,7 +129,8 @@ task :e2e_only do # Link prebuild binaries to the Project system('ln -s $(pwd)/releases e2eTests/XCRemoteCacheSample/XCRC') # Run a docker server - system('docker run -it --rm -d -p 8080:8080 --name xcremotecache xcremotecache-demo-server') + # system('docker run -it --rm -d -p 8080:8080 --name xcremotecache xcremotecache-demo-server') + # Create producer Podfile File.open('e2eTests/XCRemoteCacheSample/Podfile', 'w') do |f| @@ -176,11 +180,16 @@ task :e2e_only do end # Kill a docker - system('docker kill xcremotecache') + # system('docker kill xcremotecache') + # Destroy cache + system('rm -rf /tmp/cache') end # Revert remote system('git origin delete self') + + # Stop nginx + system('nginx -s stop') end diff --git a/e2eTests/nginx/nginx.conf b/e2eTests/nginx/nginx.conf new file mode 100644 index 0000000..97c7f2f --- /dev/null +++ b/e2eTests/nginx/nginx.conf @@ -0,0 +1,47 @@ + +#user nobody; +worker_processes 1; + +events { + worker_connections 1024; +} + + +http { + default_type application/octet-stream; + + server { + listen 8080; + server_name localhost; + + #charset koi8-r; + + #access_log logs/host.access.log main; + + location / { + root html; + index index.html index.htm; + } + + location /cache/ { + # The path to the directory where nginx should store the cache contents. + root /tmp/cache; + # Allow PUT + dav_methods PUT; + # Allow nginx to create the /ac and /cas subdirectories. + create_full_put_path on; + # The maximum size of a single file. + client_max_body_size 1G; + allow all; + } + sendfile on; + + #keepalive_timeout 0; + keepalive_timeout 65; + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + } +} From 46a99bbe327f7537d3823bee5e62563eab21bf19 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Thu, 3 Feb 2022 20:32:45 +0100 Subject: [PATCH 12/20] Cleanup --- Rakefile | 20 ++++++-------------- e2eTests/nginx/nginx.conf | 10 +++------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/Rakefile b/Rakefile index 9d496b0..5346087 100644 --- a/Rakefile +++ b/Rakefile @@ -92,9 +92,7 @@ task :e2e_only do system("gem install #{gemfile_path}") end - # Build a docker image - # system('docker build -t xcremotecache-demo-server backend-example') - # Start an nginx server + # Start nginx server system('nginx -c $PWD/e2eTests/nginx/nginx.conf') current_branch = 'e2e-test-branch' @@ -116,10 +114,8 @@ task :e2e_only do })} # Configure remote system("git checkout -b #{current_branch}") - system('git remote -v') system('git remote add self . && git fetch self') - system('git remote -v') - ts_counterpart = " while IFS= read -r line; do printf '[%s] %s\n' \"$(date '+%Y-%m-%d %H:%M:%S')\" \"$line\"; done" + log_name = "xcodebuild.log" # initalize Pods for podfile_path in Dir.glob('e2eTests/**/*.Podfile') @@ -128,8 +124,6 @@ task :e2e_only do system('git clean -xdf e2eTests/XCRemoteCacheSample') # Link prebuild binaries to the Project system('ln -s $(pwd)/releases e2eTests/XCRemoteCacheSample/XCRC') - # Run a docker server - # system('docker run -it --rm -d -p 8080:8080 --name xcremotecache xcremotecache-demo-server') # Create producer Podfile @@ -143,7 +137,7 @@ task :e2e_only do Dir.chdir('e2eTests/XCRemoteCacheSample') do system('pod install') p "Building producer ..." - system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build | #{ts_counterpart} | tee #{log_name}") + system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build > #{log_name}") # reset stats system('XCRC/xcprepare stats --reset --format json') @@ -163,7 +157,7 @@ task :e2e_only do Dir.chdir('e2eTests/XCRemoteCacheSample') do system('pod install') p "Building consumer ..." - system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build | #{ts_counterpart} | tee #{log_name}") + system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build > #{log_name}") # clean DerivedData system('rm -rf ./build') @@ -179,14 +173,12 @@ task :e2e_only do p "hit rate: #{hit_rate}% (#{hits}/#{all_targets})" end - # Kill a docker - # system('docker kill xcremotecache') - # Destroy cache + # Destroy a cache system('rm -rf /tmp/cache') end # Revert remote - system('git origin delete self') + system('git remote delete self') # Stop nginx system('nginx -s stop') diff --git a/e2eTests/nginx/nginx.conf b/e2eTests/nginx/nginx.conf index 97c7f2f..5aad388 100644 --- a/e2eTests/nginx/nginx.conf +++ b/e2eTests/nginx/nginx.conf @@ -1,5 +1,7 @@ +# Nginx configuration used for E2E tests cache server +# Listens HTTP on port 8080 + -#user nobody; worker_processes 1; events { @@ -14,10 +16,6 @@ http { listen 8080; server_name localhost; - #charset koi8-r; - - #access_log logs/host.access.log main; - location / { root html; index index.html index.htm; @@ -28,7 +26,6 @@ http { root /tmp/cache; # Allow PUT dav_methods PUT; - # Allow nginx to create the /ac and /cas subdirectories. create_full_put_path on; # The maximum size of a single file. client_max_body_size 1G; @@ -36,7 +33,6 @@ http { } sendfile on; - #keepalive_timeout 0; keepalive_timeout 65; error_page 500 502 503 504 /50x.html; From 92875bcdeed1c667829e4e196c35eda0fb144633 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Thu, 3 Feb 2022 20:35:07 +0100 Subject: [PATCH 13/20] Change DerivedData path --- Rakefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Rakefile b/Rakefile index 5346087..68f7198 100644 --- a/Rakefile +++ b/Rakefile @@ -142,7 +142,7 @@ task :e2e_only do # reset stats system('XCRC/xcprepare stats --reset --format json') # clean DerivedData - system('rm -rf ./build') + system('rm -rf ./DerivedData') end @@ -157,10 +157,10 @@ task :e2e_only do Dir.chdir('e2eTests/XCRemoteCacheSample') do system('pod install') p "Building consumer ..." - system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build > #{log_name}") + system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData2 EXCLUDED_ARCHS='arm64 i386' clean build > #{log_name}") # clean DerivedData - system('rm -rf ./build') + system('rm -rf ./DerivedData2') # validate 100% hit rate stats_json_string = JSON.parse(`XCRC/xcprepare stats --format json`) @@ -178,7 +178,7 @@ task :e2e_only do end # Revert remote - system('git remote delete self') + system('git remote remove self') # Stop nginx system('nginx -s stop') From 56b6722dbe053151300758fcb04c2d6895579c6f Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Thu, 3 Feb 2022 21:44:55 +0100 Subject: [PATCH 14/20] Reuse DerivedData for producer and consumer --- Rakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 68f7198..f5fc1d9 100644 --- a/Rakefile +++ b/Rakefile @@ -157,10 +157,10 @@ task :e2e_only do Dir.chdir('e2eTests/XCRemoteCacheSample') do system('pod install') p "Building consumer ..." - system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData2 EXCLUDED_ARCHS='arm64 i386' clean build > #{log_name}") + system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build > #{log_name}") # clean DerivedData - system('rm -rf ./DerivedData2') + system('rm -rf ./DerivedData') # validate 100% hit rate stats_json_string = JSON.parse(`XCRC/xcprepare stats --format json`) From b872a8d7f94f341819fcd372178f2c26f610fc9d Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Fri, 4 Feb 2022 18:59:19 +0100 Subject: [PATCH 15/20] Post test cleanup --- Rakefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Rakefile b/Rakefile index f5fc1d9..4b72282 100644 --- a/Rakefile +++ b/Rakefile @@ -94,6 +94,7 @@ task :e2e_only do # Start nginx server system('nginx -c $PWD/e2eTests/nginx/nginx.conf') + Signal.trap(0, proc { system('nginx -s stop') }) current_branch = 'e2e-test-branch' producer_configuration = %{xcremotecache({ @@ -120,6 +121,7 @@ task :e2e_only do # initalize Pods for podfile_path in Dir.glob('e2eTests/**/*.Podfile') p "****** Scenario: #{podfile_path}" + system('rm -rf /tmp/cache') # Revert any local changes system('git clean -xdf e2eTests/XCRemoteCacheSample') # Link prebuild binaries to the Project @@ -159,9 +161,6 @@ task :e2e_only do p "Building consumer ..." system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build > #{log_name}") - # clean DerivedData - system('rm -rf ./DerivedData') - # validate 100% hit rate stats_json_string = JSON.parse(`XCRC/xcprepare stats --format json`) misses = stats_json_string.fetch('miss_count', 0) @@ -171,6 +170,9 @@ task :e2e_only do hit_rate = hits * 100 / all_targets raise "Failure: Hit rate is only #{hit_rate}%" if misses != 0 p "hit rate: #{hit_rate}% (#{hits}/#{all_targets})" + + # clean DerivedData + system('rm -rf ./DerivedData') end # Destroy a cache @@ -180,8 +182,6 @@ task :e2e_only do # Revert remote system('git remote remove self') - # Stop nginx - system('nginx -s stop') end From 0778639ae23b4133e573b3dfb14dca95324c4a2e Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Sat, 5 Feb 2022 20:24:16 +0100 Subject: [PATCH 16/20] Extract to a separate file --- Rakefile | 106 +---------------------------- tasks/e2e.rb | 186 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 189 insertions(+), 103 deletions(-) create mode 100644 tasks/e2e.rb diff --git a/Rakefile b/Rakefile index 4b72282..248f505 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,6 @@ # encoding: utf-8 require 'json' +require_relative 'tasks/e2e' ################################ # Rake configuration @@ -78,112 +79,11 @@ task :test do spm_test() end -desc 'run E2E tests with CocoaPods plugin' +desc 'build and run E2E tests' task :e2e => [:build, :e2e_only] desc 'run E2E tests without building the XCRemoteCache binary' -task :e2e_only do - # Build a plugin - cocoapods_dir = 'cocoapods-plugin' - Dir.chdir(cocoapods_dir) do - gemspec_path = "cocoapods-xcremotecache.gemspec" - gemfile_path = "cocoapods-xcremotecache.gem" - system("gem build #{gemspec_path} -o #{gemfile_path}") - system("gem install #{gemfile_path}") - end - - # Start nginx server - system('nginx -c $PWD/e2eTests/nginx/nginx.conf') - Signal.trap(0, proc { system('nginx -s stop') }) - - current_branch = 'e2e-test-branch' - producer_configuration = %{xcremotecache({ - 'cache_addresses' => ['http://localhost:8080/cache/pods'], - 'primary_repo' => '.', - 'primary_branch' => '#{current_branch}', - 'mode' => 'producer', - 'final_target' => 'XCRemoteCacheSample', - 'artifact_maximum_age' => 0 - })} - consumer_configuration = %{xcremotecache({ - 'cache_addresses' => ['http://localhost:8080/cache/pods'], - 'primary_repo' => '.', - 'primary_branch' => '#{current_branch}', - 'mode' => 'consumer', - 'final_target' => 'XCRemoteCacheSample', - 'artifact_maximum_age' => 0 - })} - # Configure remote - system("git checkout -b #{current_branch}") - system('git remote add self . && git fetch self') - - log_name = "xcodebuild.log" - # initalize Pods - for podfile_path in Dir.glob('e2eTests/**/*.Podfile') - p "****** Scenario: #{podfile_path}" - system('rm -rf /tmp/cache') - # Revert any local changes - system('git clean -xdf e2eTests/XCRemoteCacheSample') - # Link prebuild binaries to the Project - system('ln -s $(pwd)/releases e2eTests/XCRemoteCacheSample/XCRC') - - - # Create producer Podfile - File.open('e2eTests/XCRemoteCacheSample/Podfile', 'w') do |f| - # Copy podfile - File.foreach(podfile_path) { |line| f.puts line } - - f.write(producer_configuration) - end - - Dir.chdir('e2eTests/XCRemoteCacheSample') do - system('pod install') - p "Building producer ..." - system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build > #{log_name}") - - # reset stats - system('XCRC/xcprepare stats --reset --format json') - # clean DerivedData - system('rm -rf ./DerivedData') - end - - - # Create consumer Podfile - File.open('e2eTests/XCRemoteCacheSample/Podfile', 'w') do |f| - # Copy podfile - File.foreach(podfile_path) { |line| f.puts line; p } - - f.write(consumer_configuration) - end - - Dir.chdir('e2eTests/XCRemoteCacheSample') do - system('pod install') - p "Building consumer ..." - system("xcodebuild -workspace 'XCRemoteCacheSample.xcworkspace' -scheme 'XCRemoteCacheSample' -configuration 'Debug' -sdk 'iphonesimulator' -destination 'generic/platform=iOS Simulator' -derivedDataPath ./DerivedData EXCLUDED_ARCHS='arm64 i386' clean build > #{log_name}") - - # validate 100% hit rate - stats_json_string = JSON.parse(`XCRC/xcprepare stats --format json`) - misses = stats_json_string.fetch('miss_count', 0) - hits = stats_json_string.fetch('hit_count', 0) - all_targets = misses + hits - raise "Failure: XCRemoteCache is disabled" if all_targets == 0 - hit_rate = hits * 100 / all_targets - raise "Failure: Hit rate is only #{hit_rate}%" if misses != 0 - p "hit rate: #{hit_rate}% (#{hits}/#{all_targets})" - - # clean DerivedData - system('rm -rf ./DerivedData') - end - - # Destroy a cache - system('rm -rf /tmp/cache') - end - - # Revert remote - system('git remote remove self') - -end - +task :e2e_only => ['e2e:run'] ################################ # Helper functions diff --git a/tasks/e2e.rb b/tasks/e2e.rb new file mode 100644 index 0000000..52db84d --- /dev/null +++ b/tasks/e2e.rb @@ -0,0 +1,186 @@ +require 'json' + +desc 'Support for E2E tests: building XCRemoteCache-enabled xcodeproj using xcodebuild' +namespace :e2e do + COCOAPODS_DIR = 'cocoapods-plugin' + COCOAPODS_GEMSPEC_FILENAME = "cocoapods-xcremotecache.gemspec" + E2E_COCOAPODS_SAMPLE_DIR = 'e2eTests/XCRemoteCacheSample' + GIT_REMOTE_NAME = 'self' + # Location of the remote address that points to itself + GIT_REMOTE_ADDRESS = '.' + GIT_BRANCH = 'e2e-test-branch' + LOG_NAME = "xcodebuild.log" + DERIVED_DATA_PATH = './DerivedData' + NGINX_ROOT_DIR = '/tmp/cache' + XCRC_BINARIES = 'XCRC' + SHARED_COCOAPODS_CONFIG = { + 'cache_addresses' => ['http://localhost:8080/cache/pods'], + 'primary_repo' => GIT_REMOTE_ADDRESS, + 'primary_branch' => GIT_BRANCH, + 'mode' => 'consumer', + 'final_target' => 'XCRemoteCacheSample', + 'artifact_maximum_age' => 0 + } + + Stats = Struct.new(:hits, :misses, :hit_rate) + + # run E2E tests + task :run => [:run_cocoapods] + + # run E2E tests for CocoaPods-powered projects + task :run_cocoapods do + install_cocoapods_plugin + start_nginx + configure_git + + # Run scenarios for all Podfile scenarios + for podfile_path in Dir.glob('e2eTests/**/*.Podfile') + run_cocoapods_scenario(podfile_path) + end + # Revert all side effects + clean + end + + # Build and install a plugin + def self.install_cocoapods_plugin + Dir.chdir(COCOAPODS_DIR) do + gemfile_path = "cocoapods-xcremotecache.gem" + system("gem build #{COCOAPODS_GEMSPEC_FILENAME} -o #{gemfile_path}") + system("gem install #{gemfile_path}") + end + end + + def self.start_nginx + # Start nginx server + system('nginx -c $PWD/e2eTests/nginx/nginx.conf') + puts('starting nginx') + # Call cleanup on exit + at_exit { puts('resetting ngingx'); system('nginx -s stop') } + end + + # Create a new branch out of a current commit and + # add remote that points to itself + def self.configure_git + system("git checkout -B #{GIT_BRANCH}") + system("git remote add #{GIT_REMOTE_NAME} #{GIT_REMOTE_ADDRESS} && git fetch -q #{GIT_REMOTE_NAME}") + # Revert new remote on exit + at_exit { system("git remote remove #{GIT_REMOTE_NAME}")} + end + + def self.pre_producer_setup + clean_git + clean_server + # Link prebuilt binaries to the Project + system("ln -s $(pwd)/releases #{E2E_COCOAPODS_SAMPLE_DIR}/#{XCRC_BINARIES}") + end + + def self.pre_consumer_setup + clean_git + # Link prebuilt binaries to the Project + system("ln -s $(pwd)/releases #{E2E_COCOAPODS_SAMPLE_DIR}/#{XCRC_BINARIES}") + end + + def self.clean_server + system("rm -rf #{NGINX_ROOT_DIR}") + end + + # Revert any local changes in the test project + def self.clean_git + system("git clean -xdf #{E2E_COCOAPODS_SAMPLE_DIR}") + end + + # Cleans all extra locations that a test creates + def self.clean + clean_git + clean_server + end + + # xcremotecache configuration to add to Podfile + def self.cocoapods_configuration_string(extra_configs = {}) + configuration_lines = ['xcremotecache({'] + all_properties = SHARED_COCOAPODS_CONFIG.merge(extra_configs) + config_lines = all_properties.map {|key, value| " \"#{key}\" => #{value.inspect},"} + configuration_lines.push(*config_lines) + configuration_lines << '})' + configuration_lines.join("\n") + end + + def self.dump_podfile(config, source) + # Create producer Podfile + File.open("#{E2E_COCOAPODS_SAMPLE_DIR}/Podfile", 'w') do |f| + # Copy podfile template + File.foreach(source) { |line| f.puts line } + f.write(config) + end + end + + def self.build_project + system('pod install') + xcodebuild_args = { + 'workspace' => 'XCRemoteCacheSample.xcworkspace', + 'scheme' => 'XCRemoteCacheSample', + 'configuration' => 'Debug', + 'sdk' => 'iphonesimulator', + 'destination' => 'generic/platform=iOS Simulator', + 'derivedDataPath' => DERIVED_DATA_PATH, + } + xcodebuild_vars = { + 'EXCLUDED_ARCHS' => 'arm64 i386' + } + args = ['xcodebuild'] + args.push(*xcodebuild_args.map {|k,v| "-#{k} '#{v}'"}) + args.push(*xcodebuild_vars.map {|k,v| "#{k}='#{v}'"}) + args.push('clean build') + args.push("> #{LOG_NAME}") + puts 'Building a project with xcodebuild...' + system(args.join(' ')) + unless $?.success? + system("tail #{LOG_NAME}") + raise "xcodebuild failed." + end + end + + def self.read_stats + stats_json_string = JSON.parse(`#{XCRC_BINARIES}/xcprepare stats --format json`) + misses = stats_json_string.fetch('miss_count', 0) + hits = stats_json_string.fetch('hit_count', 0) + all_targets = misses + hits + raise "Failure: No XCRemoteCache targets invoked" if all_targets == 0 + hit_rate = hits * 100 / all_targets + Stats.new(hits, misses, hit_rate) + end + + # validate 100% hit rate + def self.valide_hit_rate + status = read_stats() + raise "Failure: Hit rate is only #{status.hit_rate}% (#{status.hits}/#{status.all_targets})" if status.misses > 0 + all_targets = status.misses + status.hits + puts("Hit rate: #{status.hit_rate}% (#{status.hits}/#{all_targets})") + end + + def self.run_cocoapods_scenario(template_path) + producer_configuration = cocoapods_configuration_string({'mode' => 'producer'}) + consumer_configuration = cocoapods_configuration_string() + + puts("****** Scenario: #{template_path}") + + # Run producer build + pre_producer_setup + dump_podfile(producer_configuration, template_path) + puts('Building producer ...') + Dir.chdir(E2E_COCOAPODS_SAMPLE_DIR) do + build_project + # reset XCRemoteCache stats + system("#{XCRC_BINARIES}/xcprepare stats --reset --format json") + end + + # Run consumer build + pre_consumer_setup + dump_podfile(consumer_configuration, template_path) + puts('Building consumer ...') + Dir.chdir(E2E_COCOAPODS_SAMPLE_DIR) do + build_project + valide_hit_rate + end + end +end \ No newline at end of file From f0a4d361b17788d49dd4389ace4e015b512c71ef Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Sat, 5 Feb 2022 21:25:12 +0100 Subject: [PATCH 17/20] Use separate DerivedData path for consumser --- Rakefile | 1 - tasks/e2e.rb | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Rakefile b/Rakefile index 248f505..e56b58a 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,4 @@ # encoding: utf-8 -require 'json' require_relative 'tasks/e2e' ################################ diff --git a/tasks/e2e.rb b/tasks/e2e.rb index 52db84d..6bc08a3 100644 --- a/tasks/e2e.rb +++ b/tasks/e2e.rb @@ -114,7 +114,7 @@ namespace :e2e do end end - def self.build_project + def self.build_project(extra_args = {}) system('pod install') xcodebuild_args = { 'workspace' => 'XCRemoteCacheSample.xcworkspace', @@ -123,7 +123,7 @@ namespace :e2e do 'sdk' => 'iphonesimulator', 'destination' => 'generic/platform=iOS Simulator', 'derivedDataPath' => DERIVED_DATA_PATH, - } + }.merge(extra_args) xcodebuild_vars = { 'EXCLUDED_ARCHS' => 'arm64 i386' } @@ -179,8 +179,8 @@ namespace :e2e do dump_podfile(consumer_configuration, template_path) puts('Building consumer ...') Dir.chdir(E2E_COCOAPODS_SAMPLE_DIR) do - build_project + build_project({'derivedDataPath' => "#{DERIVED_DATA_PATH}_Consumer"}) valide_hit_rate end end -end \ No newline at end of file +end From c6b31d30864dd50b3643c6f541817e7863ae6116 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Sat, 5 Feb 2022 21:31:57 +0100 Subject: [PATCH 18/20] Disable exclusive DD paths --- tasks/e2e.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks/e2e.rb b/tasks/e2e.rb index 6bc08a3..83b1096 100644 --- a/tasks/e2e.rb +++ b/tasks/e2e.rb @@ -179,7 +179,8 @@ namespace :e2e do dump_podfile(consumer_configuration, template_path) puts('Building consumer ...') Dir.chdir(E2E_COCOAPODS_SAMPLE_DIR) do - build_project({'derivedDataPath' => "#{DERIVED_DATA_PATH}_Consumer"}) + # TODO: Change DerivedData's path to emulate multi-machines setup. Blocked by #59 + build_project({'derivedDataPath' => "#{DERIVED_DATA_PATH}"}) valide_hit_rate end end From 1c5aa569dd24979679234bcff6a316953d508a95 Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Sat, 5 Feb 2022 21:37:36 +0100 Subject: [PATCH 19/20] Cleanup xcodeproj --- .../project.pbxproj | 114 ------------------ .../XCRemoteCacheSample/AppDelegate.swift | 7 -- .../XCRemoteCacheSample/SceneDelegate.swift | 20 --- .../XCRemoteCacheSample/ViewController.swift | 1 - 4 files changed, 142 deletions(-) diff --git a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample.xcodeproj/project.pbxproj b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample.xcodeproj/project.pbxproj index 4a122ca..8727476 100644 --- a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample.xcodeproj/project.pbxproj +++ b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample.xcodeproj/project.pbxproj @@ -13,7 +13,6 @@ 3695D9D327A3218C007F3792 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3695D9D127A3218C007F3792 /* Main.storyboard */; }; 3695D9D527A3218D007F3792 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3695D9D427A3218D007F3792 /* Assets.xcassets */; }; 3695D9D827A3218D007F3792 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3695D9D627A3218D007F3792 /* LaunchScreen.storyboard */; }; - E0A28FC0C12F263A640F955C /* Pods_XCRemoteCacheSample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A3FD0BAE1387E5E29B6D7E35 /* Pods_XCRemoteCacheSample.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -25,9 +24,6 @@ 3695D9D427A3218D007F3792 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 3695D9D727A3218D007F3792 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 3695D9D927A3218D007F3792 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 3EE12A879EBE767C99B0FC32 /* Pods-XCRemoteCacheSample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-XCRemoteCacheSample.debug.xcconfig"; path = "Target Support Files/Pods-XCRemoteCacheSample/Pods-XCRemoteCacheSample.debug.xcconfig"; sourceTree = ""; }; - A3FD0BAE1387E5E29B6D7E35 /* Pods_XCRemoteCacheSample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_XCRemoteCacheSample.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - C7B900612D1F7BD7CA3DFDC9 /* Pods-XCRemoteCacheSample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-XCRemoteCacheSample.release.xcconfig"; path = "Target Support Files/Pods-XCRemoteCacheSample/Pods-XCRemoteCacheSample.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -35,7 +31,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - E0A28FC0C12F263A640F955C /* Pods_XCRemoteCacheSample.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -47,8 +42,6 @@ children = ( 3695D9CA27A3218C007F3792 /* XCRemoteCacheSample */, 3695D9C927A3218C007F3792 /* Products */, - 4FE2462282E9908CE0357DE3 /* Pods */, - 9736800B94F7D85ED1CA9F7E /* Frameworks */, ); sourceTree = ""; }; @@ -74,24 +67,6 @@ path = XCRemoteCacheSample; sourceTree = ""; }; - 4FE2462282E9908CE0357DE3 /* Pods */ = { - isa = PBXGroup; - children = ( - 3EE12A879EBE767C99B0FC32 /* Pods-XCRemoteCacheSample.debug.xcconfig */, - C7B900612D1F7BD7CA3DFDC9 /* Pods-XCRemoteCacheSample.release.xcconfig */, - ); - name = Pods; - path = Pods; - sourceTree = ""; - }; - 9736800B94F7D85ED1CA9F7E /* Frameworks */ = { - isa = PBXGroup; - children = ( - A3FD0BAE1387E5E29B6D7E35 /* Pods_XCRemoteCacheSample.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -99,12 +74,9 @@ isa = PBXNativeTarget; buildConfigurationList = 3695D9DC27A3218D007F3792 /* Build configuration list for PBXNativeTarget "XCRemoteCacheSample" */; buildPhases = ( - E722BEC0D6AA112B0DC88BA5 /* [CP] Check Pods Manifest.lock */, 3695D9C427A3218C007F3792 /* Sources */, 3695D9C527A3218C007F3792 /* Frameworks */, 3695D9C627A3218C007F3792 /* Resources */, - 181E10D369F1135B2514CC3B /* [CP] Embed Pods Frameworks */, - 785F3A1B596395970C430424 /* [XCRC] Postbuild */, ); buildRules = ( ); @@ -161,70 +133,6 @@ }; /* End PBXResourcesBuildPhase section */ -/* Begin PBXShellScriptBuildPhase section */ - 181E10D369F1135B2514CC3B /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-XCRemoteCacheSample/Pods-XCRemoteCacheSample-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-XCRemoteCacheSample/Pods-XCRemoteCacheSample-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-XCRemoteCacheSample/Pods-XCRemoteCacheSample-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; - 785F3A1B596395970C430424 /* [XCRC] Postbuild */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - dependencyFile = "$(TARGET_TEMP_DIR)/postbuild.d"; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "$SRCROOT/XCRC/xcpostbuild", - ); - name = "[XCRC] Postbuild"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(TARGET_BUILD_DIR)/$(MODULES_FOLDER_PATH)/$(PRODUCT_MODULE_NAME).swiftmodule/$(XCRC_PLATFORM_PREFERRED_ARCH).swiftmodule.md5", - "$(TARGET_BUILD_DIR)/$(MODULES_FOLDER_PATH)/$(PRODUCT_MODULE_NAME).swiftmodule/$(XCRC_PLATFORM_PREFERRED_ARCH)-$(LLVM_TARGET_TRIPLE_VENDOR)-$(SWIFT_PLATFORM_TARGET_PREFIX)$(LLVM_TARGET_TRIPLE_SUFFIX).swiftmodule.md5", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"$SCRIPT_INPUT_FILE_0\""; - }; - E722BEC0D6AA112B0DC88BA5 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-XCRemoteCacheSample-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ 3695D9C427A3218C007F3792 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -376,7 +284,6 @@ }; 3695D9DD27A3218D007F3792 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 3EE12A879EBE767C99B0FC32 /* Pods-XCRemoteCacheSample.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; @@ -389,32 +296,21 @@ INFOPLIST_KEY_UIMainStoryboardFile = Main; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - LD = "$SRCROOT/XCRC/xcld"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - LIBTOOL = "$SRCROOT/XCRC/xclibtool"; MARKETING_VERSION = 1.0; - OTHER_CFLAGS = ( - "$(inherited)", - " -fdebug-prefix-map=$(SRCROOT)=$(XCREMOTE_CACHE_FAKE_SRCROOT)", - ); - OTHER_SWIFT_FLAGS = "$(inherited) -debug-prefix-map $(SRCROOT)=$(XCREMOTE_CACHE_FAKE_SRCROOT)"; PRODUCT_BUNDLE_IDENTIFIER = com.xcremotecache.XCRemoteCacheSample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_EXEC = "$SRCROOT/XCRC/xcswiftc"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; - XCRC_PLATFORM_PREFERRED_ARCH = "$(LINK_FILE_LIST_$(CURRENT_VARIANT)_$(PLATFORM_PREFERRED_ARCH):dir:standardizepath:file:default=arm64)"; - XCREMOTE_CACHE_FAKE_SRCROOT = /xxxxxxxxxx; }; name = Debug; }; 3695D9DE27A3218D007F3792 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = C7B900612D1F7BD7CA3DFDC9 /* Pods-XCRemoteCacheSample.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; @@ -427,26 +323,16 @@ INFOPLIST_KEY_UIMainStoryboardFile = Main; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - LD = "$SRCROOT/XCRC/xcld"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); - LIBTOOL = "$SRCROOT/XCRC/xclibtool"; MARKETING_VERSION = 1.0; - OTHER_CFLAGS = ( - "$(inherited)", - " -fdebug-prefix-map=$(SRCROOT)=$(XCREMOTE_CACHE_FAKE_SRCROOT)", - ); - OTHER_SWIFT_FLAGS = "$(inherited) -debug-prefix-map $(SRCROOT)=$(XCREMOTE_CACHE_FAKE_SRCROOT)"; PRODUCT_BUNDLE_IDENTIFIER = com.xcremotecache.XCRemoteCacheSample; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_EXEC = "$SRCROOT/XCRC/xcswiftc"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; - XCRC_PLATFORM_PREFERRED_ARCH = "$(LINK_FILE_LIST_$(CURRENT_VARIANT)_$(PLATFORM_PREFERRED_ARCH):dir:standardizepath:file:default=arm64)"; - XCREMOTE_CACHE_FAKE_SRCROOT = /xxxxxxxxxx; }; name = Release; }; diff --git a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/AppDelegate.swift b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/AppDelegate.swift index 433b8f1..a0ac6ec 100644 --- a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/AppDelegate.swift +++ b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/AppDelegate.swift @@ -25,24 +25,17 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - // Override point for customization after application launch. return true } // MARK: UISceneSession Lifecycle func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { - // Called when a new scene session is being created. - // Use this method to select a configuration to create the new scene with. return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) } func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { - // Called when the user discards a scene session. - // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. - // Use this method to release any resources that were specific to the discarded scenes, as they will not return. } - } diff --git a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/SceneDelegate.swift b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/SceneDelegate.swift index bc8ea2c..9275b00 100644 --- a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/SceneDelegate.swift +++ b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/SceneDelegate.swift @@ -20,45 +20,25 @@ import UIKit class SceneDelegate: UIResponder, UIWindowSceneDelegate { - var window: UIWindow? func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { - // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. - // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. - // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). - guard let _ = (scene as? UIWindowScene) else { return } } func sceneDidDisconnect(_ scene: UIScene) { - // Called as the scene is being released by the system. - // This occurs shortly after the scene enters the background, or when its session is discarded. - // Release any resources associated with this scene that can be re-created the next time the scene connects. - // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead). } func sceneDidBecomeActive(_ scene: UIScene) { - // Called when the scene has moved from an inactive state to an active state. - // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. } func sceneWillResignActive(_ scene: UIScene) { - // Called when the scene will move from an active state to an inactive state. - // This may occur due to temporary interruptions (ex. an incoming phone call). } func sceneWillEnterForeground(_ scene: UIScene) { - // Called as the scene transitions from the background to the foreground. - // Use this method to undo the changes made on entering the background. } func sceneDidEnterBackground(_ scene: UIScene) { - // Called as the scene transitions from the foreground to the background. - // Use this method to save data, release shared resources, and store enough scene-specific state information - // to restore the scene back to its current state. } - - } diff --git a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/ViewController.swift b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/ViewController.swift index 3447333..f85ee49 100644 --- a/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/ViewController.swift +++ b/e2eTests/XCRemoteCacheSample/XCRemoteCacheSample/ViewController.swift @@ -23,7 +23,6 @@ class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - // Do any additional setup after loading the view. } From 478649a1d7cd8dda64e16ab39ae972decd37ae1b Mon Sep 17 00:00:00 2001 From: Bartosz Polaczyk Date: Sat, 5 Feb 2022 21:49:35 +0100 Subject: [PATCH 20/20] Add docs --- docs/Development.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/Development.md b/docs/Development.md index a458c81..352277f 100644 --- a/docs/Development.md +++ b/docs/Development.md @@ -25,7 +25,18 @@ The generated Xcode project contains schemes for each output application (like ` #### Running tests in Xcode -All unit tests are placed in `XCRemoteCacheTests`. To run them from Xcode, just pick any application scheme and run tests (⌘+U). +All unit tests are placed in `XCRemoteCacheTests`. To run them from Xcode, just pick any application scheme and run tests (⌘+U). + +#### Running E2E tests + +E2E tests build a CocoaPods plugin, locally build both `producer` and `consumer` modes and verify 100% hit rate. All `Podfile` templates are placed in [e2eTests/tests](../e2eTests/tests). As a backend server, nginx server with a sample [nginx.conf](../e2eTests/nginx/nginx.conf) configuration is used. The sample server exposes local location `/tmp/cache` under http://localhost:8080. + +To run tests locally, install `nginx` (e.g. `brew install nginx`) and call: + +```bash +rake 'build[release]' +rake e2e_only +``` ## Project organization