141 lines
3.6 KiB
YAML
141 lines
3.6 KiB
YAML
version: 2
|
|
|
|
defaults: &defaults
|
|
working_directory: ~/tps
|
|
docker:
|
|
- image: circleci/ruby:2.5.0-node-browsers
|
|
- image: circleci/postgres:9.5
|
|
environment:
|
|
POSTGRES_USER: tps_test
|
|
POSTGRES_PASSWORD: tps_test
|
|
POSTGRES_DB: tps_test
|
|
|
|
bundle_restore_cache: &bundle_restore_cache
|
|
restore_cache:
|
|
key: bundle-install-v8-{{ arch }}-{{ checksum "Gemfile.lock" }}
|
|
|
|
bundle_save_cache: &bundle_save_cache
|
|
save_cache:
|
|
key: bundle-install-v8-{{ arch }}-{{ checksum "Gemfile.lock" }}
|
|
paths:
|
|
- ~/vendor/bundle
|
|
|
|
bundle_install: &bundle_install
|
|
run:
|
|
name: Install Ruby Dependencies
|
|
command: bundle install --path ~/vendor/bundle
|
|
|
|
yarn_restore_cache: &yarn_restore_cache
|
|
restore_cache:
|
|
key: yarn-install-v8-{{ arch }}-{{ checksum "yarn.lock" }}
|
|
|
|
yarn_save_cache: &yarn_save_cache
|
|
save_cache:
|
|
key: yarn-install-v8-{{ arch }}-{{ checksum "yarn.lock" }}
|
|
paths:
|
|
- ~/node_modules
|
|
|
|
yarn_install: &yarn_install
|
|
run:
|
|
name: Install JS Dependencies
|
|
command: yarn install --non-interactive
|
|
|
|
jobs:
|
|
build:
|
|
<<: *defaults
|
|
steps:
|
|
- checkout
|
|
- *bundle_restore_cache
|
|
- *bundle_install
|
|
- *bundle_save_cache
|
|
- *yarn_restore_cache
|
|
- *yarn_save_cache
|
|
- *yarn_install
|
|
test:
|
|
<<: *defaults
|
|
parallelism: 3
|
|
steps:
|
|
- checkout
|
|
- *bundle_restore_cache
|
|
- *bundle_install
|
|
- *yarn_restore_cache
|
|
- *yarn_install
|
|
- 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: |
|
|
bundle exec rspec --profile 10 \
|
|
--format RspecJunitFormatter \
|
|
--out ~/test_results/rspec.xml \
|
|
--format progress \
|
|
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
|
|
- store_test_results:
|
|
path: ~/test_results/rspec.xml
|
|
lint:
|
|
<<: *defaults
|
|
steps:
|
|
- checkout
|
|
- *bundle_restore_cache
|
|
- *bundle_install
|
|
- *yarn_restore_cache
|
|
- *yarn_install
|
|
- run:
|
|
name: Run eslint
|
|
command: yarn lint:js
|
|
- run:
|
|
name: Run rubocop
|
|
command: bundle exec rubocop
|
|
- run:
|
|
name: Run brakeman
|
|
command: bundle exec brakeman
|
|
- run:
|
|
name: Run haml-lint
|
|
command: bundle exec haml-lint app/views/
|
|
- run:
|
|
name: Run scss-lint
|
|
command: bundle exec scss-lint app/assets/stylesheets/
|
|
deploy:
|
|
<<: *defaults
|
|
steps:
|
|
- checkout
|
|
- *bundle_restore_cache
|
|
- *bundle_install
|
|
- add_ssh_keys:
|
|
fingerprints:
|
|
- "0a:67:42:7d:7e:b7:e1:3c:48:8f:bf:68:10:51:a8:44"
|
|
- deploy:
|
|
command: |
|
|
if [ "${CIRCLE_BRANCH}" == "dev" ]; then
|
|
bundle exec rake deploy_ha
|
|
fi
|
|
|
|
if [ "${CIRCLE_BRANCH}" == "master" ]; then
|
|
bundle exec rake deploy_ha to=production
|
|
fi
|
|
|
|
workflows:
|
|
version: 2
|
|
build_and_test:
|
|
jobs:
|
|
- build
|
|
- test:
|
|
requires:
|
|
- build
|
|
- lint:
|
|
requires:
|
|
- build
|
|
- deploy:
|
|
filters:
|
|
branches:
|
|
only:
|
|
- dev
|
|
- master
|
|
requires:
|
|
- test
|
|
- lint
|