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

Unable to run tests on GitHub CI #62

Open
nrgbistro opened this issue Aug 22, 2024 · 6 comments
Open

Unable to run tests on GitHub CI #62

nrgbistro opened this issue Aug 22, 2024 · 6 comments

Comments

@nrgbistro
Copy link

I'm trying to run turbo_tests on my Ruby project, which requires a postgresql database running, one for each parallel tester. It seems that running bin/rails parallel:create does not properly set the TEST_ENV_NUMBER environment variable in GitHub CI, as the output from the command is:

Database 'test_database' already exists
Database 'test_database' already exists

When I run locally, I get test_database1 and test_database2. I've made sure to set PARALLEL_TEST_FIRST_IS_1=true, but even without that the second database name should be test_database2. Could someone help me run this test suite on in a GitHub action workflow? I would prefer not to use a matrix.

@TheRoyalTnetennba
Copy link

@nrgbistro did you ever figure this out?

@nrgbistro
Copy link
Author

No I haven't, I'm currently sticking with rspec for my CI. This would be nice to have but isn't a priority for me now. Let me know if you figure it out.

@javierjulio
Copy link
Contributor

@nrgbistro have you tried using bin/rake parallel:setup instead? From what I recall the "setup" commands handle the case where if they exist they drop and recreate them but "create" won't do that I believe.

@nrgbistro
Copy link
Author

nrgbistro commented Nov 20, 2024

I just tried using parallel:setup but get the same issues:

Database 'rails_test' already exists
Database 'rails_test' already exists
psql:/home/runner/.../db/structure.sql:16: ERROR:  duplicate key value violates unique constraint "pg_extension_name_index"
DETAIL:  Key (extname)=(pg_stat_statements) already exists.
rake aborted!

It doesn't seem to ever increment the database number on CI. Any ideas on how to debug that specific behavior?

@nrgbistro
Copy link
Author

nrgbistro commented Nov 20, 2024

After significant headache, I've settled on a more manual approach to this:

- name: Set up databases
        run: |
          for i in $(seq 1 2); do
            TEST_ENV_NUMBER=$i DISABLE_SPRING=1 bin/rake db:create db:schema:load
          done

This works as expected when running bundle exec turbo_tests -n 2. I'm not 100% sure if DISABLE_SPRING is necessary but I think it fixed a bug where the environment variable was being cached.

@javierjulio
Copy link
Contributor

@nrgbistro sorry, it's hard to help without more info about your setup. I did want to suggest one thing based on your last comment though to confirm. Did you end up trying PARALLEL_TEST_FIRST_IS_1=true bin/rake parallel:setup instead? That should work both locally and in CI.

For example, in one project, this is what I use to prep and run turbo_tests in CI:

DEVISE_SECRET_KEY=sample PARALLEL_TEST_FIRST_IS_1=true bin/rake parallel:setup
bin/turbo_tests

You did update your config/database.yml file so the test database name includes <%= ENV['TEST_ENV_NUMBER'] %> right? Not sure what else I can suggest without more info.

I'd advise against using spring nowadays. I removed it shortly after adding turbo_tests, for what its worth. Although the primary reason for that was when upgrading Rails due to Zeitwerk.

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

No branches or pull requests

3 participants