From c5fe2a35591e1ab0e0519f97ba2115edce418f54 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Tue, 20 Jun 2023 22:36:15 +0800 Subject: [PATCH] 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`. --- Library/Homebrew/dev-cmd/audit.rb | 4 +++- Library/Homebrew/formula_auditor.rb | 13 +++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index f8b33517aa..73a529d874 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -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| diff --git a/Library/Homebrew/formula_auditor.rb b/Library/Homebrew/formula_auditor.rb index b4250e2a0a..fead654e14 100644 --- a/Library/Homebrew/formula_auditor.rb +++ b/Library/Homebrew/formula_auditor.rb @@ -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