Skip to content

Commit 646e6a9

Browse files
authored
Add umbrella header check on PRs (#10381)
* Revert "Include subheaders in script output (#10212)" This reverts commit 11313da. * Revert "Revert "Add new danger check (#10338)" (#10355)" This reverts commit e190b63. * Add umbrella header check again * make warning for now * fix syntax error * Test danger * syntax error * actually fix syntaax * test 2 * lose sanity * test warning resolution * remove test changes
1 parent f092647 commit 646e6a9

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

Dangerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ def hasChangesIn(paths)
2424
return false
2525
end
2626

27+
# Determine if any new files were added to paths matching any of the
28+
# path patterns provided.
29+
def hasAdditionsIn(paths)
30+
path_array = Array(paths)
31+
path_array.each do |dir|
32+
if !git.added_files.grep(/#{dir}/).empty?
33+
return true
34+
end
35+
end
36+
return false
37+
end
38+
2739
# Adds the provided labels to the current PR.
2840
def addLabels(label_array)
2941
issue_number = github.pr_json["number"]
@@ -70,6 +82,27 @@ has_changelog_changes = hasChangesIn(["CHANGELOG"])
7082
# Whether or not the LICENSE file has been modified or deleted.
7183
has_license_changes = didModify(["LICENSE"])
7284

85+
# A list of published Firebase products.
86+
@product_list = [
87+
"ABTesting",
88+
"AppCheck",
89+
"AppDistribution",
90+
"Analytics",
91+
"Authentication",
92+
"Core",
93+
"Crashlytics",
94+
"Database",
95+
"DynamicLinks",
96+
"Firestore",
97+
"Functions",
98+
"InAppMessaging",
99+
"Installations",
100+
"Messaging",
101+
"Performance",
102+
"RemoteConfig",
103+
"Storage"
104+
]
105+
73106
## Product directories
74107
@has_analytics_changes = hasChangesIn([
75108
"FirebaseAnalyticsOnDeviceConversionWrapper",
@@ -118,6 +151,10 @@ has_license_changes = didModify(["LICENSE"])
118151
@has_storage_changes = hasChangesIn("FirebaseStorage")
119152

120153
@has_releasetooling_changes = hasChangesIn("ReleaseTooling/")
154+
@has_public_additions = hasAdditionsIn("Public/")
155+
156+
@has_umbrella_changes =
157+
@product_list.reduce(false) { |accum, product| accum || hasChangesIn("Firebase#{product}.h") }
121158

122159
# Convenient flag for all API changes.
123160
@has_api_changes = @has_abtesting_api_changes ||
@@ -164,6 +201,14 @@ if has_sdk_changes
164201
end
165202
end
166203

204+
# Warn if a new public header file is added but no umbrella header changes
205+
# are detected. Prevents regression of #10301
206+
if @has_public_additions && !@has_umbrella_changes
207+
error = "New public headers were added, "\
208+
"did you remember to add them to the umbrella header?"
209+
warn(error)
210+
end
211+
167212
# Error on license edits
168213
fail("LICENSE changes are explicitly disallowed.") if has_license_changes
169214

0 commit comments

Comments
 (0)