ensl.org/.circleci/config.yml

128 lines
3.9 KiB
YAML
Raw Normal View History

2020-03-23 22:51:23 +00:00
version: 2
references:
default_docker_ruby_executor: &default_docker_ruby_executor
image: circleci/ruby:2.6.5-buster-node-browsers
environment:
2020-03-24 21:44:36 +00:00
BUNDLE_JOBS: '3'
BUNDLE_RETRY: '3'
BUNDLE_PATH: vendor/bundle
2020-03-23 22:51:23 +00:00
RACK_ENV: test
RAILS_ENV: test
2020-03-24 21:44:36 +00:00
MYSQL_HOST: '127.0.0.1'
2020-03-24 21:09:24 +00:00
mariadb: &mariadb
2020-03-24 21:30:21 +00:00
image: circleci/mariadb:10.1.44
2020-03-23 22:51:23 +00:00
environment:
2020-03-24 21:20:41 +00:00
MYSQL_DATABASE: ensl_test
2020-03-23 22:51:23 +00:00
MYSQL_USER: ensl
MYSQL_PASSWORD: ensl
MYSQL_ROOT_PASSWORD: ensl
2020-03-23 23:03:05 +00:00
MYSQL_ROOT_HOST: "%"
2020-03-23 22:51:23 +00:00
jobs:
build:
2020-03-24 22:27:06 +00:00
environment:
CC_TEST_REPORTER_ID: b3db5b7df9a0a1d0fd3503e72d7431ffbfa172492c2840d590ccb2fafd9172d3
RAILS_ENV: test
RACK_ENV: test
2020-03-23 22:51:23 +00:00
docker:
- *default_docker_ruby_executor
steps:
- checkout
2020-03-23 23:24:16 +00:00
- run:
name: Bundle Update
2020-03-24 21:04:36 +00:00
command: gem update --system && gem install bundler
2020-03-23 22:51:23 +00:00
# Which version of bundler?
- run:
name: Which bundler?
command: bundle -v
# bundle cache
- restore_cache:
keys:
- rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }}
- rails-demo-bundle-v2-
- run:
name: Bundle Install
command: bundle check || bundle install
# Store bundle cache
- save_cache:
key: rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
2020-03-24 22:35:26 +00:00
# - run:
# name: Setup dependencies
# command: |
# sudo composer self-update
# composer install -n --prefer-dist
2020-03-24 22:27:06 +00:00
# download test reporter as a static binary
2020-03-24 22:46:05 +00:00
# - run:
# name: Setup Code Climate test-reporter
# command: |
# curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
# chmod +x ./cc-test-reporter
2020-03-23 22:51:23 +00:00
# Only necessary if app uses webpacker or yarn in some other way
2020-03-23 23:39:26 +00:00
#- restore_cache:
# keys:
# - rails-demo-yarn-{{ checksum "yarn.lock" }}
# - rails-demo-yarn-
#- run:
# name: Yarn Install
# command: yarn install --cache-folder ~/.cache/yarn
2020-03-23 22:51:23 +00:00
# Store yarn / webpacker cache
2020-03-23 23:39:26 +00:00
#- save_cache:
# key: rails-demo-yarn-{{ checksum "yarn.lock" }}
# paths:
# - ~/.cache/yarn
2020-03-23 22:51:23 +00:00
test:
parallelism: 3
docker:
- *default_docker_ruby_executor
2020-03-24 21:09:24 +00:00
- *mariadb
2020-03-23 22:51:23 +00:00
steps:
2020-03-23 23:08:55 +00:00
- add_ssh_keys:
fingerprints:
- "b7:35:a6:4e:9b:0d:6d:d4:78:1e:9a:97:2a:66:6b:be"
2020-03-23 22:51:23 +00:00
- checkout
2020-03-23 23:36:47 +00:00
- run:
name: Bundle Update
command: gem update --system && gem install bundler
2020-03-23 22:51:23 +00:00
- restore_cache:
keys:
- rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }}
- rails-demo-bundle-v2-
- run:
name: Bundle Install
command: bundle check || bundle install
2020-03-23 23:39:26 +00:00
#- restore_cache:
# keys:
# - rails-demo-yarn-{{ checksum "yarn.lock" }}
# - rails-demo-yarn-
2020-03-23 22:51:23 +00:00
- run:
name: Wait for DB
command: dockerize -wait tcp://localhost:3306 -timeout 1m
- run:
name: Database setup
2020-03-26 01:58:59 +00:00
command: bundle exec rake db:test:prepare --trace
2020-03-23 22:51:23 +00:00
# Run rspec in parallel
2020-03-24 22:48:50 +00:00
# ./cc-test-reporter before-build
# ./cc-test-reporter after-build --coverage-input-type clover --exit-code $?
2020-03-23 22:51:23 +00:00
- run:
command: |
mkdir /tmp/test-results
TESTFILES=$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
2020-03-24 21:58:47 +00:00
bundle exec rspec $TESTFILES --profile 10 -r rspec_junit_formatter --format RspecJunitFormatter --out /tmp/test-results/rspec.xml --format progress
2020-03-23 22:51:23 +00:00
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
destination: test-results
workflows:
version: 2
build_and_test:
jobs:
- build
- test:
requires:
- build