2017-04-10 16:45:31 +02:00
|
|
|
version: 2
|
2017-12-15 12:16:02 +01:00
|
|
|
|
|
|
|
defaults: &defaults
|
2018-01-04 10:46:33 +01:00
|
|
|
working_directory: ~/tps
|
2017-12-15 12:16:02 +01:00
|
|
|
docker:
|
2018-01-12 13:07:48 +01:00
|
|
|
- image: circleci/ruby:2.5.0-node-browsers
|
2018-01-04 10:46:33 +01:00
|
|
|
- image: circleci/postgres:9.5
|
2017-12-15 12:16:02 +01:00
|
|
|
environment:
|
|
|
|
POSTGRES_USER: tps_test
|
|
|
|
POSTGRES_PASSWORD: tps_test
|
|
|
|
POSTGRES_DB: tps_test
|
|
|
|
|
|
|
|
bundle_restore_cache: &bundle_restore_cache
|
|
|
|
restore_cache:
|
2018-08-01 17:18:07 +02:00
|
|
|
name: Restore Bundler Package Cache
|
2018-01-31 11:26:15 +01:00
|
|
|
key: bundle-install-v8-{{ arch }}-{{ checksum "Gemfile.lock" }}
|
2018-01-04 10:46:33 +01:00
|
|
|
|
|
|
|
bundle_save_cache: &bundle_save_cache
|
|
|
|
save_cache:
|
2018-08-01 17:18:07 +02:00
|
|
|
name: Save Bundler Package Cache
|
2018-01-31 11:26:15 +01:00
|
|
|
key: bundle-install-v8-{{ arch }}-{{ checksum "Gemfile.lock" }}
|
2018-01-04 10:46:33 +01:00
|
|
|
paths:
|
|
|
|
- ~/vendor/bundle
|
2017-12-15 12:16:02 +01:00
|
|
|
|
|
|
|
bundle_install: &bundle_install
|
|
|
|
run:
|
|
|
|
name: Install Ruby Dependencies
|
2018-01-04 10:46:33 +01:00
|
|
|
command: bundle install --path ~/vendor/bundle
|
2017-12-15 12:16:02 +01:00
|
|
|
|
2018-07-12 11:50:47 +02:00
|
|
|
yarn_restore_cache: &yarn_restore_cache
|
|
|
|
restore_cache:
|
2018-08-01 17:18:07 +02:00
|
|
|
name: Restore Yarn Package Cache
|
|
|
|
key: yarn-install-v1-{{ arch }}-{{ checksum "yarn.lock" }}
|
2018-07-12 11:50:47 +02:00
|
|
|
|
|
|
|
yarn_save_cache: &yarn_save_cache
|
|
|
|
save_cache:
|
2018-08-01 17:18:07 +02:00
|
|
|
name: Save Yarn Package Cache
|
|
|
|
key: yarn-install-v1-{{ arch }}-{{ checksum "yarn.lock" }}
|
2018-07-12 11:50:47 +02:00
|
|
|
paths:
|
2018-08-01 17:18:07 +02:00
|
|
|
- ~/.cache/yarn
|
2018-07-12 11:50:47 +02:00
|
|
|
|
|
|
|
yarn_install: &yarn_install
|
|
|
|
run:
|
|
|
|
name: Install JS Dependencies
|
2018-08-01 16:37:52 +02:00
|
|
|
command: yarn install --non-interactive || yarn install --non-interactive
|
2018-07-12 11:50:47 +02:00
|
|
|
|
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
|
|
|
- *bundle_restore_cache
|
|
|
|
- *bundle_install
|
2018-01-04 10:46:33 +01:00
|
|
|
- *bundle_save_cache
|
2018-07-12 11:50:47 +02:00
|
|
|
- *yarn_restore_cache
|
|
|
|
- *yarn_save_cache
|
|
|
|
- *yarn_install
|
2017-12-15 12:16:02 +01:00
|
|
|
test:
|
|
|
|
<<: *defaults
|
2018-02-26 14:38:24 +01:00
|
|
|
parallelism: 3
|
2017-12-15 12:16:02 +01:00
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- *bundle_restore_cache
|
|
|
|
- *bundle_install
|
2018-07-12 11:50:47 +02:00
|
|
|
- *yarn_restore_cache
|
|
|
|
- *yarn_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: |
|
2018-11-14 12:13:36 +01:00
|
|
|
COMMAND="bundle exec rspec --profile 10 \
|
2017-12-15 12:16:02 +01:00
|
|
|
--format RspecJunitFormatter \
|
2018-01-04 10:46:33 +01:00
|
|
|
--out ~/test_results/rspec.xml \
|
2017-12-15 12:16:02 +01:00
|
|
|
--format progress \
|
2018-11-14 12:13:36 +01:00
|
|
|
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
|
|
|
|
echo $COMMAND
|
|
|
|
eval $COMMAND
|
2017-12-15 12:16:02 +01:00
|
|
|
- store_test_results:
|
2018-01-04 10:46:33 +01:00
|
|
|
path: ~/test_results/rspec.xml
|
2017-12-15 12:16:02 +01:00
|
|
|
lint:
|
|
|
|
<<: *defaults
|
|
|
|
steps:
|
|
|
|
- checkout
|
|
|
|
- *bundle_restore_cache
|
|
|
|
- *bundle_install
|
2018-07-12 11:50:47 +02:00
|
|
|
- *yarn_restore_cache
|
|
|
|
- *yarn_install
|
|
|
|
- run:
|
2018-08-13 14:05:16 +02:00
|
|
|
name: Run linters
|
|
|
|
command: bundle exec rake lint
|
2017-12-15 12:16:02 +01:00
|
|
|
|
|
|
|
workflows:
|
|
|
|
version: 2
|
|
|
|
build_and_test:
|
|
|
|
jobs:
|
|
|
|
- build
|
|
|
|
- test:
|
|
|
|
requires:
|
|
|
|
- build
|
|
|
|
- lint:
|
|
|
|
requires:
|
|
|
|
- build
|