demarches-normaliennes/.circleci/config.yml

153 lines
3.9 KiB
YAML
Raw Normal View History

2017-04-10 16:45:31 +02:00
version: 2
2017-12-15 12:16:02 +01:00
defaults: &defaults
working_directory: ~/tps
2017-12-15 12:16:02 +01:00
docker:
- image: circleci/ruby:2.6.5-node-browsers
- 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
keys:
2020-04-23 20:16:20 +02:00
- bundle-install-v10-{{ arch }}-{{ checksum "Gemfile.lock" }}
- bundle-install-v10-{{ arch }}
- bundle-install-v10
bundle_save_cache: &bundle_save_cache
save_cache:
2018-08-01 17:18:07 +02:00
name: Save Bundler Package Cache
2020-04-23 20:16:20 +02:00
key: bundle-install-v10-{{ arch }}-{{ checksum "Gemfile.lock" }}
paths:
- ~/vendor/bundle
2017-12-15 12:16:02 +01:00
2020-04-22 11:27:33 +02:00
aptget_install: &aptget_install
run:
name: Install GEOS
command: sudo apt-get install libgeos-dev
2017-12-15 12:16:02 +01:00
bundle_install: &bundle_install
run:
name: Install Ruby Dependencies
command: bundle install --path ~/vendor/bundle
2017-12-15 12:16:02 +01:00
yarn_restore_cache: &yarn_restore_cache
restore_cache:
2018-08-01 17:18:07 +02:00
name: Restore Yarn Package Cache
keys:
- yarn-install-v3-{{ arch }}-{{ checksum "yarn.lock" }}
- yarn-install-v3-{{ arch }}
- yarn-install-v3
yarn_save_cache: &yarn_save_cache
save_cache:
2018-08-01 17:18:07 +02:00
name: Save Yarn Package Cache
key: yarn-install-v3-{{ arch }}-{{ checksum "yarn.lock" }}
paths:
2018-08-01 17:18:07 +02:00
- ~/.cache/yarn
yarn_install: &yarn_install
run:
name: Install JS Dependencies
command: yarn install --frozen-lockfile --non-interactive || yarn install --frozen-lockfile --non-interactive
2020-01-27 17:55:23 +01:00
webpacker_restore_cache: &webpacker_restore_cache
restore_cache:
name: Restore Webpacker Cache
keys:
- webpacker-v1-{{ .Branch }}-{{ .Revision }}
- webpacker-v1-{{ .Branch }}
- webpacker-v1
webpacker_save_cache: &webpacker_save_cache
save_cache:
name: Save Webpacker Cache
key: webpacker-v1-{{ .Branch }}-{{ .Revision }}
paths:
- public/packs-test
- tmp/cache/webpacker
webpacker_precompile: &webpacker_precompile
run:
environment:
RAILS_ENV: test
name: Precompile Webpack assets
command: bin/webpack
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
2020-04-22 11:27:33 +02:00
- *aptget_install
2017-12-15 12:16:02 +01:00
- *bundle_restore_cache
- *bundle_install
- *bundle_save_cache
- *yarn_restore_cache
- *yarn_install
- *yarn_save_cache
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
2020-04-22 11:27:33 +02:00
- *aptget_install
2017-12-15 12:16:02 +01:00
- *bundle_restore_cache
- *bundle_install
- *yarn_restore_cache
- *yarn_install
2020-01-27 17:55:23 +01:00
- *webpacker_restore_cache
- *webpacker_precompile
- *webpacker_save_cache
2017-04-10 16:45:31 +02:00
- run:
environment:
DATABASE_URL: "postgres://tps_test@localhost:5432/tps_test"
2020-01-27 17:55:23 +01:00
name: Create Database
2017-04-10 16:45:31 +02:00
command: bundle exec rake db:create db:schema:load db:migrate RAILS_ENV=test
2020-01-27 17:55:23 +01:00
2017-04-10 16:45:31 +02:00
- run:
environment:
DATABASE_URL: "postgres://tps_test@localhost:5432/tps_test"
name: Run Tests, Splitted by Timings
command: |
COMMAND="bundle exec rspec --profile 10 \
2017-12-15 12:16:02 +01:00
--format RspecJunitFormatter \
--out ~/test_results/rspec.xml \
2017-12-15 12:16:02 +01:00
--format progress \
$(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:
path: ~/test_results
2020-03-12 20:25:42 +01:00
- store_artifacts:
path: tmp/capybara
destination: screenshots
2017-12-15 12:16:02 +01:00
lint:
<<: *defaults
steps:
- checkout
2020-04-22 11:27:33 +02:00
- *aptget_install
2017-12-15 12:16:02 +01:00
- *bundle_restore_cache
- *bundle_install
- *yarn_restore_cache
- *yarn_install
- run:
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