-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
Test officially supported cmd taps. #390
Conversation
|
||
if ARGV.include? "--official-cmd-taps" | ||
OFFICIAL_CMD_TAPS.each do |org, repo| | ||
tap = "#{org}/#{repo}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tap = Tap.fetch(user, repo)
@UniqMartin @xu-cheng Neither of you are opposed to the overall concept of this PR? |
system "bundle", "install", "--path", "vendor/bundle" | ||
end | ||
system "bundle", "exec", "rake" | ||
Homebrew.failed = !$?.success? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Homebrew.failed = true unless $?.success?
Otherwise a later success may mask a previous failure.
I'm not opposed. Makes a lot of sense to me, though I personally don't care that much about these external commands because I don't use them. How long does this additional step approximately take to complete compared to a regular |
I'm not opposed to this PR's concept as well. |
Have addressed feedback.
Will get you the numbers for this after this PR runs the CI job. |
when "services" | ||
Tap.fetch("Homebrew", "services") | ||
end | ||
possible_tap = OFFICIAL_CMD_TAPS.find { |_, repo| repo == cmd } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you intentionally dropping support for auto-tapping when brew bundle
is invoked with the alternative commands brewdle
, brewdler
, and bundler
? (I'm not opposing this change, just making sure.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we use the Hash approach in the above? i.e.
OFFICIAL_CMD_TAPS = {
"homebrew/bundle" => %w[bundle ...]
...
}.freeze
I am however opposite to only check cmd with tap name, which it's a bad assumption for future commands or taps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you intentionally dropping support for auto-tapping when brew bundle is invoked with the alternative commands brewdle, brewdler, and bundler? (I'm not opposing this change, just making sure.)
Yes. PR incoming for homebrew-bundle to do that.
I am however opposite to only check cmd with tap name, which it's a bad assumption for future commands or taps.
I don't think it's a bad assumption but we can correct it when it's no longer correct as it's an implementation detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you take homebrew/alias
into account, the assumption is already broken. 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now either needs a require "official_taps"
added before this line or directly in tap.rb
(otherwise the constant OFFICIAL_CMD_TAPS
is undefined at this point).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also agree with @xu-cheng that it would be better to use his suggested hash approach from the start. Unlike the currently proposed solution it doesn't make any assumptions about the tap name vs. command name relationship and allows for multiple commands in a single tap, thus feels very future-proof to me. It doesn't feel like “doing it right” from the start creates a significant burden.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The redundancy and speculation annoys me a bit here but will defer to you to get this merged.
Have you been able to run $ brew official-cmd-tap-tests
==> Running caskroom/cask tests:
==> Tapping caskroom/cask
[…snip…]
8307 tests, 10105 assertions, 1 failures, 4 errors, 2395 skips
[…snip…] The failure and those errors of course result in a nonzero exit code. On the other hand, the tests run for Ignoring the failures for a moment, here are some numbers when running this locally: $ /usr/bin/time brew tests --no-compat
[…snip…]
74.16 real 57.36 user 16.19 sys
$ /usr/bin/time brew tests --no-compat
[…snip…]
67.33 real 54.76 user 13.66 sys
$ /usr/bin/time brew official-cmd-tap-tests
[…snip…]
353.80 real 142.69 user 39.52 sys
$ /usr/bin/time brew official-cmd-tap-tests
[…snip…]
193.10 real 76.73 user 30.89 sys Those extra tests are not exactly cheap, particularly on the first run when the taps need to be installed and the Gems required for testing need to be fetched and installed via |
Cask's tests seem very oriented towards their Travis setup so I decided it was a bad idea to run the entire test suite (and probably overkill) so I decided to just write integration tests to smoke tests these three commands; in my experience if we e.g. break an API they are relying on we'll realise pretty quickly. I think this gives us the best of both worlds; fast integration tests (less than a second added in total for all three assuming they are already tapped) whilst making sure we don't obliterate the internal methods they rely on. |
|
||
def test_services | ||
skip_unless_test_cmd_taps | ||
assert_equal "Warning: No services available to control with `brew services`", cmd("services", "list") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you wrap this overly long line, just like you did in the bundle check
case?
Commented on some code, that is probably causing the test bot run to fail, and on a few details.
I agree.
Makes sense and works for me. |
if ARGV.include? "--official-cmd-taps" | ||
ENV["HOMEBREW_TEST_OFFICIAL_CMD_TAPS"] = "1" | ||
OFFICIAL_CMD_TAPS.each do |tap, _| | ||
tap = Tap.fetch tap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably needs a require "tap"
at the top of the file. Here's what I currently get:
$ brew tests --no-compat --official-cmd-taps
Error: uninitialized constant Homebrew::Tap
Please report this bug:
https://git.io/brew-troubleshooting
/opt/brewery/dummy/Library/Homebrew/cmd/tests.rb:14:in `block in tests'
/opt/brewery/dummy/Library/Homebrew/cmd/tests.rb:13:in `each'
/opt/brewery/dummy/Library/Homebrew/cmd/tests.rb:13:in `tests'
/opt/brewery/dummy/Library/brew.rb:87:in `<main>'
All of these taps use Homebrew internal APIs (or will shortly) and we autoinstall them all from `brew $CMD`. We should adjust our CI to ensure that we never accidentally break these taps when making changes to core code so that these taps can rely more on this core code rather than having to e.g. vendor equivalent code that never changes on our end.
This reverts commit 252c701. Taps installed prior to running the test suite are not visible to the test suite as most Homebrew paths are redefined as to not mess up the local installation.
I'm sorry, but I had to revert this in dba1958. This needs more work and local testing via, e.g.,
before it can be merged (as the test bot won't run this code until it is merged, at which point it's too late). To quote from the revert commit:
|
I just realized that there is/was another issue with the current implementation. The entire test suite now runs thrice: once with coverage in no-compat mode, once regularly, and now once more with the three integration tests from this PR enabled. The latter two runs are basically identical except for those newly added integration tests, resulting in some unnecessary and wasteful redundancy. |
This reverts commit dba1958.
Addressed this in a series of commits ending in a1b0ef1 as currently the bot isn't doing CI testing with the correct version so it was easier to just ensure it was working properly on all platforms by pushing to |
👍 |
All of these taps use Homebrew internal APIs (or will shortly) and we autoinstall them all from `brew $CMD`. We should adjust our CI to ensure that we never accidentally break these taps when making changes to core code so that these taps can rely more on this core code rather than having to e.g. vendor equivalent code that never changes on our end.
This reverts commit 252c701. Taps installed prior to running the test suite are not visible to the test suite as most Homebrew paths are redefined as to not mess up the local installation.
This reverts commit dba1958.
brew tests
with your changes locally?All of these taps use Homebrew internal APIs (or will shortly) and we autoinstall them all from
brew $CMD
. We should adjust our CI to ensure that we never accidentally break these taps when making changes to core code so that these taps can rely more on this core code rather than having to e.g. vendor equivalent code that never changes on our end.CI may well by wrong here as I've not tested this on the actual bot and it won't run
brew tests --official-cmd-taps
(although I should fix that so we can test newbrew test-bot
changes here).The approach may well be terrible; we could perhaps get away with a simpler integration tests or a subset of their tests. Alternatively, we may also want to consider running these tests in parallel with something like https://github.com/grosser/parallel_tests.
This (in some form) will be a requirement for @AnastasiaSulyagina's GSoC project to be able to remove duplicated/vendored core code from Caskroom/cask and eventually move it into Homebrew itself and it's something we should have done for Homebrew/bundle a while ago. This also perhaps overlaps with @eirinikos's integration testing work.
CC @Homebrew/maintainers for thoughts as this is a fairly big change in how we do CI for this repository but it's something we'll have to do in some form.