diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 5ae56f7..44cefe6 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: '3.11' - name: Cache Mint packages uses: actions/cache@v4 @@ -32,11 +32,7 @@ jobs: run: ./setup-scripts.sh - name: Setup check - run: | - brew update - brew install clang-format@19 - brew install mint - mint bootstrap + run: scripts/setup_check.sh - name: Style run: scripts/style.sh test-only diff --git a/.github/workflows/spm.yml b/.github/workflows/spm.yml index 34acac4..6177753 100644 --- a/.github/workflows/spm.yml +++ b/.github/workflows/spm.yml @@ -30,7 +30,6 @@ jobs: env: FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1 FIREBASE_MAIN: 1 - DISABLE_INTEGRATION_TESTS: 1 steps: - uses: actions/checkout@v4 - name: Generate Swift Package.resolved @@ -54,15 +53,14 @@ jobs: strategy: matrix: - os: [macos-14] + os: [macos-15] # GitHub actions' runners do not include visionOS. https://github.com/actions/runner-images/issues/10559 - target: [iOS, tvOS, macOS, catalyst] - xcode: [Xcode_15.2, Xcode_15.4, Xcode_16] + target: [iOS, macOS, tvOS, catalyst] + xcode: [Xcode_16.2] runs-on: ${{ matrix.os }} env: FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1 FIREBASE_MAIN: 1 - DISABLE_INTEGRATION_TESTS: 1 steps: - uses: actions/checkout@v4 - uses: actions/cache/restore@v4 @@ -73,5 +71,9 @@ jobs: run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer - name: Setup Scripts Directory run: ./setup-scripts.sh - - name: Unit Tests - run: scripts/third_party/travis/retry.sh scripts/build.sh FirebaseDataConnect ${{ matrix.target }} spm + - name: Install iOS Platform + run: xcodebuild -downloadPlatform iOS + - name: Integration Test Setup + run: Tests/Integration/Emulator/start-emulator.sh + - name: Unit and Integration Tests + run: scripts/third_party/travis/retry.sh ./scripts/build.sh FirebaseDataConnect ${{ matrix.target }} spm diff --git a/Tests/Integration/Emulator/start-emulator.sh b/Tests/Integration/Emulator/start-emulator.sh new file mode 100755 index 0000000..ab10f79 --- /dev/null +++ b/Tests/Integration/Emulator/start-emulator.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# Copyright 2025 Google LLC +# +# Licensed 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. + +# Sets up Firebase Data Connect emulator to execute +# integration tests. + +set -e + +# Get the absolute path to the directory containing this script. +SCRIPT_DIR="$(cd $(dirname ${BASH_SOURCE[0]}) && pwd)" +TEMP_DIR="$(mktemp -d -t firebase-data-connect)" +echo "Starting Firebase Data Connect emulator in ${TEMP_DIR}" +cd "${TEMP_DIR}" + +EMULATOR_VERSION="1.8.3" +EMULATOR_FILENAME="dataconnect-emulator-macos-v${EMULATOR_VERSION}" +EMULATOR_URL="https://storage.googleapis.com/firemat-preview-drop/emulator/${EMULATOR_FILENAME}" +echo "Downloading emulator from ${EMULATOR_URL}" + +curl -o "${EMULATOR_FILENAME}" "${EMULATOR_URL}" + +chmod 755 "${EMULATOR_FILENAME}" + +./${EMULATOR_FILENAME} --logtostderr dev --listen="127.0.0.1:3628" & diff --git a/Tests/Integration/IntegrationTestBase.swift b/Tests/Integration/IntegrationTestBase.swift index ca2faed..ff18989 100644 --- a/Tests/Integration/IntegrationTestBase.swift +++ b/Tests/Integration/IntegrationTestBase.swift @@ -37,8 +37,10 @@ class IntegrationTestBase: XCTestCase { ) override class func setUp() { - FirebaseApp.configure(options: options) - defaultApp = FirebaseApp.app() + if defaultApp == nil { + FirebaseApp.configure(options: options) + defaultApp = FirebaseApp.app() + } DataConnect.kitchenSinkConnector.useEmulator(port: 3628) } } diff --git a/Tests/Unit/InstanceTests.swift b/Tests/Unit/InstanceTests.swift index 2ebf1dd..b49db12 100644 --- a/Tests/Unit/InstanceTests.swift +++ b/Tests/Unit/InstanceTests.swift @@ -19,8 +19,15 @@ import XCTest @available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) class InstanceTests: XCTestCase { - static var defaultApp: FirebaseApp? - static var appTwo: FirebaseApp? + static var defaultApp: FirebaseApp? = { + FirebaseApp.configure(options: options) + return FirebaseApp.app() + }() + + static var appTwo: FirebaseApp? = { + FirebaseApp.configure(name: "app-two", options: optionsTwo) + return FirebaseApp.app(name: "app-two") + }() static var options: FirebaseOptions = { let options = FirebaseOptions(googleAppID: "0:0000000000000:ios:0000000000000000", @@ -51,14 +58,6 @@ class InstanceTests: XCTestCase { connector: "blogs" ) - override class func setUp() { - FirebaseApp.configure(options: options) - defaultApp = FirebaseApp.app() - - FirebaseApp.configure(name: "app-two", options: optionsTwo) - appTwo = FirebaseApp.app(name: "app-two") - } - // same connector config, same app, instance returned should be same func testSameInstance() throws { let dcOne = DataConnect.dataConnect(connectorConfig: fakeConnectorConfigOne)