26 Commits

Author SHA1 Message Date
Bo Anderson
e35709cb43
utils/github/actions: fix frozen string handling 2025-05-02 01:35:04 +01:00
Carlo Cabrera
7a8f9fa489
extend/kernel: fix duplicate messages in GitHub Actions
Calls to `opoo` and `onoe` produce duplicate `Warning:` and `Error:`
messages in CI logs because we print something to stdout and print an
annotation. Annotations also produce `Error:` and `Warning:` lines in
the log.

Let's fix this by skipping printing the message if we've already printed
an annotation.
2024-10-14 12:15:24 +08:00
Mike McQuaid
1c390093f8
Revert "Limit usage of GitHub Actions Annotations" 2024-09-16 16:52:03 +01:00
Carlo Cabrera
c6e2cd9037
Limit usage of GitHub Actions Annotations
- only use annotations for `opoo` and `onoe` if
  `HOMEBREW_GITHUB_ACTIONS` is set. This will make using `brew` less
  noisy in GitHub Actions for third parties. See
  Homebrew/discussions#5602.
- if we've already called `puts_annotation_if_env_set`, then we no
  longer need to print the message to `$stderr`. The message from the
  annotation already show up in the GitHub Actions log, so printing to
  `$stderr` just leads to duplicate messages in the log.

While we're here, let's make sure to forward the `file:` and `line:`
kwargs of `puts_annotation_if_env_set` to the `Annotation` constructor.
2024-09-15 11:31:54 +08:00
Carlo Cabrera
54383d1c5f
github/actions: fix annotation title handling
We currently generate invalid workflow commands when we create
annotations with a `title` but no `file`. Let's fix that.

While we're here, let's improve handling of `title`s with `:`s. We
cannot use `title`s with `::` since GitHub Actions uses this as a
separator for different fields between a workflow command.

Let's also make sure `metadata` never ends in a `:` to avoid confusing
the GitHub Actions command parser about where the `::` separator is
meant to be.
2024-09-08 17:56:04 +08:00
Sam Ford
a6e61fd664
contributions, github: reorder requires
Per feedback to https://github.com/Homebrew/brew/pull/17806, this
moves some `require` statements in `dev-cmd/contributions.rb` and
`Utils::GitHub` into the methods that need them.
2024-07-25 10:02:18 -04:00
Issy Long
b033119523
utils/github/actions: Bump to Sorbet typed: strict 2024-07-17 18:00:20 -04:00
Mike McQuaid
e573a53868
Output GitHub warning/error annotations to stderr
This will mean e.g. `opoo` etc. will output to stdout and not end up
being in the stdout of `brew deps` etc.

While we're here, remove a duplicate annotation output I noticed in
`extend/kernel.rb`.

Inspired by conversation in:
https://github.com/Homebrew/homebrew-test-bot/issues/1082
2024-05-31 09:31:44 +01:00
Mike McQuaid
16901a674f
extend/kernel: make opoo/odie/etc. print GitHub Actions notes.
We already do this for deprecations but these may make warnings
and errors from Homebrew easier to spot in GitHub Actions logs.

While we're here, cleanup other cases that should have used
`GitHub::Actions::Annotation` but didn't and provide some helpers and
tweaks there necessary for our use case here.
2024-05-09 14:43:53 +01:00
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Markus Reiter
c76170a456
Hide #to_s in docs. 2024-04-26 14:04:55 +02:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Nanda H Krishna
30845593cc
utils/github/actions: remove Error class 2023-03-18 16:38:08 -04:00
Nanda H Krishna
b792a5fd20
utils/github/actions: add format_multiline_string method 2023-03-18 10:49:16 -04:00
Carlo Cabrera
105d1f9cfc
utils/github/actions: make file a mandatory argument
An annotation is pretty useless if you don't specify a file to place the
annotation on, so let's just require it.
2021-11-16 23:42:03 +08:00
Carlo Cabrera
6795a88520
utils/github/actions: support notices and new annotation parameters
GitHub Actions annotations also suport a "notice" annotation type. You
can also set the title of an annotion, and the set `endLine` and
`endColumn` parameters.

See https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions
2021-11-16 14:44:43 +08:00
Seeker
fbafaff4fe rubocop: require braces for Sorbet sig 2021-01-18 16:52:45 -08:00
Markus Reiter
220b4606ca Add type signatures to GitHub::Actions. 2020-11-19 16:07:50 +01:00
Markus Reiter
da9289eff0 Add more type signatures. 2020-11-13 12:26:36 +01:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
2f25e1f03e Strip escape codes from annotations. 2020-09-13 23:45:28 +02:00
Markus Reiter
d8905d5a33
Merge pull request #8671 from reitermarkus/audit-annotations
Output annotations for `brew cask audit` (again).
2020-09-10 02:01:01 +02:00
Markus Reiter
769fa066e2 Output annotations for brew cask audit. 2020-09-09 21:50:32 +02:00
Markus Reiter
196d7badfa Improve RSpec annotations. 2020-09-09 10:24:20 +02:00
Markus Reiter
ebd4ce467c Output GitHub Actions annotations for brew style. 2020-09-02 16:44:16 +02:00