formula_auditor: adjust deps audit for a staging branch

1. Adjust audit so that it ignore conflicts only for `brew audit --tap`.
   This is useful because it prevents us from trying to migrate a formula
   to `openssl@3` before all its dependencies have also been migrated.
2. Exempt only PRs that target a branch called
   `openssl-migration-staging`.
This commit is contained in:
Carlo Cabrera 2023-06-20 22:36:15 +08:00
parent 9e747d8769
commit c5fe2a3559
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0
2 changed files with 10 additions and 7 deletions

View File

@ -116,7 +116,8 @@ module Homebrew
new_formula = args.new_formula?
strict = new_formula || args.strict?
online = new_formula || args.online?
skip_style = args.skip_style? || args.no_named? || args.tap
tap_audit = args.tap.present?
skip_style = args.skip_style? || args.no_named? || tap_audit
no_named_args = T.let(false, T::Boolean)
ENV.activate_extensions!
@ -202,6 +203,7 @@ module Homebrew
spdx_license_data: spdx_license_data,
spdx_exception_data: spdx_exception_data,
style_offenses: style_offenses&.for_path(f.path),
tap_audit: tap_audit,
}.compact
errors = os_arch_combinations.flat_map do |os, arch|

View File

@ -35,6 +35,7 @@ module Homebrew
@specs = %w[stable head].map { |s| formula.send(s) }.compact
@spdx_license_data = options[:spdx_license_data]
@spdx_exception_data = options[:spdx_exception_data]
@tap_audit = options[:tap_audit]
end
def audit_style
@ -345,17 +346,17 @@ module Homebrew
# TODO: remove this and check these there too.
return if Homebrew::SimulateSystem.simulating_or_running_on_linux?
# Skip the versioned dependencies conflict audit on the OpenSSL migration branch.
# Skip the versioned dependencies conflict audit for OpenSSL on the OpenSSL migration staging branch.
# TODO: Remove this when OpenSSL migration is complete.
ignore_openssl_conflict = if (github_event_path = ENV.fetch("GITHUB_EVENT_PATH", nil)).present?
ignore_openssl_conflict = if @tap_audit && (github_event_path = ENV.fetch("GITHUB_EVENT_PATH", nil)).present?
event_payload = JSON.parse(File.read(github_event_path))
head_info = event_payload.dig("pull_request", "head").to_h # handle `nil`
base_info = event_payload.dig("pull_request", "base").to_h # handle `nil`
# We need to read the head ref from `GITHUB_EVENT_PATH` because
# `git branch --show-current` returns `master` on PR branches.
openssl_migration_branch = head_info["ref"] == "openssl-migration"
homebrew_owned_repo = head_info.dig("repo", "owner", "login") == "Homebrew"
homebrew_core_pr = head_info.dig("repo", "name") == "homebrew-core"
openssl_migration_branch = base_info["ref"] == "openssl-migration-staging"
homebrew_owned_repo = base_info.dig("repo", "owner", "login") == "Homebrew"
homebrew_core_pr = base_info.dig("repo", "name") == "homebrew-core"
openssl_migration_branch && homebrew_owned_repo && homebrew_core_pr
end