diff --git a/.github/workflows/common.yml b/.github/workflows/common.yml index 4af29b0f68b..052d6e8d1c3 100644 --- a/.github/workflows/common.yml +++ b/.github/workflows/common.yml @@ -52,6 +52,12 @@ on: required: false default: "" + # Whether the job is scheduled. Defaults to false. + is_nightly: + type: boolean + required: false + default: false + outputs: cache_key: description: "The cache key for the Swift package resolution." @@ -86,6 +92,8 @@ jobs: # Run on the main repo's scheduled jobs or pull requests and manual workflow invocations. if: (github.repository == 'firebase/firebase-ios-sdk' && github.event_name == 'schedule') || contains(fromJSON('["pull_request", "workflow_dispatch"]'), github.event_name) needs: [spm-package-resolved] + env: + FIREBASE_IS_NIGHTLY_TESTING: ${{ inputs.is_nightly && '1' || '' }} strategy: matrix: os: [macos-15] @@ -114,6 +122,8 @@ jobs: run: scripts/setup_spm_tests.sh - uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3 if: contains(join(inputs.platforms), matrix.platform) || matrix.os == 'macos-14' + env: + FIREBASE_IS_NIGHTLY_TESTING: ${{ inputs.is_nightly && '1' || '' }} with: timeout_minutes: 15 max_attempts: 3 diff --git a/.github/workflows/crashlytics.yml b/.github/workflows/crashlytics.yml index 3969c1eb223..341da63a063 100644 --- a/.github/workflows/crashlytics.yml +++ b/.github/workflows/crashlytics.yml @@ -30,6 +30,7 @@ jobs: uses: ./.github/workflows/common.yml with: target: FirebaseCrashlyticsUnit + is_nightly: ${{ github.event_name == 'schedule' }} catalyst: uses: ./.github/workflows/common_catalyst.yml diff --git a/Crashlytics/Crashlytics/Models/FIRCLSSettings.m b/Crashlytics/Crashlytics/Models/FIRCLSSettings.m index 758772e5b8d..80c70a48953 100644 --- a/Crashlytics/Crashlytics/Models/FIRCLSSettings.m +++ b/Crashlytics/Crashlytics/Models/FIRCLSSettings.m @@ -190,7 +190,9 @@ - (NSDictionary *)loadCacheKey { - (void)deleteCachedSettings { __weak FIRCLSSettings *weakSelf = self; +#ifndef FIREBASE_IS_NIGHTLY_TESTING dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ +#endif __strong FIRCLSSettings *strongSelf = weakSelf; if ([strongSelf.fileManager fileExistsAtPath:strongSelf.fileManager.settingsFilePath]) { [strongSelf.fileManager removeItemAtPath:strongSelf.fileManager.settingsFilePath]; @@ -198,7 +200,9 @@ - (void)deleteCachedSettings { if ([strongSelf.fileManager fileExistsAtPath:strongSelf.fileManager.settingsCacheKeyPath]) { [strongSelf.fileManager removeItemAtPath:strongSelf.fileManager.settingsCacheKeyPath]; } +#ifndef FIREBASE_IS_NIGHTLY_TESTING }); +#endif @synchronized(self) { self.isCacheKeyExpired = YES; diff --git a/Package.swift b/Package.swift index 4e2502a8586..de5871e591a 100644 --- a/Package.swift +++ b/Package.swift @@ -555,61 +555,7 @@ let package = Package( ], path: "FirebaseCombineSwift/Sources/Storage" ), - .target( - name: "FirebaseCrashlytics", - dependencies: [ - "FirebaseCore", - "FirebaseInstallations", - "FirebaseSessions", - "FirebaseRemoteConfigInterop", - "FirebaseCrashlyticsSwift", - .product(name: "GoogleDataTransport", package: "GoogleDataTransport"), - .product(name: "GULEnvironment", package: "GoogleUtilities"), - .product(name: "FBLPromises", package: "Promises"), - .product(name: "nanopb", package: "nanopb"), - ], - path: "Crashlytics", - exclude: [ - "run", - "CHANGELOG.md", - "LICENSE", - "README.md", - "ProtoSupport/", - "UnitTests/", - "generate_project.sh", - "upload-symbols", - "CrashlyticsInputFiles.xcfilelist", - "third_party/libunwind/LICENSE", - "Crashlytics/Rollouts/", - ], - sources: [ - "Crashlytics/", - "Protogen/", - "Shared/", - "third_party/libunwind/dwarf.h", - ], - resources: [.process("Resources/PrivacyInfo.xcprivacy")], - publicHeadersPath: "Crashlytics/Public", - cSettings: [ - .headerSearchPath(".."), - .define("DISPLAY_VERSION", to: firebaseVersion), - .define("CLS_SDK_NAME", to: "Crashlytics iOS SDK", .when(platforms: [.iOS])), - .define( - "CLS_SDK_NAME", - to: "Crashlytics macOS SDK", - .when(platforms: [.macOS, .macCatalyst]) - ), - .define("CLS_SDK_NAME", to: "Crashlytics tvOS SDK", .when(platforms: [.tvOS])), - .define("CLS_SDK_NAME", to: "Crashlytics watchOS SDK", .when(platforms: [.watchOS])), - .define("PB_FIELD_32BIT", to: "1"), - .define("PB_NO_PACKED_STRUCTS", to: "1"), - .define("PB_ENABLE_MALLOC", to: "1"), - ], - linkerSettings: [ - .linkedFramework("Security"), - .linkedFramework("SystemConfiguration", .when(platforms: [.iOS, .macOS, .tvOS])), - ] - ), + firebaseCrashlyticsTarget(), .target( name: "FirebaseCrashlyticsSwift", dependencies: ["FirebaseRemoteConfigInterop"], @@ -1402,6 +1348,69 @@ let package = Package( // MARK: - Helper Functions +func firebaseCrashlyticsTarget() -> Target { + var cSettings: [CSetting] = [ + .headerSearchPath(".."), + .define("DISPLAY_VERSION", to: firebaseVersion), + .define("CLS_SDK_NAME", to: "Crashlytics iOS SDK", .when(platforms: [.iOS])), + .define( + "CLS_SDK_NAME", to: "Crashlytics macOS SDK", + .when(platforms: [.macOS, .macCatalyst]) + ), + .define("CLS_SDK_NAME", to: "Crashlytics tvOS SDK", .when(platforms: [.tvOS])), + .define("CLS_SDK_NAME", to: "Crashlytics watchOS SDK", .when(platforms: [.watchOS])), + .define("PB_FIELD_32BIT", to: "1"), + .define("PB_NO_PACKED_STRUCTS", to: "1"), + .define("PB_ENABLE_MALLOC", to: "1"), + ] + + if Context.environment["FIREBASE_IS_NIGHTLY_TESTING"] != nil { + cSettings += [.define("FIREBASE_IS_NIGHTLY_TESTING", to: "1")] + } + + return .target( + name: "FirebaseCrashlytics", + dependencies: [ + "FirebaseCore", + "FirebaseInstallations", + "FirebaseSessions", + "FirebaseRemoteConfigInterop", + "FirebaseCrashlyticsSwift", + .product(name: "GoogleDataTransport", package: "GoogleDataTransport"), + .product(name: "GULEnvironment", package: "GoogleUtilities"), + .product(name: "FBLPromises", package: "Promises"), + .product(name: "nanopb", package: "nanopb"), + ], + path: "Crashlytics", + exclude: [ + "run", + "CHANGELOG.md", + "LICENSE", + "README.md", + "ProtoSupport/", + "UnitTests/", + "generate_project.sh", + "upload-symbols", + "CrashlyticsInputFiles.xcfilelist", + "third_party/libunwind/LICENSE", + "Crashlytics/Rollouts/", + ], + sources: [ + "Crashlytics/", + "Protogen/", + "Shared/", + "third_party/libunwind/dwarf.h", + ], + resources: [.process("Resources/PrivacyInfo.xcprivacy")], + publicHeadersPath: "Crashlytics/Public", + cSettings: cSettings, + linkerSettings: [ + .linkedFramework("Security"), + .linkedFramework("SystemConfiguration", .when(platforms: [.iOS, .macOS, .tvOS])), + ] + ) +} + func googleAppMeasurementDependency() -> Package.Dependency { let appMeasurementURL = "https://github.com/google/GoogleAppMeasurement.git"