Sha256: 5076308c330436c7fb129fb61c14ad35fcb7931f6934cb0b33a6ef2595f695d3

Contents?: true

Size: 1.88 KB

Versions: 7

Compression:

Stored size: 1.88 KB

Contents

unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
  namespace :ci do
    desc "Perform a build on the CI server"
    task :build => ['config', 'create_logs']  do
      begin
        Rake::Task['appstats:install:migrations'].invoke
        Rake::Task['db:migrate'].invoke
        Rake::Task['db:test:prepare'].invoke
        Rake::Task['spec'].invoke
        Rake::Task['metrics:all'].invoke
        Rake::Task['ci:success'].invoke
      rescue Exception => e
        Rake::Task['ci:failure'].invoke
        raise e
      end
    end

    desc "Setup the correct database configuration files"
    task :config do
      source_db_file = '/cenx/appstats/sensitive/config.yml'
      dest_db_file = "#{Dir.pwd}/db/config.yml"
      abort "No database file [#{source_db_file}], unable to continue CI build" unless File.exists? source_db_file
      FileUtils.cp source_db_file, dest_db_file, :preserve => false
    end

    desc "Create log files that are used when running tests"
    task :create_logs do
      if not File.exists?('log') then
        FileUtils.mkdir 'log'
      else
        if not File.directory?('log') then
          FileUtils.rm 'log'
          FileUtils.mkdir 'log'
        end
      end
      [4, 7, 8].each do |i|
        FileUtils.touch "log/appstats_remote_log_2#{i}.log"
      end
    end

    desc "Testing the environment"
    task :test do
      system('ruby -r rubygems -e "p Gem.path"')
    end

    desc "The Build Succeeded, so tell our monitoring service"
    task :success do
      FileUtils.cp '/home/deployer/monitor/statuses/Appstats.cc.success', '/home/deployer/monitor/log/Appstats.cc', :preserve => false
    end

    desc "The Build failed, so tell our monitoring service"
    task :failure do
      FileUtils.cp '/home/deployer/monitor/statuses/Appstats.cc.failure', '/home/deployer/monitor/log/Appstats.cc', :preserve => false
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
appstats-0.17.5 lib/appstats/ci.rake
appstats-0.17.4 lib/appstats/ci.rake
appstats-0.17.3 lib/appstats/ci.rake
appstats-0.17.2 lib/appstats/ci.rake
appstats-0.17.1 lib/appstats/ci.rake
appstats-0.17.0 lib/appstats/ci.rake
appstats-0.16.7 lib/appstats/ci.rake