Quellcode durchsuchen

Add umbrella header check on PRs (#10381)

* Revert "Include subheaders in script output (#10212)"

This reverts commit 11313da887c7290d1ed3318695a9350f3d4185b5.

* Revert "Revert "Add new danger check (#10338)" (#10355)"

This reverts commit e190b63a93e6d52cea7a542d8d9668088889e3a1.

* 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
Morgan Chen vor 3 Jahren
Ursprung
Commit
646e6a9efc
1 geänderte Dateien mit 45 neuen und 0 gelöschten Zeilen
  1. 45 0
      Dangerfile

+ 45 - 0
Dangerfile

@@ -24,6 +24,18 @@ def hasChangesIn(paths)
   return false
 end
 
+# Determine if any new files were added to paths matching any of the
+# path patterns provided.
+def hasAdditionsIn(paths)
+  path_array = Array(paths)
+  path_array.each do |dir|
+    if !git.added_files.grep(/#{dir}/).empty?
+      return true
+    end
+  end
+  return false
+end
+
 # Adds the provided labels to the current PR.
 def addLabels(label_array)
   issue_number = github.pr_json["number"]
@@ -70,6 +82,27 @@ has_changelog_changes = hasChangesIn(["CHANGELOG"])
 # Whether or not the LICENSE file has been modified or deleted.
 has_license_changes = didModify(["LICENSE"])
 
+# A list of published Firebase products.
+@product_list = [
+  "ABTesting",
+  "AppCheck",
+  "AppDistribution",
+  "Analytics",
+  "Authentication",
+  "Core",
+  "Crashlytics",
+  "Database",
+  "DynamicLinks",
+  "Firestore",
+  "Functions",
+  "InAppMessaging",
+  "Installations",
+  "Messaging",
+  "Performance",
+  "RemoteConfig",
+  "Storage"
+]
+
 ## Product directories
 @has_analytics_changes = hasChangesIn([
   "FirebaseAnalyticsOnDeviceConversionWrapper",
@@ -118,6 +151,10 @@ has_license_changes = didModify(["LICENSE"])
 @has_storage_changes = hasChangesIn("FirebaseStorage")
 
 @has_releasetooling_changes = hasChangesIn("ReleaseTooling/")
+@has_public_additions = hasAdditionsIn("Public/")
+
+@has_umbrella_changes =
+    @product_list.reduce(false) { |accum, product| accum || hasChangesIn("Firebase#{product}.h") }
 
 # Convenient flag for all API changes.
 @has_api_changes = @has_abtesting_api_changes ||
@@ -164,6 +201,14 @@ if has_sdk_changes
   end
 end
 
+# Warn if a new public header file is added but no umbrella header changes
+# are detected. Prevents regression of #10301
+if @has_public_additions && !@has_umbrella_changes
+  error = "New public headers were added, "\
+      "did you remember to add them to the umbrella header?"
+  warn(error)
+end
+
 # Error on license edits
 fail("LICENSE changes are explicitly disallowed.") if has_license_changes