Merge pull request #15470 from reitermarkus/readall-os-arch

Add `--os` and `--arch` flags to `readall`.
This commit is contained in:
Markus Reiter 2023-05-24 23:06:43 +02:00 committed by GitHub
commit cc8025d16e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 8 deletions

View File

@ -148,7 +148,7 @@ jobs:
run: brew tap homebrew/core run: brew tap homebrew/core
- name: Run brew readall on homebrew/core - name: Run brew readall on homebrew/core
run: brew readall --aliases homebrew/core run: brew readall --os=all --arch=all --aliases homebrew/core
- name: Run brew audit --skip-style on homebrew/core - name: Run brew audit --skip-style on homebrew/core
run: brew audit --skip-style --except=version --tap=homebrew/core run: brew audit --skip-style --except=version --tap=homebrew/core
@ -186,7 +186,7 @@ jobs:
brew tap homebrew/cask-versions brew tap homebrew/cask-versions
- name: Run brew readall on all casks - name: Run brew readall on all casks
run: brew readall homebrew/cask homebrew/cask-drivers homebrew/cask-fonts homebrew/cask-versions run: brew readall --os=all --arch=all homebrew/cask homebrew/cask-drivers homebrew/cask-fonts homebrew/cask-versions
- name: Run brew audit --skip-style on casks - name: Run brew audit --skip-style on casks
run: | run: |

View File

@ -17,6 +17,10 @@ module Homebrew
significant changes to `formula.rb`, testing the performance of loading significant changes to `formula.rb`, testing the performance of loading
all items or checking if any current formulae/casks have Ruby issues. all items or checking if any current formulae/casks have Ruby issues.
EOS EOS
flag "--os=",
description: "Read using the given operating system. (Pass `all` to simulate all operating systems.)"
flag "--arch=",
description: "Read using the given CPU architecture. (Pass `all` to simulate all architectures.)"
switch "--aliases", switch "--aliases",
description: "Verify any alias symlinks in each tap." description: "Verify any alias symlinks in each tap."
switch "--syntax", switch "--syntax",
@ -34,6 +38,10 @@ module Homebrew
def readall def readall
args = readall_args.parse args = readall_args.parse
if args.no_simulate?
# odeprecated "--no-simulate", "nothing (i.e. not passing `--os` or `--arch`)"
end
if args.syntax? && args.no_named? if args.syntax? && args.no_named?
scan_files = "#{HOMEBREW_LIBRARY_PATH}/**/*.rb" scan_files = "#{HOMEBREW_LIBRARY_PATH}/**/*.rb"
ruby_files = Dir.glob(scan_files).grep_v(%r{/(vendor)/}) ruby_files = Dir.glob(scan_files).grep_v(%r{/(vendor)/})
@ -41,7 +49,12 @@ module Homebrew
Homebrew.failed = true unless Readall.valid_ruby_syntax?(ruby_files) Homebrew.failed = true unless Readall.valid_ruby_syntax?(ruby_files)
end end
options = { aliases: args.aliases?, no_simulate: args.no_simulate? } options = {
aliases: args.aliases?,
no_simulate: args.no_simulate?,
}
# TODO: Always pass this once `--os` and `--arch` are passed explicitly to `brew readall` in CI.
options[:os_arch_combinations] = args.os_arch_combinations if args.os || args.arch
taps = if args.no_named? taps = if args.no_named?
if !args.eval_all? && !Homebrew::EnvConfig.eval_all? if !args.eval_all? && !Homebrew::EnvConfig.eval_all?
odisabled "brew readall", "brew readall --eval-all or HOMEBREW_EVAL_ALL" odisabled "brew readall", "brew readall --eval-all or HOMEBREW_EVAL_ALL"

View File

@ -66,19 +66,21 @@ module Readall
true true
end end
def valid_tap?(tap, options = {}) def valid_tap?(tap, aliases: false, no_simulate: false, os_arch_combinations: nil)
success = true success = true
if options[:aliases] if aliases
valid_aliases = valid_aliases?(tap.alias_dir, tap.formula_dir) valid_aliases = valid_aliases?(tap.alias_dir, tap.formula_dir)
success = false unless valid_aliases success = false unless valid_aliases
end end
if options[:no_simulate] if no_simulate
success = false unless valid_formulae?(tap.formula_files) success = false unless valid_formulae?(tap.formula_files)
success = false unless valid_casks?(tap.cask_files) success = false unless valid_casks?(tap.cask_files)
else else
os_names = [*MacOSVersion::SYMBOLS.keys, :linux] # TODO: Remove this default case once `--os` and `--arch` are passed explicitly to `brew readall` in CI.
os_names.product(OnSystem::ARCH_OPTIONS).each do |os, arch| os_arch_combinations ||= [*MacOSVersion::SYMBOLS.keys, :linux].product(OnSystem::ARCH_OPTIONS)
os_arch_combinations.each do |os, arch|
bottle_tag = Utils::Bottles::Tag.new(system: os, arch: arch) bottle_tag = Utils::Bottles::Tag.new(system: os, arch: arch)
next unless bottle_tag.valid_combination? next unless bottle_tag.valid_combination?