aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tasks/ci.rake
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tasks/ci.rake')
-rw-r--r--lib/tasks/ci.rake43
1 files changed, 34 insertions, 9 deletions
diff --git a/lib/tasks/ci.rake b/lib/tasks/ci.rake
index 89f9aa9c8..cb9ed77e7 100644
--- a/lib/tasks/ci.rake
+++ b/lib/tasks/ci.rake
@@ -1,9 +1,19 @@
namespace :ci do
+
+ def database_name
+ @database_name ||=
+ begin
+ config = YAML.load(ERB.new(File.read('config/database.yml')).result)
+ config["test"]["database"]
+ end
+ end
+
desc "Prepare CI build"
task :setup do
- cp "config/database/jenkins.yml", "config/database.yml"
+ cp "config/database.yml", "config/database.yml.orig"
+ cp "config/database/ci.yml", "config/database.yml"
+ puts "Use #{database_name} database"
sh "RAILS_ENV=test rake db:drop db:create db:migrate"
- sh "yarn --no-progress install"
end
def git_branch
@@ -19,6 +29,7 @@ namespace :ci do
end
def deploy_env
+ return ENV["DEPLOY_ENV"] if ENV["DEPLOY_ENV"]
if git_branch == "master"
"dev"
elsif git_branch.in?(deploy_envs)
@@ -45,12 +56,12 @@ namespace :ci do
desc "Deploy after CI"
task :deploy do
- return if ENV["CHOUETTE_DEPLOY_DISABLED"]
-
- if deploy_env
- sh "cap #{deploy_env} deploy:migrations"
- else
- puts "No deploy for branch #{git_branch}"
+ unless ENV["CHOUETTE_DEPLOY_DISABLED"]
+ if deploy_env
+ sh "cap #{deploy_env} deploy:migrations deploy:seed"
+ else
+ puts "No deploy for branch #{git_branch}"
+ end
end
end
@@ -59,7 +70,21 @@ namespace :ci do
sh "rm -rf log/test.log"
sh "RAILS_ENV=test bundle exec rake assets:clobber"
end
+
+ task :build => ["ci:setup", "ci:assets", "ci:i18n_js_export", "spec", "ci:jest", "cucumber", "ci:check_security"]
+
+ namespace :docker do
+ task :clean do
+ puts "Drop #{database_name} database"
+ sh "RAILS_ENV=test rake db:drop"
+
+ # Restore projet config/database.yml
+ # cp "config/database.yml.orig", "config/database.yml" if File.exists?("config/database.yml.orig")
+ end
+ end
+
+ task :docker => ["ci:build"]
end
desc "Run continuous integration tasks (spec, ...)"
-task :ci => ["ci:setup", "ci:assets", "ci:i18n_js_export", "spec", "ci:jest", "cucumber", "ci:check_security", "ci:deploy", "ci:clean"]
+task :ci => ["ci:build", "ci:deploy", "ci:clean"]