-
Notifications
You must be signed in to change notification settings - Fork 27
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
add --create flag #21
base: master
Are you sure you want to change the base?
Conversation
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.
@travistx Thank you for your contribution and for explaining the DX problem!
What if we'll just update the documentation like in my comment below?
def self.create(count) | ||
ENV["PARALLEL_TEST_FIRST_IS_1"] = "true" | ||
command = ["bundle", "exec", "rake", "db:create", "RAILS_ENV=#{ParallelTests::Tasks.rails_env}"] | ||
args = { count: count.to_s } | ||
ParallelTests::Tasks.run_in_parallel(command, args) | ||
end |
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'm not sure if it should be added to the Runner
.
I understand it'd be nicer to reduce the number of steps on the user side. But in this case, it seems, that wrapping two commands in a bash/rake command fits better.
Create test databases | ||
|
||
```bash | ||
$ bundle exec turbo_tests --create | ||
``` |
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.
Create test databases before running tests
- Start
TEST_ENV_NUMBER
from1
export PARALLEL_TEST_FIRST_IS_1=true
- Create databases
bundle exec rake db:create RAILS_ENV=test
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.
That doesn't create the necessary test databases. That will just create a single "_test" database, not one database per cpu.
Here is your suggestion:
❯ export PARALLEL_TEST_FIRST_IS_1=true
❯ bundle exec rake db:create RAILS_ENV=test
Database 'myapp_test' already exists
Here is my suggestion with this PR:
❯ bundle exec turbo_tests --create
Database 'myapp_test5' already exists
Database 'myapp_test9' already exists
Database 'myapp_test10' already exists
Database 'myapp_test1' already exists
Database 'myapp_test3' already exists
Database 'myapp_test7' already exists
Database 'myapp_test8' already exists
Database 'myapp_test6' already exists
Database 'myapp_test2' already exists
Database 'myapp_test4' already exists
The way to do this without any changes to turbo_tests is first install the parallel_test gem as a direct dependency, and then run this:
❯ export PARALLEL_TEST_FIRST_IS_1=true
❯ bundle exec rake parallel:create
Database 'myapp_test3' already exists
Database 'myapp_test1' already exists
Database 'myapp_test9' already exists
Database 'myapp_test2' already exists
Database 'myapp_test8' already exists
Database 'myapp_test5' already exists
Database 'myapp_test6' already exists
Database 'myapp_test10' already exists
Database 'myapp_test4' already exists
Database 'myapp_test7' already exists
But the problem with this is it it requires having the parallel_tests gem installed as a direct dependency. And this is a direct dependency that is only used for the purpose of this one-time command. With my PR, the user is no longer required to install parallel_tests as a direct dependency. They can just install turbo_tests which acts as their gateway to parallel_tests.
seems reasonable to document this even if not done automatically? |
any word on this? seems like a worthwhile addition that will make first time setup easier |
It looks like this gem is going to have parallel_tests as a direct hard dependency going forward, but regardless this would still be useful to keep the commands within the same namespace, as it is odd to use some commands of parallel_tests, and others of turbo_tests. |
Improve the initial setup experience by allowing the user to run
bundle exec turbo_tests --create
to create the databases. Also add documentation regarding this new onboarding process. This may help with #12 being less of a hurdle for users coming over from parallel_tests, as well as brand new users.