6060 Commits

Author SHA1 Message Date
Mike McQuaid
89d1d6b8f4
Merge pull request #19359 from Homebrew/no-attr_rw
refactor: inline use of attr_rw
2025-02-24 09:02:02 +00:00
Mike McQuaid
b9eff75108
Merge pull request #19351 from Homebrew/livecheck/refactor-livecheck_strategy_names
livecheck: refactor livecheck_strategy_names
2025-02-24 08:59:51 +00:00
Douglas Eichelberger
3ef22f3181
Inline use of attr_rw 2025-02-23 13:18:49 -08:00
Sam Ford
5e57df7287
livecheck: restrict POST hashes to symbol keys
I initially set the type for livecheck's `post_form` and `post_json`
hashes to allow either a string or symbol key. I used string keys in
the documentation, as there will inevitably be some form field names
that would pose a problem for symbols (e.g., `E-mail` uses a hyphen,
`1twothree` starts with a digit, etc.). However, I remembered that we
can simply use quote symbols like `:"E-mail"` to handle these
situations, as they have the flexibility of a string while still being
a symbol.

With that in mind, this updates related type signatures to only allow
symbol keys and updates documentation and tests accordingly. The
documentation example contains a hyphenated form field, so it
demonstrates how to handle names that don't work as a bare symbol.
2025-02-21 21:54:46 -05:00
Sam Ford
efeff905eb
livecheck: refactor livecheck_strategy_names
This refactors the `livecheck_strategy_names` method to align with
Doug's `livecheck_find_versions_parameters` implementation.
2025-02-21 20:24:28 -05:00
Douglas Eichelberger
cf635bc28a
Merge pull request #19314 from Homebrew/typed-dep-helpers
Enable strict typing in DependenciesHelpers
2025-02-18 18:47:06 +00:00
Nanda H Krishna
1f9cc89926
test/rubocops/text: update assert tests 2025-02-18 10:52:32 -05:00
Rylan Polster
f874603a21 Add implicit macOS dependency to casks without explicit depends_on stanza 2025-02-17 14:30:44 +01:00
Douglas Eichelberger
0037b1f626 Enable strict typing in DependenciesHelpers 2025-02-16 12:24:22 -08:00
Mike McQuaid
6f99704a64
Import brew formula-analytics and generate-analytics-api commands
Import these from the homebrew/formula-analytics tap and deprecate
that tap.

This required a little messing around with filenames and paths to get
it finding Python and writing to the user's home directory.
2025-02-07 20:05:05 +00:00
Mike McQuaid
5ae29d324d
Merge pull request #19258 from Homebrew/brew_alias_import
Import `brew alias` and `brew unalias` commands
2025-02-07 19:32:14 +00:00
Mike McQuaid
8adc188992
Import brew alias and brew unalias commands
Import these from the homebrew/aliases tap and deprecate that tap.

This required a little messing around with class/module/constant names
to get `brew tests` and `brew typecheck` to play nicely.

I added also added Sorbet type signatures and integration tests.
2025-02-07 14:31:50 +00:00
Sam Ford
8997cccddf
Livecheck: Expand test coverage
This brings line coverage for the `Livecheck` DSL back to 100%, as we
had evidently overlooked part of the `#strategy` method.
2025-02-07 08:57:33 -05:00
Sam Ford
2187316262
Strategy: Expand test coverage
Between this commit and the previous one, this brings test coverage
for `Livecheck::Strategy` up to 98.18% line coverage and 97.22%
branch coverage. The only uncovered areas are some Sorbet `params`
calls (which I'm not sure how to cover) and a conditional `break` in
`page_headers` that will be refactored away in the future.

The increased coverage is primarily in areas that weren't covered
before because they call methods that make network requests. I worked
around this with stubs and doubles, so we can test this code to some
degree. I plan to expand this approach to other areas in livecheck
that aren't covered for the same reason and that should significantly
increase test coverage (along with some other test improvements that
I have lined up).
2025-02-07 08:57:32 -05:00
Sam Ford
b4757af656
livecheck: Add support for POST requests
livecheck currently doesn't support `POST` requests but it wasn't
entirely clear how best to handle that. I initially approached it as
a `Post` strategy but unfortunately that would have required us to
handle response body parsing (e.g., JSON, XML, etc.) in some fashion.
We could borrow some of the logic from related strategies but we would
still be stuck having to update `Post` whenever we add a strategy for
a new format.

Instead, this implements `POST` support by borrowing ideas from the
`using: :post` and `data` `url` options found in formulae. This uses
a `post_form` option to handle form data and `post_json` to handle
JSON data, encoding the hash argument for each into the appropriate
format. The presence of either option means that curl will use a
`POST` request.

With this approach, we can make a `POST` request using any strategy
that calls `Strategy::page_headers` or `::page_content` (directly or
indirectly) and everything else works the same as usual. The only
change needed in related strategies was to pass the options through
to the `Strategy` methods.

For example, if we need to parse a JSON response from a `POST`
request, we add a `post_data` or `post_json` hash to the `livecheck`
block `url` and use `strategy :json` with a `strategy` block. This
leans on existing patterns that we're already familiar with and
shouldn't require any notable maintenance burden when adding new
strategies, so it seems like a better approach than a `Post` strategy.
2025-02-07 08:53:47 -05:00
Mike McQuaid
9e3ae9f3f9
Merge pull request #19251 from Homebrew/revert-json-v3-logic
Revert json v3 logic
2025-02-07 08:32:22 +00:00
apainintheneck
eead014ceb cask/cask: remove unnecessary tests
The `compact:` option got removed from `Cask::Cask#artifacts_list`
in 042d6cc97e886c6f2817500083cda6c856b5350a.
2025-02-06 20:13:19 -08:00
Adrian Ho
956b71eeed update-python-resources: add option to ignore errors
This is particularly useful for third-party Python formulae that have a ton of resources, not all of which may adhere to homebrew/core's strict policies. See #19240 for context.

I've also added logic that ignores `--ignore-errors` on `homebrew/core`, although I personally think this new behavior is also useful for mainline formula creation.

Before: error out on a single non-conforming resource, zero resource blocks added to formula, scary stacktrace.

After: all conforming resources added, all non-conforming resources identified in comments, error message at end, `brew` exits non-zero without scary stacktrace:-
```
% brew update-python-resources --ignore-errors gromgit/test/auto-coder || echo OOPS
==> Retrieving PyPI dependencies for "auto-coder==0.1.243"...
==> Retrieving PyPI dependencies for excluded ""...
==> Getting PyPI info for "aiohappyeyeballs==2.4.4"
[200+ resource lines elided]
==> Getting PyPI info for "zhipuai==2.1.5.20250106"
==> Updating resource blocks
Error: Unable to resolve some dependencies. Please check /opt/homebrew/Library/Taps/gromgit/homebrew-test/Formula/auto-coder.rb for RESOURCE-ERROR comments.
OOPS

% brew cat gromgit/test/auto-coder | ggrep -C10 RESOURCE-ERROR
  license "Apache-2.0"

  depends_on "python@3.11"

  # Additional dependency
  # resource "" do
  #   url ""
  #   sha256 ""
  # end

  # RESOURCE-ERROR: Unable to resolve "azure-cognitiveservices-speech==1.42.0" (no suitable source distribution on PyPI)
  # RESOURCE-ERROR: Unable to resolve "ray==2.42.0" (no suitable source distribution on PyPI)

  resource "aiohappyeyeballs" do
    url "e4373e888f/aiohappyeyeballs-2.4.4.tar.gz"
    sha256 "5fdd7d87889c63183afc18ce9271f9b0a7d32c2303e394468dd45d514a757745"
  end

  resource "aiohttp" do
    url "952d49c730/aiohttp-3.11.12.tar.gz"
    sha256 "7603ca26d75b1b86160ce1bbe2787a0b706e592af5b2504e12caa88a217767b0"
  end
```
2025-02-06 21:20:55 +08:00
apainintheneck
839198d21e Remove JSON v3 formula logic 2025-02-05 23:36:57 -08:00
Douglas Eichelberger
fe7c76196c
Merge pull request #19215 from Homebrew/concurrency-test
Add test for concurrent fetching
2025-02-05 14:52:57 +00:00
Sam Ford
23274ac454
tests: add missing :needs_network argument
I was recently running `brew tests` without `--online` and I noticed
that there was still one formulae.brew.sh request. I narrowed it down
to a `brew desc` test, so this adds `:needs_network` to that test.
As expected, `brew tests` doesn't make any network requests after this
change unless `--online` is used.
2025-02-04 16:05:35 -05:00
Douglas Eichelberger
f5d2d30f5b Add test for concurrent fetching 2025-02-04 13:02:50 -08:00
Mike McQuaid
2b737f0423
Split up SoftwareSpec
This came up in the AGM and has bothered me for years: let's actually
split out `software_spec.rb` into one file per class, as is more typical
in Ruby.

This will make these classes easier to find.
2025-02-04 16:27:39 +00:00
Mike McQuaid
510a1503c8
Merge pull request #19217 from Homebrew/ww/brew-verify
dev-cmd: add brew verify
2025-02-04 15:24:19 +00:00
William Woodruff
27be7b50a1
dev-cmd: add a basic verify test
Signed-off-by: William Woodruff <william@yossarian.net>
2025-02-04 13:08:53 +01:00
Mike McQuaid
791194865f
Merge pull request #19188 from Homebrew/arm64_linux-tag
Rename aarch64_linux tag to arm64_linux
2025-02-03 13:21:59 +00:00
Bo Anderson
fed5321969
Rename aarch64_linux tag to arm64_linux 2025-02-01 13:03:58 +01:00
Kristján Oddsson
7b01442273 make sure disable comments have content 2025-01-31 20:38:21 +01:00
Kristján Oddsson
4acdcfcb37
Add a DisableComment Cop
Co-authored-by: Issy Long <issyl0@github.com>
2025-01-31 15:39:17 +01:00
Mike McQuaid
bbf5a9f479
env_config: use environment variables consistently
- use e.g. `$HOMEBREW_*` for cases where only the environment variable
  is the entire backtick-quoted string
- use e.g. `${HOMEBREW_*}` for cases where the environment variable is
  part of a backtick-quoted string to make clear what parts are variable
  and what parts are not
- use `export HOMEBREW_*=...` for cases where we're talking about
  setting the environment variable (because it likely needs to be
  exported to work how they want)

Inspired by https://github.com/Homebrew/homebrew-bundle/pull/1579 making
similar changes for Homebrew/homebrew-bundle.
2025-01-27 14:21:27 +00:00
Mike McQuaid
f4371b866d
Merge pull request #19116 from alebcay/utils-check-binary-linkage
utils: add check_binary_linkage function
2025-01-24 09:03:33 +00:00
Caleb Xu
2373b6d586
utils: add check_binary_linkage function 2025-01-23 11:26:38 -05:00
Mike McQuaid
fa8ada31b8
cleanup: improve cleanup version detection.
We're using `formula.eligible_kegs_for_cleanup` to figure out which
formula should be kept or removed based on e.g. `brew pin` status but
we didn't use this sufficiently in `brew cleanup` to avoid cleaning up
all cached files related to a pinned keg.

Instead, let's use a (cached) call to
`formula.eligible_kegs_for_cleanup` to ensure that we check all
related resources, manifests, etc. for pinned bottles rather than just
the latest version.
2025-01-23 16:04:31 +00:00
Rylan Polster
c023b70e8f
Mirror real installation directory structure for tests 2025-01-23 03:11:59 -05:00
Sean Molenaar
32b9afd7cd feat: add linux tests 2025-01-19 12:32:55 +01:00
Sam Ford
d8125322e1
Curl: expand test coverage
This adds more tests to `curl_spec.rb` to increase test coverage.
This brings almost all of the methods that don't make network
requests up to 100% line and branch coverage (the exception being
some guards in `parse_curl_output` that shouldn't happen under
normal circumstances).

In the process of writing more tests for `parse_curl_response`, I
made some tweaks to remove checks for conditions that shouldn't ever
be true (e.g., `match["code"]` isn't optional, so it will be present
if `HTTP_STATUS_LINE_REGEX` matches) and to refactor some others. I
contributed this method a while back (9171eb2), so this is me coming
back to clarify some behavior.
2025-01-14 08:14:39 -05:00
Sam Ford
cf22382921
Curl: use typed: strict
This upgrades `utils/curl.rb` to `typed: strict`, which requires
a number of changes to pass `brew typecheck`. The most
straightforward are adding type signatures to methods, adding type
annotations (e.g., `T.let`) to variables that need them, and ensuring
that methods always use the expected return type.

I had to refactor areas where we call a `Utils::Curl` method and use
array destructuring on a `SystemCommand::Result` return value
(e.g., `output, errors, status = curl_output(...)`), as Sorbet
doesn't understand implicit array conversion. As suggested by Markus,
I've switched these areas to use `#stdout`, `#stderr`, and `#status`.
This requires the use of an intermediate variable (`result`) in some
cases but this was a fairly straightforward substitution.

I also had to refactor how `Cask::URL::BlockDSL::PageWithURL` works.
It currently uses `page.extend PageWithURL` to add a `url` attribute
but this reworks it to subclass `SimpleDelegator` and use an
`initialize` method instead. This achieves the same goal but in a way
that Sorbet can understand.
2025-01-14 08:14:39 -05:00
Issy Long
9c8ff4c7d6
Reset "custom internal commands" RSpec.shared_context wording
- I tried this as a previous approach to see if we could enable the rule, but it didn't work, then I forgot about it.
2025-01-13 11:18:05 +00:00
Issy Long
6ada9a9665
Add clarifying comments to rubocop:disables
- Needed for PR 18842 that adds a `DisableComment` RuboCop to ensure that all RuboCop disables have comments.
2025-01-12 16:59:07 +00:00
Mike McQuaid
e9b4979f40
Add support for Homebrew wrappers
Allow the ability for a system administrator to use
`HOMEBREW_BREW_WRAPPER` and `HOMEBREW_FORCE_BREW_WRAPPER` variables to
enforce the usage of a particular `brew` command for non-trivial (e.g.
`brew --prefix` is considered trivial, it doesn't need to write to the
prefix) Homebrew commands.

This also introduces a `HOMEBREW_ORIGINAL_BREW_FILE` variable for some
internal usage; `HOMEBREW_BREW_FILE` was being used internally for
both "how should we shell out to Homebrew" and "what should we use
to check permissions on Homebrew". `HOMEBREW_ORIGINAL_BREW_FILE` is
now used just for the latter case.

Inspired by conversation in
https://github.com/Homebrew/homebrew-bundle/pull/1551 which suggested
this was worth fixing in wider than just `brew bundle`.
2025-01-07 17:40:18 +00:00
Mike McQuaid
f84082963d
Merge pull request #19009 from Homebrew/fewer_actions_warnings
cask: fewer GitHub Actions warnings.
2024-12-30 13:07:02 +00:00
Mike McQuaid
d490692b26
cask: fewer GitHub Actions warnings.
- don't care about no checksums being defined for official casks
- don't complain about Gatekeeper being disabled on GitHub Actions as
  it's been globally disabled for the team
2024-12-30 12:55:30 +00:00
Mike McQuaid
5013c44adf
Merge pull request #19010 from Homebrew/livecheck/xorg-handle-mesa-urls
Xorg: Handle archive.mesa3d.org URLs
2024-12-30 12:40:03 +00:00
Rui Chen
79ed2c6e61
chore: fix typos
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-12-28 15:53:35 -05:00
Sam Ford
260698b1cb
Xorg: Handle archive.mesa3d.org URLs
The `mesa` formula currently uses a mesa.freedesktop.org/archive/
`stable` URL but it redirects to archive.mesa3d.org. Upstream links
to archive.mesa3d.org as the location to find Mesa releases, so we
should update the formula URLs accordingly.

This updates the `Xorg` strategy to be able to handle
archive.mesa3d.org URLs, so livecheck will continue to be able to
check `mesa` without needing a one-off `livecheck` block. [This would
also work for `mesalib-glw` (which has an archive.mesa3d.org `stable`
URL) but that formula is deprecated.]
2024-12-28 09:55:44 -05:00
Mike McQuaid
e69124045a
Remove BuildPulse and use CodeCov instead
Now we're successfully sending flaky test results to CodeCov, let's
remove BuildPulse code and docs.
2024-12-24 10:32:55 +00:00
Michael Cho
eebcd60bd9
test/deprecate_disable_spec: increase test coverage 2024-12-20 14:30:30 -05:00
Michael Cho
c8d0a1904d
test/download_strategies/abstract_spec: fix test 2024-12-19 15:27:14 -05:00
Mike McQuaid
640f2152f3
Merge pull request #18808 from Homebrew/feat/cask/block_install
feat: only block cask install on Linux
2024-12-16 12:14:05 +00:00
Michael Cho
60b5e063e3
formula: conditionally use executable name as completion name
When running `generate_completions_from_executable` with a formula's
`bin`/`sbin` executable, the resulting completion is usually intended
for the executable itself.
2024-12-15 11:58:39 -05:00