Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

livecheck: Add ExtractPlist skip to SkipConditions #16968

Conversation

samford
Copy link
Member

@samford samford commented Mar 29, 2024

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

When the --extract-plist option was added to livecheck (#16759), conditions were added in #run_checks to skip casks using ExtractPlist if the --extract-plist isn't used and the run involves multiple formulae/casks. This integrates the skip into the SkipConditions class.

Outside of the organizational improvement, this also fixes a related issue with the livecheck --json output when an ExtractPlist cask is included in a multi-cask run without the --extract-plist option. In this scenario, we wrongly get non-JSON output alongside the expected JSON data:

$ brew livecheck -j 0-ad 1clipboard actual-odbc-pack
==> Running checks
1clipboard: skipped - Livecheck skipped due to the ExtractPlist strategy..] 1/3
[
  {
    "cask": "0-ad",
    "version": {
      "current": "0.0.26-alpha",
      "latest": "0.0.26-alpha",
      "outdated": false,
      "newer_than_upstream": false
    }
  }
]

With this change, we receive the expected JSON output:

$ brew livecheck -j 0-ad 1clipboard actual-odbc-pack
[
  {
    "cask": "0-ad",
    "version": {
      "current": "0.0.26-alpha",
      "latest": "0.0.26-alpha",
      "outdated": false,
      "newer_than_upstream": false
    }
  },
  {
    "cask": "1clipboard",
    "status": "skipped",
    "messages": [
      "Use `--extract-plist` to enable checking multiple casks with ExtractPlist strategy"
    ],
    "meta": {
      "livecheckable": true
    }
  },
  {
    "cask": "actual-odbc-pack",
    "status": "skipped",
    "messages": [
      "Use `--extract-plist` to enable checking multiple casks with ExtractPlist strategy"
    ],
    "meta": {
      "livecheckable": true
    }
  }
]

Besides that, this updates the language around the --extract-plist flag (usage description, code comments) to clarify the behavior. From the description, it would seem that the ExtractPlist strategy is only enabled when --extract-plist is used. Instead, livecheck automatically enables the strategy if the command is run on only one cask.

@apainintheneck
Copy link
Contributor

The --extract-plist option is only available for brew livecheck however adding this to SkipConditions will mean that this new skip condition will now affect brew audit and brew bump as well. Is that intentional?

I'm specifically looking at the changes to SkipConditions.referenced_skip_information which is used in those three commands.

@samford
Copy link
Member Author

samford commented Mar 31, 2024

The --extract-plist option is only available for brew livecheck however adding this to SkipConditions will mean that this new skip condition will now affect brew audit and brew bump as well. Is that intentional?

It wasn't intentional and I had simply forgotten that bump and cask audits also use SkipConditions, so thanks for the catch. I'll take a look at it tomorrow but, off the top of my head, if we want to maintain the existing behavior (not restricting ExtractPlist), it could be as simple as adding extract_plist: true to the related calls in those areas. Alternatively, we could have extract_plist default to true and specifically pass a false value in Livecheck#run_checks to trigger the skip.

@apainintheneck
Copy link
Contributor

Either of those options makes sense to me.

When the `--extract-plist` option was added to livecheck, conditions
were added in `#run_checks` to skip casks using `ExtractPlist` if the
`--extract-plist` isn't used and the run involves multiple
formulae/casks. This integrates the skip into the `SkipConditions`
class.
From the description of the `--extract-plist` option, it would seem
that the `ExtractPlist` strategy is only enabled when the option is
used. Instead, livecheck automatically enables the strategy if the
command is run on only one cask. This rewords descriptions of the
option to clarify the behavior.
@samford samford force-pushed the livecheck/add-extract-plist-skip-to-skip-conditions branch from c82062d to 111ac58 Compare April 1, 2024 01:06
@samford
Copy link
Member Author

samford commented Apr 1, 2024

I updated the #skip_information and #referenced_skip_information methods to use true as the default extract_plist value, which will take care of the aforementioned issue. With this setup, we don't have to update the bump and audit calls (or any future calls outside of livecheck), which maybe seems a little better than the other option (adding an explicit extract_plist: true to those calls).

@MikeMcQuaid MikeMcQuaid merged commit 120eb55 into Homebrew:master Apr 1, 2024
25 checks passed
@MikeMcQuaid
Copy link
Member

Thanks @samford!

@samford samford deleted the livecheck/add-extract-plist-skip-to-skip-conditions branch April 1, 2024 11:53
@github-actions github-actions bot added the outdated PR was locked due to age label May 2, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants