Replace DB environment variable with optional bundler groups

See the changes to the changelog for more details
This commit is contained in:
Jonne Haß 2015-05-29 01:11:51 +02:00
parent 351f54d74f
commit c85fe3872e
8 changed files with 41 additions and 27 deletions

View file

@ -5,9 +5,9 @@ rvm:
- 2.1
env:
- DB=postgres BUILD_TYPE=other
- DB=postgresql BUILD_TYPE=other
- DB=mysql BUILD_TYPE=other
- DB=postgres BUILD_TYPE=cucumber
- DB=postgresql BUILD_TYPE=cucumber
- DB=mysql BUILD_TYPE=cucumber
sudo: false
@ -23,7 +23,7 @@ branches:
- 'develop'
before_install: gem install bundler
bundler_args: "--without development production heroku --jobs 3 --retry 3"
bundler_args: "--deployment --without development production --with mysql postgresql --jobs 3 --retry 3"
script: "./script/ci/build.sh"

View file

@ -1,5 +1,19 @@
# 0.6.0.0
## The DB environment variable is gone
With Bundler 1.10 supporting optional groups, we removed the DB environment variable. When updating to this release, please update
bundler and select the database support you want:
```sh
gem install bundler
bundle install --with mysql # For MySQL and MariaDB
bundle install --with postgresql # For PostgreSQL
```
For production setups we now additionally recommend adding the `--deployment` flag.
If you set the DB environment variable anywhere, that's no longer necessary.
## Supported Ruby versions
This release recommends using Ruby 2.2, while retaining Ruby 2.1 as an officially supported version.

10
Gemfile
View file

@ -60,10 +60,12 @@ gem "autoprefixer-rails", "5.1.11"
# Database
ENV["DB"] ||= "mysql"
gem "mysql2", "0.3.18" if ENV["DB"] == "all" || ENV["DB"] == "mysql"
gem "pg", "0.18.1" if ENV["DB"] == "all" || ENV["DB"] == "postgres"
group :mysql, optional: true do
gem "mysql2", "0.3.18"
end
group :postgresql, optional: true do
gem "pg", "0.18.1"
end
gem "activerecord-import", "0.7.0"

View file

@ -463,6 +463,7 @@ GEM
orm_adapter (0.5.0)
parser (2.2.2.2)
ast (>= 1.1, < 3.0)
pg (0.18.1)
phantomjs (1.9.8.0)
powerpack (0.1.1)
pry (0.10.1)
@ -785,6 +786,7 @@ DEPENDENCIES
omniauth-twitter (= 1.0.1)
omniauth-wordpress (= 0.2.1)
open_graph_reader (= 0.6.1)
pg (= 0.18.1)
pry
pry-byebug
pry-debundle
@ -850,3 +852,6 @@ DEPENDENCIES
uuid (= 2.3.7)
webmock (= 1.21.0)
will_paginate (= 3.0.7)
BUNDLED WITH
1.10.0

View file

@ -1,3 +1,11 @@
postgresql: &postgresql
adapter: postgresql
host: localhost
port: 5432
username: postgres
password:
encoding: unicode
mysql: &mysql
adapter: mysql2
host: "localhost"
@ -8,20 +16,13 @@ mysql: &mysql
encoding: utf8mb4
collation: utf8mb4_bin
postgres: &postgres
adapter: postgresql
host: localhost
port: 5432
username: postgres
password:
encoding: unicode
# Comment the the mysql line and uncomment the postgres line
# if you want to use postgres
common: &common
# Choose one of the following
<<: *mysql
#<<: *postgres
<<: *postgresql
#<<: *mysql
# Should match environment.sidekiq.concurrency
#pool: 25
@ -32,9 +33,6 @@ common: &common
# Normally you don't need to touch anything here
postgres_travis: &postgres_travis
adapter: postgresql
username: postgres
combined: &combined
<<: *common
development:

View file

@ -7,7 +7,7 @@ end
Eye.application("diaspora") do
working_dir Rails.root.to_s
env "DB" => ENV["DB"], "RAILS_ENV" => rails_env
env "RAILS_ENV" => rails_env
stdout "log/eye_processes_stdout.log" unless rails_env == "development"
stderr "log/eye_processes_stderr.log"

View file

@ -4,8 +4,8 @@
# Create a database.yml for the right database
echo "Setting up database.yml for $DB"
cp config/database.yml.example config/database.yml
if [ "$DB" = "postgres" ]; then
sed -i 's/*common/*postgres_travis/' config/database.yml
if [ "$DB" = "mysql" ]; then
sed -i 's/*common/*mysql/' config/database.yml
fi
command="bundle exec rake --trace ci:travis:${BUILD_TYPE}"

View file

@ -113,11 +113,6 @@ vars=$(bin/bundle exec ruby ./script/get_config.rb \
on_failure "Couldn't parse config/diaspora.yml!"
eval "$vars"
if [ -n "$DB" ]
then
export DB
fi
args="$@"
for arg in $(echo $args | awk '{ for (i = 1; i <= NF; i++) print $i}')
do