Skip to content

Commit 5f22050

Browse files
Enable Integration Tests in Git (#43)
Co-authored-by: Nick Cooke <36927374+ncooke3@users.noreply.github.com>
1 parent 3cb987e commit 5f22050

File tree

5 files changed

+61
-25
lines changed

5 files changed

+61
-25
lines changed

.github/workflows/check.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
- uses: actions/setup-python@v5
2121
with:
22-
python-version: '3.10'
22+
python-version: '3.11'
2323

2424
- name: Cache Mint packages
2525
uses: actions/cache@v4
@@ -32,11 +32,7 @@ jobs:
3232
run: ./setup-scripts.sh
3333

3434
- name: Setup check
35-
run: |
36-
brew update
37-
brew install clang-format@19
38-
brew install mint
39-
mint bootstrap
35+
run: scripts/setup_check.sh
4036

4137
- name: Style
4238
run: scripts/style.sh test-only

.github/workflows/spm.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ jobs:
3030
env:
3131
FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1
3232
FIREBASE_MAIN: 1
33-
DISABLE_INTEGRATION_TESTS: 1
3433
steps:
3534
- uses: actions/checkout@v4
3635
- name: Generate Swift Package.resolved
@@ -54,15 +53,14 @@ jobs:
5453

5554
strategy:
5655
matrix:
57-
os: [macos-14]
56+
os: [macos-15]
5857
# GitHub actions' runners do not include visionOS. https://github.com/actions/runner-images/issues/10559
59-
target: [iOS, tvOS, macOS, catalyst]
60-
xcode: [Xcode_15.2, Xcode_15.4, Xcode_16]
58+
target: [iOS, macOS, tvOS, catalyst]
59+
xcode: [Xcode_16.2]
6160
runs-on: ${{ matrix.os }}
6261
env:
6362
FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1
6463
FIREBASE_MAIN: 1
65-
DISABLE_INTEGRATION_TESTS: 1
6664
steps:
6765
- uses: actions/checkout@v4
6866
- uses: actions/cache/restore@v4
@@ -73,5 +71,9 @@ jobs:
7371
run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer
7472
- name: Setup Scripts Directory
7573
run: ./setup-scripts.sh
76-
- name: Unit Tests
77-
run: scripts/third_party/travis/retry.sh scripts/build.sh FirebaseDataConnect ${{ matrix.target }} spm
74+
- name: Install iOS Platform
75+
run: xcodebuild -downloadPlatform iOS
76+
- name: Integration Test Setup
77+
run: Tests/Integration/Emulator/start-emulator.sh
78+
- name: Unit and Integration Tests
79+
run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseDataConnect ${{ matrix.target }} spm
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2025 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Sets up Firebase Data Connect emulator to execute
18+
# integration tests.
19+
20+
set -e
21+
22+
# Get the absolute path to the directory containing this script.
23+
SCRIPT_DIR="$(cd $(dirname ${BASH_SOURCE[0]}) && pwd)"
24+
TEMP_DIR="$(mktemp -d -t firebase-data-connect)"
25+
echo "Starting Firebase Data Connect emulator in ${TEMP_DIR}"
26+
cd "${TEMP_DIR}"
27+
28+
EMULATOR_VERSION="1.8.3"
29+
EMULATOR_FILENAME="dataconnect-emulator-macos-v${EMULATOR_VERSION}"
30+
EMULATOR_URL="https://storage.googleapis.com/firemat-preview-drop/emulator/${EMULATOR_FILENAME}"
31+
echo "Downloading emulator from ${EMULATOR_URL}"
32+
33+
curl -o "${EMULATOR_FILENAME}" "${EMULATOR_URL}"
34+
35+
chmod 755 "${EMULATOR_FILENAME}"
36+
37+
./${EMULATOR_FILENAME} --logtostderr dev --listen="127.0.0.1:3628" &

Tests/Integration/IntegrationTestBase.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ class IntegrationTestBase: XCTestCase {
3737
)
3838

3939
override class func setUp() {
40-
FirebaseApp.configure(options: options)
41-
defaultApp = FirebaseApp.app()
40+
if defaultApp == nil {
41+
FirebaseApp.configure(options: options)
42+
defaultApp = FirebaseApp.app()
43+
}
4244
DataConnect.kitchenSinkConnector.useEmulator(port: 3628)
4345
}
4446
}

Tests/Unit/InstanceTests.swift

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,15 @@ import XCTest
1919

2020
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
2121
class InstanceTests: XCTestCase {
22-
static var defaultApp: FirebaseApp?
23-
static var appTwo: FirebaseApp?
22+
static var defaultApp: FirebaseApp? = {
23+
FirebaseApp.configure(options: options)
24+
return FirebaseApp.app()
25+
}()
26+
27+
static var appTwo: FirebaseApp? = {
28+
FirebaseApp.configure(name: "app-two", options: optionsTwo)
29+
return FirebaseApp.app(name: "app-two")
30+
}()
2431

2532
static var options: FirebaseOptions = {
2633
let options = FirebaseOptions(googleAppID: "0:0000000000000:ios:0000000000000000",
@@ -51,14 +58,6 @@ class InstanceTests: XCTestCase {
5158
connector: "blogs"
5259
)
5360

54-
override class func setUp() {
55-
FirebaseApp.configure(options: options)
56-
defaultApp = FirebaseApp.app()
57-
58-
FirebaseApp.configure(name: "app-two", options: optionsTwo)
59-
appTwo = FirebaseApp.app(name: "app-two")
60-
}
61-
6261
// same connector config, same app, instance returned should be same
6362
func testSameInstance() throws {
6463
let dcOne = DataConnect.dataConnect(connectorConfig: fakeConnectorConfigOne)

0 commit comments

Comments
 (0)