brew icon indicating copy to clipboard operation
brew copied to clipboard

unversioned_cask_checker: check installer artifacts

Open bevanjkay opened this issue 3 years ago • 3 comments

  • [x] Have you followed the guidelines in our Contributing document?
  • [x] Have you checked to ensure there aren't other open Pull Requests for the same change?
  • [x] 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.
  • [x] Have you successfully run brew style with your changes locally?
  • [ ] Have you successfully run brew typecheck with your changes locally?
  • [x] Have you successfully run brew tests with your changes locally?

This PR adds installer paths to the unversioned_cask_checker method, which allows the :extract_plist livecheck method to look inside of installer paths for info.plist files. This will be used fairly rarely but will enable a livecheck to be added to the PR - https://github.com/Homebrew/homebrew-cask/pull/128899

I'm seeing an error with typecheck locally, that I'm not sure how to resolve as this is not the case practically;

unversioned_cask_checker.rb:102: This code is unreachable https://srb.help/7006
     102 |          source = artifact.is_a?(Cask::Artifact::Installer) ? artifact.path : artifact.source.basename
                                                                         ^^^^^^^^^^^^^
    unversioned_cask_checker.rb:102: This condition was always falsy (T::Boolean)
     102 |          source = artifact.is_a?(Cask::Artifact::Installer) ? artifact.path : artifact.source.basename

bevanjkay avatar Aug 06 '22 03:08 bevanjkay

Review period will end on 2022-08-09 at 00:00:00 UTC.

BrewTestBot avatar Aug 06 '22 03:08 BrewTestBot

Review period ended.

BrewTestBot avatar Aug 09 '22 00:08 BrewTestBot

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

github-actions[bot] avatar Sep 20 '22 00:09 github-actions[bot]

Looks good to me so far!

Would like to see this lines covered by at least unit tests, some other cask folks and/or @Bo98 👍🏻 this before merging.

One cask that needs this is https://github.com/Homebrew/homebrew-cask-drivers/pull/3008

Moulick avatar Oct 16 '22 12:10 Moulick

Gentle nudge as I want to get https://github.com/Homebrew/homebrew-cask-drivers/pull/3008 working and closed :)

Moulick avatar Nov 04 '22 09:11 Moulick

Gentle nudge :)

Moulick avatar Nov 16 '22 13:11 Moulick

I have added a test that should confirm that this works with an installer artifact. I have little experience with writing tests, so I hope that this suffices.

To allow the test to be completed, I needed an artifact to check for a contained info.plist file. I created a modified version of the caffeine.zip fixture that includes an info.plist file.

bevanjkay avatar Dec 05 '22 03:12 bevanjkay

It seems that the test doesn't work on Linux? I'm not sure how to proceed, would love some direction here.

bevanjkay avatar Dec 05 '22 05:12 bevanjkay

It seems that the test doesn't work on Linux? I'm not sure how to proceed, would love some direction here.

Looks like a Sorbet issue here where the wrong argument is being passed?

MikeMcQuaid avatar Dec 05 '22 13:12 MikeMcQuaid

The test is simulating the livecheck command on a cask fixture, however this will not work on Linux as the strategy uses system commands that are only found on MacOS - https://github.com/Homebrew/brew/blob/96574c831f9ed1f3fa281f4724719d8cb2424ece/Library/Homebrew/unversioned_cask_checker.rb#L83

Could this be why it is failing on CI, but I can't replicate it locally?

bevanjkay avatar Dec 05 '22 23:12 bevanjkay

Maybe restrict feature to macOS only? or find a linux alternative?

aaronliu0130 avatar Dec 06 '22 00:12 aaronliu0130

@aaronliu0130 The whole cask system should be limited to Mac only, but I'm not sure how that integrates with CI testing.

bevanjkay avatar Dec 06 '22 01:12 bevanjkay

@bevanjkay Can this command perhaps be mocked out instead? It'll be slower to call it directly anyway.

MikeMcQuaid avatar Dec 06 '22 09:12 MikeMcQuaid

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

github-actions[bot] avatar Dec 28 '22 00:12 github-actions[bot]

Thanks again @bevanjkay!

MikeMcQuaid avatar Dec 28 '22 15:12 MikeMcQuaid