Ver Fonte

Update instructions

Matthew Mathias há 3 anos atrás
pai
commit
4b4af4628d

+ 5 - 10
.github/workflows/tests.yml

@@ -74,13 +74,6 @@ jobs:
     steps:
     - name: Checkout
       uses: actions/checkout@v2
-    - name: Create xcconfig file
-      shell: bash
-      env:
-        EMAIL_SECRET : ${{ secrets.EMAIL_SECRET }}
-        PASSWORD_SECRET : ${{ secrets.PASSWORD_SECRET }}
-      run: |
-        echo EMAIL_SECRET = $EMAIL_SECRET$'\n'PASSWORD_SECRET = $PASSWORD_SECRET >> DaysUntilBirthdayUITests\(iOS\)/Credentials.xcconfig
     - name: Build test target for Google Sign-in button for Swift
       run: |
         xcodebuild \
@@ -91,12 +84,14 @@ jobs:
           -destination 'platform=iOS Simulator,name=iPhone 11'
     - name: Run test target for Google Sign-in button for Swift
       env:
-        FOO_BAR : ${{ secrets.FOO_BAR }}
+        EMAIL_SECRET : ${{ secrets.EMAIL_SECRET }}
+        PASSWORD_SECRET : ${{ secrets.PASSWORD_SECRET }}
       run: |
         xcodebuild \
           -project DaysUntilBirthday.xcodeproj \
           test-without-building \
           -scheme DaysUntilBirthday\(iOS\) \
           -sdk iphonesimulator \
-          -destination 'platform=iOS Simulator,name=iPhone 11'
-          FOO_BAR=$FOO_BAR
+          -destination 'platform=iOS Simulator,name=iPhone 11' \
+          EMAIL_SECRET=$EMAIL_SECRET \ 
+          PASSWORD_SECRET=$PASSWORD_SECRET

+ 0 - 9
Samples/Swift/DaysUntilBirthday/DaysUntilBirthday.xcodeproj/project.pbxproj

@@ -19,7 +19,6 @@
 		7345AD242703D9C30020AFB1 /* UserProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7345AD1A2703D9C30020AFB1 /* UserProfileView.swift */; };
 		73508EC82811BD9C00ED7FB7 /* DaysUntilBirthdayUITests_iOS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73508EC72811BD9C00ED7FB7 /* DaysUntilBirthdayUITests_iOS.swift */; };
 		73508ED528134C7300ED7FB7 /* Credential.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73508ED428134C7300ED7FB7 /* Credential.swift */; };
-		73508ED9281353E800ED7FB7 /* Credentials.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 73508ED8281353E800ED7FB7 /* Credentials.xcconfig */; };
 		736F49BA270E05E200580053 /* BirthdayLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 736F49B9270E05E200580053 /* BirthdayLoader.swift */; };
 		736F49BC270E102C00580053 /* BirthdayViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 736F49BB270E102C00580053 /* BirthdayViewModel.swift */; };
 		739FCC46270E467600C92042 /* BirthdayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 739FCC45270E467600C92042 /* BirthdayView.swift */; };
@@ -68,9 +67,7 @@
 		7345AD1A2703D9C30020AFB1 /* UserProfileView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserProfileView.swift; sourceTree = "<group>"; };
 		73508EC52811BD9C00ED7FB7 /* DaysUntilBirthdayUITests (iOS).xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "DaysUntilBirthdayUITests (iOS).xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
 		73508EC72811BD9C00ED7FB7 /* DaysUntilBirthdayUITests_iOS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DaysUntilBirthdayUITests_iOS.swift; sourceTree = "<group>"; };
-		73508ED2281337AE00ED7FB7 /* DaysUntilBirthdayUITests-iOS--Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "DaysUntilBirthdayUITests-iOS--Info.plist"; sourceTree = SOURCE_ROOT; };
 		73508ED428134C7300ED7FB7 /* Credential.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Credential.swift; sourceTree = "<group>"; };
-		73508ED8281353E800ED7FB7 /* Credentials.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Credentials.xcconfig; sourceTree = "<group>"; };
 		736F49B9270E05E200580053 /* BirthdayLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BirthdayLoader.swift; sourceTree = "<group>"; };
 		736F49BB270E102C00580053 /* BirthdayViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BirthdayViewModel.swift; sourceTree = "<group>"; };
 		739FCC45270E467600C92042 /* BirthdayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BirthdayView.swift; sourceTree = "<group>"; };
@@ -159,10 +156,8 @@
 		73508EC62811BD9C00ED7FB7 /* DaysUntilBirthdayUITests(iOS) */ = {
 			isa = PBXGroup;
 			children = (
-				73508ED2281337AE00ED7FB7 /* DaysUntilBirthdayUITests-iOS--Info.plist */,
 				73508EC72811BD9C00ED7FB7 /* DaysUntilBirthdayUITests_iOS.swift */,
 				73508ED428134C7300ED7FB7 /* Credential.swift */,
-				73508ED8281353E800ED7FB7 /* Credentials.xcconfig */,
 			);
 			path = "DaysUntilBirthdayUITests(iOS)";
 			sourceTree = "<group>";
@@ -361,7 +356,6 @@
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				73508ED9281353E800ED7FB7 /* Credentials.xcconfig in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -598,7 +592,6 @@
 		};
 		73508ECD2811BD9C00ED7FB7 /* Debug */ = {
 			isa = XCBuildConfiguration;
-			baseConfigurationReference = 73508ED8281353E800ED7FB7 /* Credentials.xcconfig */;
 			buildSettings = {
 				CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
 				CODE_SIGN_STYLE = Automatic;
@@ -608,7 +601,6 @@
 					"DEBUG=1",
 				);
 				GENERATE_INFOPLIST_FILE = YES;
-				INFOPLIST_FILE = "DaysUntilBirthdayUITests-iOS--Info.plist";
 				INFOPLIST_KEY_LSApplicationCategoryType = "";
 				IPHONEOS_DEPLOYMENT_TARGET = 15.0;
 				LD_RUNPATH_SEARCH_PATHS = (
@@ -635,7 +627,6 @@
 				CURRENT_PROJECT_VERSION = 1;
 				GCC_PREPROCESSOR_DEFINITIONS = "";
 				GENERATE_INFOPLIST_FILE = YES;
-				INFOPLIST_FILE = "DaysUntilBirthdayUITests-iOS--Info.plist";
 				INFOPLIST_KEY_LSApplicationCategoryType = "";
 				IPHONEOS_DEPLOYMENT_TARGET = 15.0;
 				LD_RUNPATH_SEARCH_PATHS = (

+ 7 - 2
Samples/Swift/DaysUntilBirthday/DaysUntilBirthday.xcodeproj/xcshareddata/xcschemes/DaysUntilBirthday(iOS).xcscheme

@@ -38,8 +38,13 @@
       </MacroExpansion>
       <EnvironmentVariables>
          <EnvironmentVariable
-            key = "FOO_BAR"
-            value = "$(FOO_BAR)"
+            key = "EMAIL_SECRET"
+            value = "$(EMAIL_SECRET)"
+            isEnabled = "YES">
+         </EnvironmentVariable>
+         <EnvironmentVariable
+            key = "PASSWORD_SECRET"
+            value = "$(PASSWORD_SECRET)"
             isEnabled = "YES">
          </EnvironmentVariable>
       </EnvironmentVariables>

+ 3 - 8
Samples/Swift/DaysUntilBirthday/DaysUntilBirthdayUITests(iOS)/Credential.swift

@@ -16,10 +16,9 @@
 
 import Foundation
 
-/// An enumeration helping to interact with the configuration file containing
+/// An enumeration helping to interact with the environment variables containing
 /// the email and password secrets used for testing the Google sign-in flow.
 enum Credential: String {
-  static let bundle: Bundle? = Bundle(identifier: "com.google.DaysUntilBirthdayUITests-iOS-")
   private var emailKey: String { return "EMAIL_SECRET" }
   private var passwordKey: String { return "PASSWORD_SECRET" }
 
@@ -29,16 +28,12 @@ enum Credential: String {
   var rawValue: String {
     switch self {
     case .email:
-      guard let email = Credential
-              .bundle?
-              .object(forInfoDictionaryKey: emailKey) as? String else {
+      guard let email = ProcessInfo.processInfo.environment[emailKey] else {
         fatalError("Failed to retrieve secret email from UI testing bundle")
       }
       return email
     case .password:
-      guard let password = Credential
-              .bundle?
-              .object(forInfoDictionaryKey: passwordKey) as? String else {
+      guard let password = ProcessInfo.processInfo.environment[passwordKey] else {
         fatalError("Failed to retrieve secret password from UI testing bundle")
       }
       return password

+ 0 - 7
Samples/Swift/DaysUntilBirthday/DaysUntilBirthdayUITests(iOS)/DaysUntilBirthdayUITests_iOS.swift

@@ -60,13 +60,6 @@ class DaysUntilBirthdayUITests_iOS: XCTestCase {
       return XCTFail("Signing out should return user to sign in view")
     }
   }
-
-  func testFooBarPassedIntoEnvironment() {
-    guard let fooBar = ProcessInfo.processInfo.environment["FOO_BAR"] else {
-      return XCTFail("No `FOO_BAR`.")
-    }
-    XCTAssertEqual(fooBar, "testValue")
-  }
 }
 
 extension DaysUntilBirthdayUITests_iOS {

+ 0 - 10
Samples/Swift/DaysUntilBirthday/DaysUntilBirthdayUITests-iOS--Info.plist

@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>EMAIL_SECRET</key>
-	<string>$(EMAIL_SECRET)</string>
-	<key>PASSWORD_SECRET</key>
-	<string>$(PASSWORD_SECRET)</string>
-</dict>
-</plist>

+ 6 - 16
Samples/Swift/DaysUntilBirthday/README.md

@@ -31,20 +31,10 @@ open DaysUntilBirthday.xcodeproj
 We run integration tests on the `DaysUntilBirthday(iOS)` sample app.
 These tests attempt to login via Google Sign-in, and so they need an email and
 a password.
-The email and password that we use are located in `Credentials.xcconfig`.
+The email and password that we use are defined as
+[secrets](https://docs.github.com/en/actions/learn-github-actions/contexts#secrets-context)
+on our GitHub repo, and we retrieve these from the workflow environment.
 
-We create this file during a workflow step on PR push by retrieving these values
-from [GitHub's Secret's context](https://docs.github.com/en/actions/learn-github-actions/contexts#secrets-context).
-
-Locally, both email and password are retrived from a `Credentials.xcconfig`
-configuration file that is not checked into the repo.
-You will need to create an `Credentials.xcconfig` at this path:
-`Samples/Swift/DaysUntilBirthday/DaysUnilBirthdayUITests(iOS)/Credentials.xcconfig`.
-It will need values for `EMAIL_SECRET` and `PASSWORD_SECRET`:
-
-```
-EMAIL_SECRET = ...
-PASSWORD_SECRET = ...
-```
-
-Refer to the repo's Secrets for the values to add to this configuration file.
+Locally, both the email and password need to be passed to `xcodebuild` as
+arguments: `xcodebuild <other args> EMAIL_SECRET=... PASSWORD_SECRET=...`.
+Refer to the repo's Secrets for these values.