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

Move integration tests to use inline Gemfiles #445

Open
michaelherold opened this issue Apr 27, 2018 · 4 comments
Open

Move integration tests to use inline Gemfiles #445

michaelherold opened this issue Apr 27, 2018 · 4 comments
Labels
chore hacktoberfest Issues that would be suitable for Hacktoberfest you can help!

Comments

@michaelherold
Copy link
Member

michaelherold commented Apr 27, 2018

Our integration tests currently use an external Gemfile to the test. This means that in order to onboard into contributing, you have to go through the tedious process of running bundle install within each of the integration tests' folders.

It would be great to move the Bundler configuration into using bundler/inline, like the Rails bug report templates to make them more reliable and easier to start using.

While we're at it, we could reorganize the integration specs to be single files instead of the spec/integration/<name>/integration_spec.rb pattern.

For example: spec/integration/elasticsearch/integration_spec.rb could become spec/integration/elasticsearch_spec.rb

@anew-bhav
Copy link

Hi, I am interested to contribute towards this.
I am reading about how we can use bundler inline
While I was setting up my dev environment, when I ran bundle exec rake, I was greeted with the much anticipated integration test failure messages, I got to know, what I am going to fix.

@michaelherold
Copy link
Member Author

What I'm looking for here is a simplification of our integration test setup. The implementation is a suggestion: if there's a different way you want to go about attempting it, that would be fine too.

Ideally, the variables I would like to optimize for are:

  1. It's easy to write a new integration test.
  2. It's easy to run integration tests locally.

I think that inline bundles will help with both of those, but there could be a different way to solve the problem.

@anew-bhav
Copy link

I read the Rakefile (in the root directory) and figured out how the initial setup works, when bundle exec rake is run for the first time.
I edited one of the integration tests to include an inline gemfile.
The expected behavior I suppose is that after running rspec integration_spec.rb first the required gems are installed followed by rest of the code.
I have no success as of now.

@anew-bhav
Copy link

@michaelherold
I tried the inline Gemfile approach.
It some how worked for elasticsearch/integration_ spec.rb. The presence of only the integration_spec.rb ensured that I wrote only the code for inline gem file once.

Other integration spec directories had multiple files, thus the point of eliminating the Gemfile in these directory meant writing gem requirements of each of these files at the beginning and thus doesn't looked much promising to me as writing new integration specs in future would require this to be done every time and I think is cumbersome.

I decided not to follow this.
Instead Rake itself can be used to run bundle install inside each of integration spec directories.
I am reading about Rake for a few days and turns out that it is quite powerful.

The task :integration_specs can have a prerequisite task, which runs bundle install inside each of the directories (using Bundler.with_clean_env { `bundle install` }). When this prerequisite task completes then only integration specs are evaluated.
Running bundle install creates Gemfile.lock in each directory. We put a rule on Gemfile.lock that if it doesn't exists, then only the prerequisite task runs, otherwise it continues to evaluate the specs.

What are your thoughts?

@michaelherold michaelherold added the hacktoberfest Issues that would be suitable for Hacktoberfest label Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore hacktoberfest Issues that would be suitable for Hacktoberfest you can help!
Projects
None yet
Development

No branches or pull requests

2 participants