2017-04-10 16:45:31 +02:00
|
|
|
version: 2
|
2017-12-15 12:16:02 +01:00
|
|
|
|
|
|
|
defaults: &defaults
|
|
|
|
working_directory: /tps
|
|
|
|
docker:
|
|
|
|
- image: ruby:2.3.5
|
|
|
|
- image: postgres:9.4.1
|
|
|
|
environment:
|
|
|
|
POSTGRES_USER: tps_test
|
|
|
|
POSTGRES_PASSWORD: tps_test
|
|
|
|
POSTGRES_DB: tps_test
|
|
|
|
|
|
|
|
install_system_deps: &install_system_deps
|
|
|
|
run:
|
|
|
|
name: Install System Dependencies
|
|
|
|
command: apt-get update -qq && apt-get install -y build-essential nodejs
|
|
|
|
|
|
|
|
restore_phantomjs_cache: &restore_phantomjs_cache
|
|
|
|
restore_cache:
|
|
|
|
key: phantomjs-2-1-1
|
|
|
|
|
|
|
|
bundle_restore_cache: &bundle_restore_cache
|
|
|
|
restore_cache:
|
|
|
|
key: bundle-install-v4-{{ arch }}-{{ checksum "Gemfile.lock" }}
|
|
|
|
|
|
|
|
bundle_install: &bundle_install
|
|
|
|
run:
|
|
|
|
name: Install Ruby Dependencies
|
|
|
|
command: bundle install
|
|
|
|
|
2017-04-10 16:45:31 +02:00
|
|
|
jobs:
|
|
|
|
build:
|
2017-12-15 12:16:02 +01:00
|
|
|
<<: *defaults
|
2017-04-10 16:45:31 +02:00
|
|
|
steps:
|
|
|
|
- checkout
|
2017-12-15 12:16:02 +01:00
|
|
|
- *install_system_deps
|
|
|
|
- *bundle_restore_cache
|
|
|
|
- *bundle_install
|
2017-04-10 16:45:31 +02:00
|
|
|
- save_cache:
|
2017-12-15 12:16:02 +01:00
|
|
|
key: bundle-install-v4-{{ arch }}-{{ checksum "Gemfile.lock" }}
|
2017-04-10 16:45:31 +02:00
|
|
|
paths:
|
|
|
|
- /usr/local/bundle
|
2017-12-15 12:16:02 +01:00
|
|
|
- *restore_phantomjs_cache
|
2017-04-10 16:45:31 +02:00
|
|
|
- run:
|
|
|
|
name: Install PhantomJS Dependencies
|
|
|
|
command: |
|
|
|
|
[ -f /usr/local/bin/phantomjs ] || apt-get update
|
|
|
|
[ -f /usr/local/bin/phantomjs ] || apt-get install -y fontconfig wget
|
|
|
|
- run:
|
|
|
|
name: Install PhantomJS
|
|
|
|
command: |
|
|
|
|
[ -f /usr/local/bin/phantomjs ] || wget -O /tmp/phantomjs.tar.bz2 https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
|
|
|
|
[ -f /usr/local/bin/phantomjs ] || tar -xjf /tmp/phantomjs.tar.bz2 -C /tmp
|
|
|
|
[ -f /usr/local/bin/phantomjs ] || mv /tmp/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs
|
|
|
|
- save_cache:
|
|
|
|
key: phantomjs-2-1-1
|
|
|
|
paths:
|
|
|
|
- /usr/local/bin/phantomjs
|
2017-12-15 12:16:02 +01:00
|
|
|
test:
|
|
|
|
<<: *defaults
|
2017-12-15 15:42:51 +01:00
|
|
|
parallelism: 4
|
2017-12-15 12:16:02 +01:00
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- *install_system_deps
|
|
|
|
- *restore_phantomjs_cache
|
|
|
|
- *bundle_restore_cache
|
|
|
|
- *bundle_install
|
2017-04-10 16:45:31 +02:00
|
|
|
- run:
|
|
|
|
environment:
|
|
|
|
DATABASE_URL: "postgres://tps_test@localhost:5432/tps_test"
|
|
|
|
name: Create DB
|
|
|
|
command: bundle exec rake db:create db:schema:load db:migrate RAILS_ENV=test
|
|
|
|
- run:
|
|
|
|
environment:
|
|
|
|
DATABASE_URL: "postgres://tps_test@localhost:5432/tps_test"
|
|
|
|
name: Run Tests, Splitted by Timings
|
|
|
|
command: |
|
2017-12-15 12:16:02 +01:00
|
|
|
bundle exec rspec --profile 10 \
|
|
|
|
--format RspecJunitFormatter \
|
|
|
|
--out $CIRCLE_TEST_REPORTS/rspec.xml \
|
|
|
|
--format progress \
|
|
|
|
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
|
|
|
|
- store_test_results:
|
|
|
|
path: $CIRCLE_TEST_REPORTS/rspec.xml
|
|
|
|
lint:
|
|
|
|
<<: *defaults
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- *install_system_deps
|
|
|
|
- *bundle_restore_cache
|
|
|
|
- *bundle_install
|
2017-06-13 10:58:46 +02:00
|
|
|
- run:
|
|
|
|
name: Run rubocop
|
2017-07-13 10:13:55 +02:00
|
|
|
command: bundle exec rubocop -R
|
2017-07-20 15:01:21 +02:00
|
|
|
- run:
|
|
|
|
name: Run brakeman
|
|
|
|
command: bundle exec brakeman -z
|
2017-04-10 16:45:31 +02:00
|
|
|
- run:
|
|
|
|
name: Run haml-lint
|
|
|
|
command: bundle exec haml-lint app/views/
|
2017-04-11 17:20:23 +02:00
|
|
|
- run:
|
|
|
|
name: Run scss-lint
|
|
|
|
command: bundle exec scss-lint app/assets/stylesheets/
|
2017-12-15 12:16:02 +01:00
|
|
|
deploy:
|
|
|
|
<<: *defaults
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- *install_system_deps
|
|
|
|
- *bundle_restore_cache
|
|
|
|
- *bundle_install
|
2017-04-13 09:25:34 +02:00
|
|
|
- add_ssh_keys:
|
|
|
|
fingerprints:
|
|
|
|
- "0a:67:42:7d:7e:b7:e1:3c:48:8f:bf:68:10:51:a8:44"
|
2017-04-10 16:45:31 +02:00
|
|
|
- deploy:
|
|
|
|
command: |
|
2017-07-05 14:41:00 +02:00
|
|
|
if [ "${CIRCLE_BRANCH}" == "dev" ]; then
|
2017-04-10 16:45:31 +02:00
|
|
|
bundle exec rake deploy_ha
|
|
|
|
fi
|
2017-04-13 11:55:11 +02:00
|
|
|
|
|
|
|
if [ "${CIRCLE_BRANCH}" == "master" ]; then
|
|
|
|
bundle exec rake deploy_ha to=production
|
|
|
|
fi
|
2017-12-15 12:16:02 +01:00
|
|
|
|
|
|
|
workflows:
|
|
|
|
version: 2
|
|
|
|
build_and_test:
|
|
|
|
jobs:
|
|
|
|
- build
|
|
|
|
- test:
|
|
|
|
requires:
|
|
|
|
- build
|
|
|
|
- lint:
|
|
|
|
requires:
|
|
|
|
- build
|
|
|
|
- deploy:
|
2017-12-19 11:40:47 +01:00
|
|
|
filters:
|
|
|
|
branches:
|
|
|
|
only:
|
|
|
|
- dev
|
|
|
|
- master
|
2017-12-15 12:16:02 +01:00
|
|
|
requires:
|
|
|
|
- test
|
|
|
|
- lint
|