blob: 52bab7aa4e7db3dfa4129b8b8bd7ed1791c8d60c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
namespace :ci do
desc "Prepare CI build"
task :setup do
cp "config/database/jenkins.yml", "config/database.yml"
sh "RAILS_ENV=test rake db:migrate"
sh "npm install"
end
def git_branch
if ENV['GIT_BRANCH'] =~ %r{/(.*)$}
$1
else
`git rev-parse --abbrev-ref HEAD`.strip
end
end
def deploy_envs
Dir["config/deploy/*.rb"].map { |f| File.basename(f, ".rb") }
end
def deploy_env
git_branch.in?(deploy_envs) ? git_branch : "dev"
end
desc "Check security aspects"
task :check_security do
sh "bundle exec bundle-audit check --update"
end
desc "Deploy after CI"
task :deploy do
sh "cap #{deploy_env} deploy:migrations deploy:seed"
end
desc "Clean test files"
task :clean do
sh "rm -rf log/test.log"
end
end
desc "Run continuous integration tasks (spec, ...)"
task :ci => ["ci:setup", "spec", "cucumber", "ci:deploy", "ci:clean"]
# task :ci => ["ci:setup", "spec", "cucumber", "ci:check_security", "ci:deploy", "ci:clean"]
|