121 Commits

Author SHA1 Message Date
Douglas Eichelberger
8763fb6d29 Resolve rubocop violations 2025-02-17 18:56:31 -08:00
Bo Anderson
d63e44185f
github_packages: fix oldest CPU variant on arm64 Linux 2025-02-03 18:17:15 +01:00
Bo Anderson
fed5321969
Rename aarch64_linux tag to arm64_linux 2025-02-01 13:03:58 +01: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
Mislav Marohnić
450469f57f
pr-upload: fix --warn-on-upload-failure functionality
For bottle uploads that would be skipped due to preupload_check warning about
skipped uploads and returning early, the old code errored out due to JSON schema
validation failure since the upload was allowed to resume:

    "error"=>"value at /manifests/0/annotations/org.opencontainers.image.ref.name is not a string"

This change ensures that the upload is effectively skipped if preupload_check
returns no result.
2025-01-11 01:28:37 +01:00
Douglas Eichelberger
9e3e1e1847 Namespace some top-level constants 2024-12-11 11:04:55 -08:00
Mike McQuaid
94416e82f0
Add new odeprecated, odisabled, remove disabled code.
Prepare the usual deprecation cycle for Homebrew 4.4.0.
2024-09-24 10:15:34 +01:00
Michael Cho
e7f01653ae
github_packages: use full license only if within limit 2024-09-03 23:03:00 -04:00
Michael Cho
bf320eb4bf
github_packages: use official license annotation
For now we ignore the 256 character limit stated by GitHub packages

https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#labelling-container-images
2024-08-27 10:12:11 -04:00
Michael Cho
253db8def2
dev-cmd/bottle: include installed_size in metadata 2024-08-23 14:24:21 -04:00
Issy Long
45978435e7
rubocop: Use Sorbet/StrictSigil as it's better than comments
- Previously I thought that comments were fine to discourage people from
  wasting their time trying to bump things that used `undef` that Sorbet
  didn't support. But RuboCop is better at this since it'll complain if
  the comments are unnecessary.

- Suggested in https://github.com/Homebrew/brew/pull/18018#issuecomment-2283369501.

- I've gone for a mixture of `rubocop:disable` for the files that can't
  be `typed: strict` (use of undef, required before everything else, etc)
  and `rubocop:todo` for everything else that should be tried to make
  strictly typed. There's no functional difference between the two as
  `rubocop:todo` is `rubocop:disable` with a different name.

- And I entirely disabled the cop for the docs/ directory since
  `typed: strict` isn't going to gain us anything for some Markdown
  linting config files.

- This means that now it's easier to track what needs to be done rather
  than relying on checklists of files in our big Sorbet issue:

```shell
$ git grep 'typed: true # rubocop:todo Sorbet/StrictSigil' | wc -l
    268
```

- And this is confirmed working for new files:

```shell
$ git status
On branch use-rubocop-for-sorbet-strict-sigils
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Library/Homebrew/bad.rb
        Library/Homebrew/good.rb

nothing added to commit but untracked files present (use "git add" to track)

$ brew style
Offenses:

bad.rb:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
^^^^^^^^^^^^^

1340 files inspected, 1 offense detected
```
2024-08-12 15:24:27 +01:00
Mike McQuaid
64b86fe25c
bottle/github_packages: include path_exec_files.
`all_files` is added to the bottle JSON but not actually used by
`GitHubPackages` yet.
2024-06-19 21:49:31 +02:00
Patrick Linnane
8e089b2fd2
Revert "bottle/github_packages: include path_exec_files, all_files." 2024-06-18 09:59:27 -07:00
Mike McQuaid
6b8b4d3f26
bottle/github_packages: include path_exec_files, all_files. 2024-06-16 09:35:33 +02:00
Patrick Linnane
2a053b7bc8
Revert "bottle/github_packages: include path_exec_files, all_files." 2024-06-15 12:54:59 -07:00
Mike McQuaid
895cd02071
bottle/github_packages: include path_exec_files, all_files.
This provides an extra field to the GitHub Packages manifest about the
executable files in `bin` or `sbin` directories of the bottle.

It also provides an extra GitHub Packages JSON file with the list of all
files.

This would allow us (post a large rebottling effort) to start providing
this information in the Homebrew JSON API.

It also provides a much nicer information source for e.g.
homebrew-command-not-found that doesn't involve downloading actual
bottles.

Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
2024-06-15 18:40:07 +01:00
Mike McQuaid
222fe8ef0b
Homebrew 4.3.0 deprecation/disable/removals.
The usual pass of deprecating/disabling/removing code for the next
minor Homebrew release.
2024-05-07 12:18:04 +01:00
Markus Reiter
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Douglas Eichelberger
eb7c3e52a0 Require SystemInclude only where needed 2024-01-31 11:42:01 -08:00
Douglas Eichelberger
f99d39faf9 Vendor CompactBlank cop 2024-01-26 15:03:59 -08:00
Douglas Eichelberger
f6c7eb7124 Add hash/keys to extend/ 2024-01-19 13:36:17 -08:00
Issy Long
f682147598
Fix RuboCop Style/RedundantFreeze offenses 2024-01-18 22:20:01 +00:00
Issy Long
149b0e4f31
Fix new Style/MutableConstant RuboCop offenses for Ruby 3.1
- A follow-up to de592af20bbff5bcb548d2474f0722e59ff1129a, resetting the previous disabled comments too.
2023-12-16 11:57:06 +00:00
Bo Anderson
b42256d286
Deprecate, disable & delete code for Homebrew 4.2.0 2023-12-07 23:42:13 +00:00
Mike McQuaid
de4207f6d0
Audit invalid versions
We have a bunch of versions we've been meaning to adjust to not use
invalid GitHub Packages characters for a while. Let's audit for them
and plan for deprecating their use in future.
2023-09-05 16:43:36 -04:00
Mike McQuaid
1a91157590
Fix more missing Utils::Curl references.
e.g. https://github.com/Homebrew/brew/pull/15940#issuecomment-1706486816
2023-09-05 08:27:02 -04:00
Bo Anderson
599f7af505
github_packages: abort with an error if image index is >= 4MB 2023-07-28 00:43:57 +01:00
Bo Anderson
d5a780d5b3
github_packages: ensure only OCI format is uploaded 2023-07-22 19:45:18 +01:00
Carlo Cabrera
c03e4111e6
github_packages: call ln with force
`FileUtils.cp` overwrites its destination when the destination already
exists, while `FileUtils.ln` throws `EEXIST`. To restore the old
behaviour, let's set `force: true`.

This fixes recent CI failures in Homebrew/core.[^1]

[^1]: For example: https://github.com/Homebrew/homebrew-core/actions/runs/5313853638/jobs/9620314048#step:8:158
2023-06-19 23:57:16 +08:00
Carlo Cabrera
4c40d452df
github_packages: create hard link instead of copying
Some bottles are quite large, and the copies can make us run out of
space rather quickly. Let's try to avoid that by using hard links
instead of copies.
2023-06-17 01:59:23 +08:00
Carlo Cabrera
65be47848d
github_packages: adjust upload retries
We still regularly see upload failures here, so let's adjust this to see
if we can try to reduce these.
2023-05-30 11:55:08 +08:00
Carlo Cabrera
9744b69071
github_packages: use exponential backoff when retrying
The retry behaviour in `publish_commit_bottles.yml` [1] is often
successful after the second try, so it's likely that we're not waiting
long enough in between retries here.

Let's fix that by retrying with exponential backoff instead of adding a
fixed interval of five seconds after each failure.

[1] 3241035b2a/.github/workflows/publish-commit-bottles.yml (L431-L443)
2023-05-03 16:58:16 +08:00
Carlo Cabrera
31a152208b
github_packages: improve upload error handling
Erroring out in the middle of uploading multiple bottles results in a
state that is tedious to recover from.

Let's try to avoid these situations by performing checks for all the
bottles first before trying to upload any.
2023-05-03 16:40:42 +08:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Ruoyu Zhong
a196d33482
github_packages: fix bottle manifest schema violation
According to [^1] [^2], image manifest annotations need to be a
string-string map.

This should fix the errors seen in Homebrew/homebrew-core#128517,
Homebrew/homebrew-core#128558, et al.

[^1]: 2879913ce4/schema/image-manifest-schema.json (L35)
[^2]: 2879913ce4/schema/defs-descriptor.json (L22)
2023-04-17 23:17:20 +08:00
Colin Dean
2787eead89 Add bottle file size to GHP manifest annotations
This will reduce the number of requests necessary to ascertain the size
of formulas' bottle archives for analysis purposes.

Currently, getting the size of each bottle requires 1 request for the
formula.json and followed by N requests per formula-version, which
for most formulae is 7— more than 47k requests!

After this change, size retrieval can ascertain all bottle sizes for a
formula-version in a single request, at the cost of one additional
request per formula-version if that formula-version has not been
rebuilt since this change was introduced.

To start, size retrieval will incur an additional P requests where
P is the number of packages. Over the next few weeks and months,
the retrieval will go a lot faster as all new and updated packages will
require only one request.
2023-04-16 21:32:47 +00:00
Issy Long
1e64a658d4
Revert "Update GitHubPackages for new Tab implementation" 2023-03-15 23:12:37 +00:00
Douglas Eichelberger
ea65b7264a Update GitHubPackages for new Tab implementation 2023-03-15 09:49:45 -07:00
Dawid Dziurla
c4cf2d208e
github_packages: reduce skopeo retry times to 2 2023-03-09 09:42:43 +01:00
Dawid Dziurla
de98ad53cc
github_packages: additional retry of skopeo copy with backoff 2023-03-09 09:17:24 +01:00
Dawid Dziurla
244006f15a
github_packages: retry skopeo copy 5 times 2023-03-08 15:32:31 +01:00
Mike McQuaid
fe37be6c30
github_packages: improve schema debugging. 2023-02-10 09:05:10 +00:00
Rylan Polster
68bbe03d04
Remove remaining formula_api_path references 2023-01-06 02:46:21 -05:00
Mike McQuaid
c294dcc616
glibc related cleanup
Extracted from https://github.com/Homebrew/brew/pull/13577
2022-08-23 12:42:02 +01:00
Bo Anderson
ecc705803f
github_packages: add comment for image-spec pin 2022-05-16 16:15:17 +01:00
Bo Anderson
354e5b60a7
github_packages: pin image spec schema 2022-05-11 04:28:02 +01:00
Bo Anderson
ac9af0dbbc
github_packages: fix OOM with large bottles 2022-03-03 16:26:47 +00:00
XuehaiPan
9ef52080e3 utils: extract common word "for" in reason 2021-11-23 23:59:09 +08:00