Background
I have a few ruby gems that run tests for a few databases. They all follow the same pattern.
Now
I start up mysql
and postgres
services for all test matrix entries.
Request
I would like to find a way to only run the services that I need.
using service
works for mysql and postgres. using systemctl
works for mysql but not for postgres.
Anyone with an idea how I can only spawn the necessary service?
Thanks for the great service,
Keenan
Current
---
sudo: false
language: ruby
cache: bundler
rvm:
- 2.5.5
services:
- mysql
- postgresql
env:
- DB=mysql2
- DB=pg
- DB=sqlite3
gemfile:
- gemfiles/gemfile_50.gemfile
- gemfiles/gemfile_51.gemfile
- gemfiles/gemfile_52.gemfile
- gemfiles/gemfile_60.gemfile
before_script:
- [ $DB = "mysql2" ] && mysql -e 'create database hash_options_test;' || true
- [ $DB = "pg" ] && psql -c 'create database hash_options_test;' -U postgres || true
Failure A
The current travis scripts call the command travis_setup_postgresql && postgresql@9.6-main
but they are not availble to me from before_script1
. I would like to use what ever is defined in the services:
list.
---
sudo: false
language: ruby
cache: bundler
rvm:
- 2.5.3
env:
- DB=mysql2
- DB=pg
- DB=sqlite3
gemfile:
- gemfiles/gemfile_50.gemfile
- gemfiles/gemfile_51.gemfile
- gemfiles/gemfile_52.gemfile
- gemfiles/gemfile_60.gemfile
before_script:
- sh -c "[ '$DB' = 'mysql2' ] && sudo systemctl start mysql && mysql -e 'create database hash_options_test;' || true"
- sh -c "[ '$DB' = 'pg' ] && sudo systemctl start postgresql && psql -c 'create database hash_options_test;' -U postgres || true"
Failure 2
Tried to get services linked into the test matrix. under the env:
section seems to make the most sense to me.
---
sudo: false
language: ruby
cache: bundler
rvm:
- 2.5.3
env:
- DB=mysql2
services: mysql
- DB=pg
services: postgres
- DB=sqlite3
gemfile:
- gemfiles/gemfile_50.gemfile
- gemfiles/gemfile_51.gemfile
- gemfiles/gemfile_52.gemfile
- gemfiles/gemfile_60.gemfile
before_script:
- sh -c "[ '$DB' = 'mysql2' ] && mysql -e 'create database hash_options_test;' || true"
- sh -c "[ '$DB' = 'pg' ] && psql -c 'create database hash_options_test;' -U postgres || true"