Skip to content

Commit

Permalink
Add umbrella header check on PRs (#10381)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
morganchen12 authored Oct 20, 2022
1 parent f092647 commit 646e6a9
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 ||
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 646e6a9

Please sign in to comment.