From d6ae95e18ceee3e3bcb78577ec66d423a87f3219 Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Tue, 25 Mar 2014 21:58:51 +0000 Subject: [PATCH] Update travis config to cache bundler Fallback to older rails I18n behaviour Silence deprecation warnings, for now Added code climate test reporter Created CI deployment task Added *all* the badges --- .travis.yml | 5 ++++- Gemfile | 1 + Gemfile.lock | 3 +++ README.md | 6 +++++- Rakefile | 5 ----- config/application.rb | 1 + config/environment.rb | 3 +-- lib/tasks/ci.rake | 22 ++++++++++++++++++++++ spec/spec_helper.rb | 2 ++ 9 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 lib/tasks/ci.rake diff --git a/.travis.yml b/.travis.yml index ef4b865..e38065c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,10 @@ language: ruby +cache: bundler rvm: - 2.1.1 env: + - CODECLIMATE_REPO_TOKEN=b3db5b7df9a0a1d0fd3503e72d7431ffbfa172492c2840d590ccb2fafd9172d3 - MYSQL_USERNAME=travis script: - - RAILS_ENV=test bundle exec rake db:create db:migrate db:test:prepare \ No newline at end of file + - RAILS_ENV=test bundle exec rake db:create db:migrate db:test:prepare + - RAILS_ENV=test bundle exec rspec spec diff --git a/Gemfile b/Gemfile index 02faf4f..78191a3 100644 --- a/Gemfile +++ b/Gemfile @@ -37,6 +37,7 @@ end group :test do gem 'simplecov', '~> 0.7.1', require: false + gem 'codeclimate-test-reporter', '~> 0.3.0', require: nil gem 'rspec-rails', '~> 2.14.1' gem 'rspec-given', '~> 3.5.4' gem 'capybara', '~> 2.2.1' diff --git a/Gemfile.lock b/Gemfile.lock index 0b08208..adbb2c9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -69,6 +69,8 @@ GEM json (>= 1.7) mime-types (>= 1.16) cliver (0.3.2) + codeclimate-test-reporter (0.3.0) + simplecov (>= 0.7.1, < 1.0.0) coderay (1.1.0) coffee-rails (3.2.2) coffee-script (>= 2.2.0) @@ -254,6 +256,7 @@ DEPENDENCIES capistrano3-unicorn (~> 0.1.1) capybara (~> 2.2.1) carrierwave (~> 0.10.0) + codeclimate-test-reporter (~> 0.3.0) coffee-rails (~> 3.2.2) dalli (~> 2.7.0) dotenv-rails (~> 0.10.0) diff --git a/README.md b/README.md index 476538e..414f630 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ +[![Build Status](https://travis-ci.org/ENSL/ensl.org.svg?branch=master)](https://travis-ci.org/ENSL/ensl.org) +[![Code Climate](https://codeclimate.com/github/ENSL/ensl.org.png)](https://codeclimate.com/github/ENSL/ensl.org) +[![Code Climate](https://codeclimate.com/github/ENSL/ensl.org/coverage.png)](https://codeclimate.com/github/ENSL/ensl.org) + # ENSL Website -This is the source code of ENSL website. Currently deployed on [European NS League](http://www.ensl.org). +This is the source code of ENSL website. Currently deployed on [ensl.org](http://www.ensl.org). Features: diff --git a/Rakefile b/Rakefile index a77116d..4c40c34 100644 --- a/Rakefile +++ b/Rakefile @@ -1,8 +1,3 @@ -# Add your own tasks in files placed in lib/tasks ending in .rake, -# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. - - - require File.expand_path('../config/application', __FILE__) require 'rake/dsl_definition' diff --git a/config/application.rb b/config/application.rb index dcb7982..6ef6ad8 100644 --- a/config/application.rb +++ b/config/application.rb @@ -38,6 +38,7 @@ module Ensl # il8n fix config.i18n.fallbacks = true + config.i18n.enforce_available_locales = false # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' diff --git a/config/environment.rb b/config/environment.rb index 5638ecb..cf06d20 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -3,6 +3,5 @@ require 'verification' require 'exceptions' require 'extra' -ActiveSupport::Deprecation.silenced = true if ['staging', 'production'].include?(ENV['RAILS_ENV']) - +ActiveSupport::Deprecation.silenced = true Ensl::Application.initialize! diff --git a/lib/tasks/ci.rake b/lib/tasks/ci.rake new file mode 100644 index 0000000..1ffebb7 --- /dev/null +++ b/lib/tasks/ci.rake @@ -0,0 +1,22 @@ +namespace :ci do + task :deploy do + require 'rubygems' + require 'capistrano/all' + require 'capistrano/setup' + require 'capistrano/deploy' + + if ci_branch = ENV['TRAVIS_BRANCH'] + BRANCH_MAP = { + # 'master' => 'production' + 'develop' => 'staging' + } + + if BRANCH_MAP.include?(ci_branch) + Capistrano::Application.invoke(BRANCH_MAP[ci_branch]) + Capistrano::Application.invoke("deploy") + end + else + raise "Failed to deploy: Rake task called outside of CI environment" + end + end +end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7b5faf7..7ec93df 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,8 @@ ENV["RAILS_ENV"] ||= 'test' +require 'codeclimate-test-reporter' require 'simplecov' +CodeClimate::TestReporter.start SimpleCov.start 'rails' require File.expand_path("../../config/environment", __FILE__)