Skip to content

Commit c427593

Browse files
authored
fix: Address flaky dispatch (#15601)
1 parent 9e83d15 commit c427593

File tree

4 files changed

+79
-55
lines changed

4 files changed

+79
-55
lines changed

.github/workflows/common.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ on:
5252
required: false
5353
default: ""
5454

55+
# Whether the job is scheduled. Defaults to false.
56+
is_nightly:
57+
type: boolean
58+
required: false
59+
default: false
60+
5561
outputs:
5662
cache_key:
5763
description: "The cache key for the Swift package resolution."
@@ -86,6 +92,8 @@ jobs:
8692
# Run on the main repo's scheduled jobs or pull requests and manual workflow invocations.
8793
if: (github.repository == 'firebase/firebase-ios-sdk' && github.event_name == 'schedule') || contains(fromJSON('["pull_request", "workflow_dispatch"]'), github.event_name)
8894
needs: [spm-package-resolved]
95+
env:
96+
FIREBASE_IS_NIGHTLY_TESTING: ${{ inputs.is_nightly && '1' || '' }}
8997
strategy:
9098
matrix:
9199
os: [macos-15]
@@ -114,6 +122,8 @@ jobs:
114122
run: scripts/setup_spm_tests.sh
115123
- uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3
116124
if: contains(join(inputs.platforms), matrix.platform) || matrix.os == 'macos-14'
125+
env:
126+
FIREBASE_IS_NIGHTLY_TESTING: ${{ inputs.is_nightly && '1' || '' }}
117127
with:
118128
timeout_minutes: 15
119129
max_attempts: 3

.github/workflows/crashlytics.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
uses: ./.github/workflows/common.yml
3131
with:
3232
target: FirebaseCrashlyticsUnit
33+
is_nightly: ${{ github.event_name == 'schedule' }}
3334

3435
catalyst:
3536
uses: ./.github/workflows/common_catalyst.yml

Crashlytics/Crashlytics/Models/FIRCLSSettings.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,19 @@ - (NSDictionary *)loadCacheKey {
190190

191191
- (void)deleteCachedSettings {
192192
__weak FIRCLSSettings *weakSelf = self;
193+
#ifndef FIREBASE_IS_NIGHTLY_TESTING
193194
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
195+
#endif
194196
__strong FIRCLSSettings *strongSelf = weakSelf;
195197
if ([strongSelf.fileManager fileExistsAtPath:strongSelf.fileManager.settingsFilePath]) {
196198
[strongSelf.fileManager removeItemAtPath:strongSelf.fileManager.settingsFilePath];
197199
}
198200
if ([strongSelf.fileManager fileExistsAtPath:strongSelf.fileManager.settingsCacheKeyPath]) {
199201
[strongSelf.fileManager removeItemAtPath:strongSelf.fileManager.settingsCacheKeyPath];
200202
}
203+
#ifndef FIREBASE_IS_NIGHTLY_TESTING
201204
});
205+
#endif
202206

203207
@synchronized(self) {
204208
self.isCacheKeyExpired = YES;

Package.swift

Lines changed: 64 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -555,61 +555,7 @@ let package = Package(
555555
],
556556
path: "FirebaseCombineSwift/Sources/Storage"
557557
),
558-
.target(
559-
name: "FirebaseCrashlytics",
560-
dependencies: [
561-
"FirebaseCore",
562-
"FirebaseInstallations",
563-
"FirebaseSessions",
564-
"FirebaseRemoteConfigInterop",
565-
"FirebaseCrashlyticsSwift",
566-
.product(name: "GoogleDataTransport", package: "GoogleDataTransport"),
567-
.product(name: "GULEnvironment", package: "GoogleUtilities"),
568-
.product(name: "FBLPromises", package: "Promises"),
569-
.product(name: "nanopb", package: "nanopb"),
570-
],
571-
path: "Crashlytics",
572-
exclude: [
573-
"run",
574-
"CHANGELOG.md",
575-
"LICENSE",
576-
"README.md",
577-
"ProtoSupport/",
578-
"UnitTests/",
579-
"generate_project.sh",
580-
"upload-symbols",
581-
"CrashlyticsInputFiles.xcfilelist",
582-
"third_party/libunwind/LICENSE",
583-
"Crashlytics/Rollouts/",
584-
],
585-
sources: [
586-
"Crashlytics/",
587-
"Protogen/",
588-
"Shared/",
589-
"third_party/libunwind/dwarf.h",
590-
],
591-
resources: [.process("Resources/PrivacyInfo.xcprivacy")],
592-
publicHeadersPath: "Crashlytics/Public",
593-
cSettings: [
594-
.headerSearchPath(".."),
595-
.define("DISPLAY_VERSION", to: firebaseVersion),
596-
.define("CLS_SDK_NAME", to: "Crashlytics iOS SDK", .when(platforms: [.iOS])),
597-
.define(
598-
"CLS_SDK_NAME",
599-
to: "Crashlytics macOS SDK",
600-
.when(platforms: [.macOS, .macCatalyst])
601-
),
602-
.define("CLS_SDK_NAME", to: "Crashlytics tvOS SDK", .when(platforms: [.tvOS])),
603-
.define("CLS_SDK_NAME", to: "Crashlytics watchOS SDK", .when(platforms: [.watchOS])),
604-
.define("PB_FIELD_32BIT", to: "1"),
605-
.define("PB_NO_PACKED_STRUCTS", to: "1"),
606-
.define("PB_ENABLE_MALLOC", to: "1"),
607-
],
608-
linkerSettings: [
609-
.linkedFramework("Security"),
610-
.linkedFramework("SystemConfiguration", .when(platforms: [.iOS, .macOS, .tvOS])),
611-
]
612-
),
558+
firebaseCrashlyticsTarget(),
613559
.target(
614560
name: "FirebaseCrashlyticsSwift",
615561
dependencies: ["FirebaseRemoteConfigInterop"],
@@ -1402,6 +1348,69 @@ let package = Package(
14021348

14031349
// MARK: - Helper Functions
14041350

1351+
func firebaseCrashlyticsTarget() -> Target {
1352+
var cSettings: [CSetting] = [
1353+
.headerSearchPath(".."),
1354+
.define("DISPLAY_VERSION", to: firebaseVersion),
1355+
.define("CLS_SDK_NAME", to: "Crashlytics iOS SDK", .when(platforms: [.iOS])),
1356+
.define(
1357+
"CLS_SDK_NAME", to: "Crashlytics macOS SDK",
1358+
.when(platforms: [.macOS, .macCatalyst])
1359+
),
1360+
.define("CLS_SDK_NAME", to: "Crashlytics tvOS SDK", .when(platforms: [.tvOS])),
1361+
.define("CLS_SDK_NAME", to: "Crashlytics watchOS SDK", .when(platforms: [.watchOS])),
1362+
.define("PB_FIELD_32BIT", to: "1"),
1363+
.define("PB_NO_PACKED_STRUCTS", to: "1"),
1364+
.define("PB_ENABLE_MALLOC", to: "1"),
1365+
]
1366+
1367+
if Context.environment["FIREBASE_IS_NIGHTLY_TESTING"] != nil {
1368+
cSettings += [.define("FIREBASE_IS_NIGHTLY_TESTING", to: "1")]
1369+
}
1370+
1371+
return .target(
1372+
name: "FirebaseCrashlytics",
1373+
dependencies: [
1374+
"FirebaseCore",
1375+
"FirebaseInstallations",
1376+
"FirebaseSessions",
1377+
"FirebaseRemoteConfigInterop",
1378+
"FirebaseCrashlyticsSwift",
1379+
.product(name: "GoogleDataTransport", package: "GoogleDataTransport"),
1380+
.product(name: "GULEnvironment", package: "GoogleUtilities"),
1381+
.product(name: "FBLPromises", package: "Promises"),
1382+
.product(name: "nanopb", package: "nanopb"),
1383+
],
1384+
path: "Crashlytics",
1385+
exclude: [
1386+
"run",
1387+
"CHANGELOG.md",
1388+
"LICENSE",
1389+
"README.md",
1390+
"ProtoSupport/",
1391+
"UnitTests/",
1392+
"generate_project.sh",
1393+
"upload-symbols",
1394+
"CrashlyticsInputFiles.xcfilelist",
1395+
"third_party/libunwind/LICENSE",
1396+
"Crashlytics/Rollouts/",
1397+
],
1398+
sources: [
1399+
"Crashlytics/",
1400+
"Protogen/",
1401+
"Shared/",
1402+
"third_party/libunwind/dwarf.h",
1403+
],
1404+
resources: [.process("Resources/PrivacyInfo.xcprivacy")],
1405+
publicHeadersPath: "Crashlytics/Public",
1406+
cSettings: cSettings,
1407+
linkerSettings: [
1408+
.linkedFramework("Security"),
1409+
.linkedFramework("SystemConfiguration", .when(platforms: [.iOS, .macOS, .tvOS])),
1410+
]
1411+
)
1412+
}
1413+
14051414
func googleAppMeasurementDependency() -> Package.Dependency {
14061415
let appMeasurementURL = "https://github.com/google/GoogleAppMeasurement.git"
14071416

0 commit comments

Comments
 (0)