Skip to content

Commit faccf50

Browse files
committed
Restructure TestApp for future CocoaPods support.
1 parent d2ed570 commit faccf50

File tree

13 files changed

+74
-80
lines changed

13 files changed

+74
-80
lines changed

.github/workflows/vertexai.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,25 +136,23 @@ jobs:
136136
runs-on: ${{ matrix.os }}
137137
needs: spm-package-resolved
138138
env:
139-
TEST_RUNNER_VertexAIRunIntegrationTests: 1
140-
TEST_RUNNER_VertexAIIntegrationAuthEmail1: ${{ secrets.VERTEXAI_INTEGRATION_AUTH_EMAIL_1 }}
141-
TEST_RUNNER_VertexAIIntegrationAuthEmailPassword1: ${{ secrets.VERTEXAI_INTEGRATION_AUTH_EMAIL_1_PW }}
142139
TEST_RUNNER_FIRAAppCheckDebugToken: ${{ secrets.VERTEXAI_INTEGRATION_FAC_DEBUG_TOKEN }}
143140
FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1
144-
plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }}
141+
secrets_passphrase: ${{ secrets.GHASecretsGPGPassphrase1 }}
145142
steps:
146143
- uses: actions/checkout@v4
147144
- uses: actions/cache/restore@v4
148145
with:
149146
path: .build
150147
key: ${{needs.spm-package-resolved.outputs.cache_key}}
151148
- name: Install Secret GoogleService-Info.plist
152-
run: scripts/decrypt_gha_secret.sh scripts/gha-encrypted/vertexai-testapp.plist.gpg \
153-
FirebaseVertexAI/Tests/TestApp/Resources/GoogleService-Info.plist "$plist_secret"
149+
run: scripts/decrypt_gha_secret.sh scripts/gha-encrypted/VertexAI/TestApp-GoogleService-Info.plist.gpg \
150+
FirebaseVertexAI/Tests/TestApp/Resources/GoogleService-Info.plist "$secrets_passphrase"
151+
- name: Install Secret Credentials.swift
152+
run: scripts/decrypt_gha_secret.sh scripts/gha-encrypted/VertexAI/TestApp-Credentials.swift.gpg \
153+
FirebaseVertexAI/Tests/TestApp/Tests/Integration/Credentials.swift "$secrets_passphrase"
154154
- name: Xcode
155155
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
156-
- name: Initialize xcodebuild
157-
run: scripts/setup_spm_tests.sh
158156
- name: Run IntegrationTests
159157
run: scripts/build.sh VertexIntegration ${{ matrix.target }}
160158

FirebaseVertexAI/Tests/TestApp/Resources/placeholder.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

FirebaseVertexAI/Tests/TestApp/VertexAITestApp/VertexAITestApp.swift renamed to FirebaseVertexAI/Tests/TestApp/Sources/TestApp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import FirebaseCore
1717
import SwiftUI
1818

1919
@main
20-
struct VertexAITestApp: App {
20+
struct TestApp: App {
2121
init() {
2222
AppCheck.setAppCheckProviderFactory(AppCheckDebugProviderFactory())
2323
FirebaseApp.configure()

FirebaseVertexAI/Tests/TestApp/IntegrationTests/IntegrationTests.swift renamed to FirebaseVertexAI/Tests/TestApp/Tests/Integration/IntegrationTests.swift

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,14 @@ final class IntegrationTests: XCTestCase {
4242
var vertex: VertexAI!
4343
var model: GenerativeModel!
4444
var storage: Storage!
45-
var userID = ""
46-
47-
static let emailEnvVar = "VertexAIIntegrationAuthEmail1"
48-
static let passwordEnvVar = "VertexAIIntegrationAuthEmailPassword1"
45+
var userID1 = ""
4946

5047
override func setUp() async throws {
51-
let environment = ProcessInfo.processInfo.environment
52-
try XCTSkipIf(environment["VertexAIRunIntegrationTests"] == nil, """
53-
Vertex AI integration tests skipped; to enable them, set the VertexAIRunIntegrationTests \
54-
environment variable in Xcode or CI jobs.
55-
""")
56-
57-
let email = try XCTUnwrap(
58-
environment[IntegrationTests.emailEnvVar],
59-
"No email address specified in environment variable \(IntegrationTests.emailEnvVar)."
60-
)
61-
let password = try XCTUnwrap(
62-
environment[IntegrationTests.passwordEnvVar],
63-
"No email address specified in environment variable \(IntegrationTests.passwordEnvVar)."
48+
let authResult = try await Auth.auth().signIn(
49+
withEmail: Credentials.emailAddress1,
50+
password: Credentials.emailPassword1
6451
)
65-
66-
let authResult = try await Auth.auth().signIn(withEmail: email, password: password)
67-
userID = authResult.user.uid
52+
userID1 = authResult.user.uid
6853

6954
vertex = VertexAI.vertexAI()
7055
model = vertex.generativeModel(
@@ -149,7 +134,7 @@ final class IntegrationTests: XCTestCase {
149134
}
150135

151136
func testCountTokens_image_fileData_requiresUserAuth_userSignedIn() async throws {
152-
let storageRef = storage.reference(withPath: "vertexai/authenticated/user/\(userID)/red.webp")
137+
let storageRef = storage.reference(withPath: "vertexai/authenticated/user/\(userID1)/red.webp")
153138

154139
let fileData = FileDataPart(uri: storageRef.gsURI, mimeType: "image/webp")
155140

0 commit comments

Comments
 (0)