From 92ee3f9ba4d8dfe18677b2df95026b0ca45093ad Mon Sep 17 00:00:00 2001 From: Ari Timonen Date: Tue, 24 Mar 2020 00:51:23 +0200 Subject: [PATCH] Try circle CI integration --- .circleci/config.yml | 98 ++++++++++++++++++++++++++++++++++++++++++++ circle.yml | 4 -- 2 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 circle.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..7b1c8f6 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,98 @@ +version: 2 + +references: + default_docker_ruby_executor: &default_docker_ruby_executor + image: circleci/ruby:2.6.5-buster-node-browsers + environment: + RACK_ENV: test + RAILS_ENV: test + mysql: &mysql + image: cricleci/mysql:latest + environment: + MYSQL_DATABASE: ensl + MYSQL_USER: ensl + MYSQL_USERNAME: ensl + MYSQL_PASSWORD: ensl + MYSQL_ROOT_PASSWORD: ensl + MYSQL_ROOT_HOST: % + +jobs: + build: + docker: + - *default_docker_ruby_executor + steps: + - checkout + # 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 + # Only necessary if app uses webpacker or yarn in some other way + - restore_cache: + keys: + - rails-demo-yarn-{{ checksum "yarn.lock" }} + - rails-demo-yarn- + - run: + name: Yarn Install + command: yarn install --cache-folder ~/.cache/yarn + # Store yarn / webpacker cache + - save_cache: + key: rails-demo-yarn-{{ checksum "yarn.lock" }} + paths: + - ~/.cache/yarn + test: + parallelism: 3 + docker: + - *default_docker_ruby_executor + - *mysql + steps: + - checkout + - restore_cache: + keys: + - rails-demo-bundle-v2-{{ checksum "Gemfile.lock" }} + - rails-demo-bundle-v2- + - run: + name: Bundle Install + command: bundle check || bundle install + - restore_cache: + keys: + - rails-demo-yarn-{{ checksum "yarn.lock" }} + - rails-demo-yarn- + - run: + name: Wait for DB + command: dockerize -wait tcp://localhost:3306 -timeout 1m + - run: + name: Database setup + command: bundle exec rails db:schema:load --trace + # Run rspec in parallel + - run: + command: | + mkdir /tmp/test-results + TESTFILES=$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings) + bundle exec rspec $TESTFILES --profile 10 --format RspecJunitFormatter --out /tmp/test-results/rspec.xml --format progress + - 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 diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 4a2665c..0000000 --- a/circle.yml +++ /dev/null @@ -1,4 +0,0 @@ -database: - override: - - mv config/database.circle.yml config/database.yml - - bundle exec rake db:create db:schema:load --trace