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

Test officially supported cmd taps. #390

Merged
merged 1 commit into from
Jul 4, 2016
Merged

Test officially supported cmd taps. #390

merged 1 commit into from
Jul 4, 2016

Conversation

MikeMcQuaid
Copy link
Member

  • 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 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 new brew 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.

@BrewTestBot BrewTestBot added the in progress Maintainers are working on this label Jun 22, 2016

if ARGV.include? "--official-cmd-taps"
OFFICIAL_CMD_TAPS.each do |org, repo|
tap = "#{org}/#{repo}"
Copy link
Member

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)

@MikeMcQuaid
Copy link
Member Author

@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?
Copy link
Contributor

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.

@UniqMartin
Copy link
Contributor

@UniqMartin @xu-cheng Neither of you are opposed to the overall concept of this PR?

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 brew tests run? Does running this on our Mavericks test bot (with Ruby 1.8.7) make sense? Do those external commands even support Ruby 1.8.7?

@xu-cheng
Copy link
Member

xu-cheng commented Jun 23, 2016

I'm not opposed to this PR's concept as well.

@MikeMcQuaid
Copy link
Member Author

Have addressed feedback.

How long does this additional step approximately take to complete compared to a regular brew tests run? Does running this on our Mavericks test bot (with Ruby 1.8.7) make sense? Do those external commands even support Ruby 1.8.7?

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 }
Copy link
Contributor

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.)

Copy link
Member

@xu-cheng xu-cheng Jul 1, 2016

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.

Copy link
Member Author

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.

Copy link
Member

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. 😉

Copy link
Contributor

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).

Copy link
Contributor

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.

Copy link
Member Author

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.

@UniqMartin
Copy link
Contributor

Have you been able to run brew official-cmd-tap-tests successfully? If I try that locally on my machine (OS X 10.11) in a Homebrew installation without any pre-installed taps except homebew/core, the Homebrew Cask tests actually fail with:

$ 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 homebrew/bundle finish just fine.


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 bundle install. On our test bot we'll obviously always have the slower times because all the taps and Gems will need to be installed anew on every test bot run.

@MikeMcQuaid
Copy link
Member Author

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")
Copy link
Contributor

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?

@UniqMartin
Copy link
Contributor

UniqMartin commented Jul 4, 2016

Commented on some code, that is probably causing the test bot run to fail, and on a few details.

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)

I agree.

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.

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
Copy link
Contributor

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.
@MikeMcQuaid MikeMcQuaid merged commit 252c701 into Homebrew:master Jul 4, 2016
@MikeMcQuaid MikeMcQuaid deleted the test-cmd-taps branch July 4, 2016 15:08
@BrewTestBot BrewTestBot removed the in progress Maintainers are working on this label Jul 4, 2016
UniqMartin added a commit that referenced this pull request Jul 4, 2016
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.
@UniqMartin
Copy link
Contributor

I'm sorry, but I had to revert this in dba1958. This needs more work and local testing via, e.g.,

brew tests --official-cmd-taps

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:

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.

@UniqMartin
Copy link
Contributor

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.

MikeMcQuaid added a commit that referenced this pull request Jul 4, 2016
@MikeMcQuaid
Copy link
Member Author

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 master. The green builds for Travis and Jenkins are: https://travis-ci.org/Homebrew/brew/builds/142266951 http://bot.brew.sh/job/Homebrew%20Testing/1029/

@UniqMartin
Copy link
Contributor

👍

souvik1997 pushed a commit to souvik1997/brew that referenced this pull request Jul 25, 2016
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.
souvik1997 pushed a commit to souvik1997/brew that referenced this pull request Jul 25, 2016
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.
souvik1997 pushed a commit to souvik1997/brew that referenced this pull request Jul 25, 2016
@Homebrew Homebrew locked and limited conversation to collaborators May 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants