6060 Commits

Author SHA1 Message Date
apainintheneck
6ad02b8e34 formula: internal json v3 dependencies: address feedback
- rename #dependencies_list to #internal_dependencies_hash
  - the initial implementation returned an array but now it doesn't
- simplify usage of #tap in #internal_dependencies_hash
- remove safe navigation operator usages in #internal_dependencies_hash
- better document why implicit dependencies are not included in the API JSON
- add new test fixture formula to better test generation of uses from
  macos bounds with the new internal json format
2024-04-30 23:44:25 -07:00
Mike McQuaid
fe4392dad5
Merge pull request #17190 from trail-of-forks/remove-cert-identity
Remove the signing workflow for backfill attestation checks
2024-04-30 16:13:41 +01:00
Joseph Sweeney
883c1e9907 Update attestation tests 2024-04-30 10:16:57 -04:00
Mike McQuaid
97ad3567d1
Optimise more command handling/speed
- in `brew.sh` split the `case` into those cases that take a single or
  no arguments and those that take multiple arguments or handle
  multiple commands. This considerably speeds up the
  `brew shellenv bash` case that wasn't being handled here before.
- add `setup-ruby` to the list of commands that can be called quickly
  by `brew.sh` without additional setup. This speeds up the
  `brew setup-ruby` no-op case by ~10x.
- add a parameter to `setup-ruby` to avoid running Bundler if the
  command doesn't need it. This makes many more cases for
  `brew setup-ruby` to be no-op cases.
- Remove the (now) unused `HOMEBREW_RUBY3` check in `setup-ruby`.
- Improve argument handling in `command_path.sh` to allow it to be
  used as a function in `setup-ruby.sh`.
- Add a new RuboCop to check usage of `install_bundler_gems!` is only
  inside `dev-cmd` (or a few other acceptable places).
- Use new `processed_source.file_path` API in `formula_cop.rb`
2024-04-30 12:48:29 +01:00
Mike McQuaid
4ffcd8a110
Various improvements for brew command
- Add a (large) speedup by moving some logic to Bash for the typical
  case of a normal or dev-cmd, Bash or Ruby command.
- Make `brew command` a non-developer command, I don't think it makes
  sense to consider it something needed for developing Homebrew.
- Update the manpage/tests/RBI accordingly.

Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
2024-04-30 11:38:19 +01:00
Markus Reiter
0b56d0be4a
Document Tab.for_keg and use Keg#tab where possible. 2024-04-28 20:50:13 +02:00
apainintheneck
541305ae98 Update internal json v3 formula tests 2024-04-27 18:07:54 -07:00
Carlo Cabrera
5e027bffd6
Merge pull request #17149 from alebcay/elf-expand-origin
elf: expand $ORIGIN in RUNPATH/RPATH entries
2024-04-28 01:14:54 +08:00
Mike McQuaid
af31d36295
Merge pull request #17156 from reitermarkus/unused-method
Remove unused private method.
2024-04-26 15:03:32 +01:00
Markus Reiter
7c8c75aa37
Remove unused method. 2024-04-26 12:34:50 +02:00
Caleb Xu
6ee34832d1
elf: expand $ORIGIN in RUNPATH/RPATH entries 2024-04-25 22:52:25 -04:00
Mike McQuaid
28c3215dba
analytics: support command and test-bot analytics.
These are used to analyse which commands are used and the
success/failure rate of official taps using `brew test-bot`.
2024-04-25 17:38:04 +01:00
Caleb Xu
4eb4c7a970
sandbox: enable strict typing 2024-04-24 21:56:25 -04:00
Ruoyu Zhong
916b37388d
Revert "Revert "os/linux/elf: avoid using ldd for listing dynamic dependencies"" 2024-04-24 02:23:13 +08:00
Mike McQuaid
966454c97d
Merge pull request #17125 from Homebrew/brew-list-manual-auto
cmd/list: support listing formulae installed on request or automatically
2024-04-23 09:10:37 +01:00
Ruoyu Zhong
b53998c21f
Fix tapioca compiler args test 2024-04-23 15:55:08 +08:00
Ruoyu Zhong
107b8c7ca5
test/cmd/list_spec: remove an integration test 2024-04-23 15:55:08 +08:00
Caleb Xu
934398dd9a
test: conditionally deny network access in sandbox 2024-04-22 22:39:45 -04:00
Caleb Xu
a3cfff72fd
formula_installer: conditionally deny network access in sandbox 2024-04-22 22:39:45 -04:00
Caleb Xu
7c11699d73
formula: add methods for allowing/denying network access 2024-04-22 22:39:44 -04:00
Ruoyu Zhong
15c2819849
Fix tapioca compiler args test 2024-04-22 12:25:41 +08:00
Ruoyu Zhong
868c15fe4f
cmd/list: support listing formulae installed on request or automatically
Sample usage:

    $ brew ls --manual
    gcc
    llvm
    [...]
    $ brew ls --auto
    grpc
    protobuf
    [...]
    $ brew ls --manual --auto
    gcc: manual
    grpc: auto
    llvm: manual
    protobuf: auto
    [...]

Resolves #17117.
2024-04-22 12:00:22 +08:00
Douglas Eichelberger
cb71938fff Enable strict typing in CLI::Parser 2024-04-21 14:16:25 -07:00
Daeho Ro
5680ffe2e6 add ssh://git scheme for git download strategy 2024-04-21 18:57:04 +09:00
Mike McQuaid
3c72da93b9
Merge pull request #17102 from Homebrew/only-brew-desc-search-needs-eval-all
Only `brew desc --search` needs `--eval-all`
2024-04-18 10:30:41 +01:00
Issy Long
69c31d275f
Only brew desc --search needs --eval-all
- It was suggested in https://github.com/Homebrew/brew/issues/ 16733 that
  `brew desc <formula_or_cask>` should work like `brew info <formula_or_cask>`
  and print the description of the package without needing `--eval-all`.
- Looking at the code, it seems like it's only searching that needs
  `--eval-all`, so limit the check to that.

Before:

```shell
$ brew desc hello
Error: `brew desc` needs `--eval-all` passed or `HOMEBREW_EVAL_ALL` set!
```

After:

```shell
$ brew desc hello
hello: Program providing model for GNU coding standards and practices

$ brew desc --search hello
Error: Invalid usage: `brew desc --search` needs `--eval-all` passed or `HOMEBREW_EVAL_ALL` set!

$ brew desc --search --eval-all hello
==> Formulae
dsh: Dancer's shell, or distributed shell
hello: Program providing model for GNU coding standards and practices
```
2024-04-17 23:54:45 +01:00
Issy Long
4c64193b9b
Set HOMEBREW_DEBUG when running brew tests --debug
- This will cause the "debug" gem to be required in `spec_helper.rb`, so we can do interactive debugging.
2024-04-17 23:26:40 +01:00
Issy Long
073e739005
Use the debug gem from portable Ruby
- This is cleaner than vendoring a whole bunch of new gems and pinning `psych`.
- Thanks for the pointer, Bo!
- It doesn't work, though?

```
❯ brew tests --only=migrator --debug
Error: cannot load such file -- debug/debug.so
Warning: Removed Sorbet lines from backtrace!
Rerun with `--verbose` to see the original backtrace
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/frame_info.rb:16:in `require'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/frame_info.rb:16:in `rescue in <module:DEBUGGER__>'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/frame_info.rb:13:in `<module:DEBUGGER__>'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/frame_info.rb:3:in `<top (required)>'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/session.rb:31:in `require_relative'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/session.rb:31:in `<top (required)>'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug.rb:3:in `require_relative'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug.rb:3:in `<top (required)>'
/opt/homebrew/Library/Homebrew/dev-cmd/tests.rb:48:in `require'
/opt/homebrew/Library/Homebrew/dev-cmd/tests.rb:48:in `run'
/opt/homebrew/Library/Homebrew/brew.rb:89:in `<main>'
```
2024-04-17 23:26:40 +01:00
Issy Long
f2a64f3808
Fix RuboCop and exclude psych from RBI generation 2024-04-17 22:25:12 +01:00
Issy Long
1daeb5bee0
Set up the debug gem for test debugging
- This processed that we'd requested a debugger, but didn't drop us into
  a debugging console until I
  [stopped the stdin disablement](https://github.com/Homebrew/brew/issues/16708#issuecomment-1953483970).

Usage:

```
❯ git diff
diff --git a/Library/Homebrew/test/migrator_spec.rb b/Library/Homebrew/test/migrator_spec.rb
index 87fadd5e95..db4700810a 100644
--- a/Library/Homebrew/test/migrator_spec.rb
+++ b/Library/Homebrew/test/migrator_spec.rb
@@ -69,6 +69,8 @@ RSpec.describe Migrator do
       tab.source["tap"] = "homebrew/core"
       tab.write

+      binding.break
+
       expect do
         described_class.new(new_formula, "oldname")
       end.to raise_error(Migrator::MigratorDifferentTapsError)

issyl0 at pictor in /opt/homebrew on bye-byebug
❯ brew tests --only=migrator --debug
Randomized with seed 59158
1 process for 1 spec, ~ 1 spec per process
.==> Relinking newname
.==> Unlinking oldname
...==> Moving oldname versions to /private/tmp/homebrew-tests-20240403-85464-3uogqr/cellar/newname
....==> Migrating formula oldname to newname
==> Unlinking oldname
==> Moving oldname versions to /private/tmp/homebrew-tests-20240403-85464-3uogqr/cellar/newname
==> Relinking newname
....[67, 76] in ~/migrator_spec.rb
    67|       tab = Tab.empty
    68|       tab.tabfile = HOMEBREW_CELLAR/"oldname/0.1/INSTALL_RECEIPT.json"
    69|       tab.source["tap"] = "homebrew/core"
    70|       tab.write
    71|
=>  72|       binding.break
    73|
    74|       expect do
    75|         described_class.new(new_formula, "oldname")
    76|       end.to raise_error(Migrator::MigratorDifferentTapsError)
=>#0    block in <top (required)> (3 levels) at ~/migrator_spec.rb:72
  #1    [C] BasicObject#instance_exec at /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.13.0/lib/rspec/core/example.rb:263
  # and 68 frames (use `bt' command for all frames)
(rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464) p tab
(rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464) p    # command(rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464) p     # command t    # command ta    # command tab    # command(rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464) p tab    # command
=> #<Tab:0x0000000107156be0 @aliases=[], @arch=nil, @built_as_bottle=false, @built_on={"os"=>"Macintosh", "os_version"=>"macOS 14", "cpu_family"=>"arm_firestorm_icestorm"}, @compiler=:clang, @homebrew_version="4.2.16-55-gc8f60ec-dirty", @installed_as_dependency=false, @installed_on_request=false, @loaded_from_api=false, @poured_from_bottle=false, @runtime_dependencies=nil, @source={"path"=>nil, "tap"=>"homebrew/core", "tap_git_head"=>nil, "spec"=>"stable", "versions"=>{"stable"=>nil, "head"=>nil, "version_scheme"=>0}}, @source_modified_time=0, @stdlib=nil, @tabfile=#<Pathname:/private/tmp/homebrew-tests-20240403-85464-3uogqr/cellar/oldname/0.1/INSTALL_RECEIPT.json>, @time=nil, @unused_options=[], @used_options=[]>
(rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464)
```
2024-04-17 22:25:12 +01:00
Issy Long
11c1960729
Remove byebug since it doesn't work in tests anymore
- Byebug was introduced in [2020](https://github.com/Homebrew/brew/pull/7577) for hooking into tests for debugging.
- It does not work anymore in so far as it does not stop at breakpoints when following the instructions to trigger them in tests.
2024-04-17 22:24:21 +01:00
Ruoyu Zhong
0df71ea6a3
utils/github: support globbing artifacts 2024-04-17 03:34:42 +08:00
Ruoyu Zhong
852c5acb65
Revert "os/linux/elf: avoid using ldd for listing dynamic dependencies" 2024-04-16 02:50:12 +08:00
Mike McQuaid
c44bf6f432
Merge pull request #16817 from cho-m/virtualenv-basic-resource-order-args
language/python: order args for `virtualenv_install_with_resources`
2024-04-15 08:37:08 +01:00
Michael Cho
ecb7daba58
language/python: order args for virtualenv_install_with_resources
Add `without`, `start_with`, and `end_with` to allow basic control over
the order that resources are installed so that the situations where we
have to split up `virtualenv_install_with_resources` is reduced.

Co-authored-by: Kevin <apainintheneck@gmail.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-04-14 22:21:32 -04:00
Caleb Xu
c6b98d0b8c
os/linux/ld: add functions for querying dynamic linker 2024-04-13 19:35:29 -04:00
Caleb Xu
4b0e950736
utils/path: add child_of? method 2024-04-13 19:35:29 -04:00
Mike McQuaid
c683e011b8
Merge pull request #17049 from trail-of-forks/ww/attestation
attestation: add initial attestation helpers, integrate into `brew install`
2024-04-12 15:52:51 +01:00
William Woodruff
1607d04ad2
test: add Bottle#filename test
Signed-off-by: William Woodruff <william@yossarian.net>
2024-04-12 10:41:55 -04:00
William Woodruff
faa00c8c79
handle backfilled attestation subjects correctly
Signed-off-by: William Woodruff <william@yossarian.net>
2024-04-11 16:44:57 -04:00
William Woodruff
e2b5d93198
more attestation coverage
Signed-off-by: William Woodruff <william@yossarian.net>
2024-04-11 13:39:13 -04:00
Issy Long
c72598d937
Test that EnvConfig::ENVS hash keys are alphabetical
- Spoiler: they aren't.
- As part of Volunteer Month at work I introduced `hharen` to contributing to
  Homebrew, `cd $(brew --repo)`, `brew tests`, `brew style`, etc.
- We started to write a RuboCop for this. But my current thinking is that this
  test might be sufficient since it might be easier to notice "oop, a test is
  failing and I've added a new envvar" and re-alphabetize it than to write a
  RuboCop linter for it to do the one-time autofix. Considering how little this
  gets changed?

Co-authored-by: Hana <hharen@github.com>
2024-04-11 17:58:08 +01:00
William Woodruff
480e48b75d
attestation_spec: simplify gh_executable test
Signed-off-by: William Woodruff <william@yossarian.net>
2024-04-10 18:02:56 -04:00
William Woodruff
990b7d77d6
attestation: fix a missing arg, add initial specs
Signed-off-by: William Woodruff <william@yossarian.net>
2024-04-10 17:57:01 -04:00
Mike McQuaid
1474806527
Add more HOMEBREW_FORBIDDEN_* configuration
We already had `HOMEBREW_FORBIDDEN_LICENSES` but this commit adds
`HOMEBREW_FORBIDDEN_CASKS`, `HOMEBREW_FORBIDDEN_FORMULAE` and
`HOMEBREW_FORBIDDEN_TAPS` for also forbidding those.

Relatedly, add `HOMEBREW_FORBIDDEN_OWNER` and
`HOMEBREW_FORBIDDEN_OWNER_CONTACT` to allow customising these
messages.

There were no existing tests for `HOMEBREW_FORBIDDEN_LICENSES` so have
added more tests for all of these checks.

Co-authored-by: Bo Anderson <mail@boanderson.me>
2024-04-08 16:38:32 +01:00
Douglas Eichelberger
8d1fa05530 Restrict AbstractCommand test to commands in repo 2024-04-04 09:48:17 -07:00
Kevin
044e48b816
Merge pull request #17012 from Homebrew/move-untap-module-into-cmd
cmd/untap: move module methods back into the cmd
2024-04-03 22:16:13 -07:00
apainintheneck
2d47193d22 cmd/untap: move module methods back into the cmd
The extra module was their to facilitate testing but now that
everything is properly namespaced and each command is an instance
we can just move the methods into the command. Since it's an
instance now we don't need to be as careful about caching either.
2024-04-03 22:06:19 -07:00
Douglas Eichelberger
f664433b5c Enable RSpec/DescribeClass 2024-04-03 09:12:47 -07:00
Douglas Eichelberger
8ebcadd1c9 Clean up args_parse tests 2024-04-02 12:19:14 -07:00