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

Use a single top-level Gemfile for test dependencies #2407

Merged
merged 13 commits into from
Dec 7, 2017

Conversation

jhawthorn
Copy link
Contributor

@jhawthorn jhawthorn commented Nov 28, 2017

Similar to the goals (and some shared changes) from #2359, but with a different approach.

Currently we have one Gemfile per solidus sub-project. This was done to keep our projects isolated ex. so solidus_backend isn't loaded when we're only testing solidus_frontend.

However, we can achieve the same separation by simply not requireing the other gems. We can either set require: false in the Gemfile, or stop calling Bundle.require. I did both. The new dummy_app no longer has any knowledge of rubygems or bundler, and all test gems are now require: false.

Advantages to this:

  • Startup (especially core specs) should be much faster since it doesn't load unnecessary gems
  • Simpler for developers (only need to bundle install in one folder)
  • Faster to bundle install once vs 5 times
  • CircleCI (or any CI) gem caching is much simpler
  • Users of BUNDLE_PATH: "vendor/bundle" 👋 don't have to fight bundler installing gems 5 times.

Disadvantages:

  • We might miss a dependency, if we require it without adding it to the gemspec.

This is the same approach to multi-sub-project Gemfile management taken by rails. So I have some confidence it is okay.

class RakeTasks
include Rake::DSL

def initialize(gem_root: , lib_name:)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space found before comma.

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 nice improvement. I have one question about database dependencies. I think we don't need to load all adapters at once.

Gemfile Outdated
gemspec require: false

platforms :ruby do
gem 'mysql2'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems unnecessary for me to require all database connectors at once.
Shouldn't we only load those we actually use via ENV['DB']?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added require: false here too

jhawthorn and others added 13 commits December 6, 2017 09:42
Previously we depended on a few gems which were only found via
Bundle.require
Users who want byebug can add it to Gemfile-custom
This is necessary to pick up migrations from all loaded engines. This
worked previously because Bundler.require would require the engine.
Previously this was done through Bundler.require
Previously we initialized the dummy_app implicitly when requiring the
file. Because of this we were relying on some hacks like using
ENV['BUNDLE_GEMFILE'] to try and determine the path to the desired
spec/dummy.

To be more reliable and to allow a single Gemfile, this commit requires
the app to be explcitly initialized through a new DummyApp.setup method.
As this Gemfile is used ONLY for testing there is no reason to group the
gems by "test" and "development". Instead we can group them by project,
or by where we expect them to be run (ex. CI).
@solidusio solidusio deleted a comment from houndci-bot Dec 6, 2017
@solidusio solidusio deleted a comment from houndci-bot Dec 6, 2017
@jhawthorn jhawthorn merged commit 5bf2735 into solidusio:master Dec 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants