From a55c03e8ca4e8dbcbac92b276e59beb2510cf64c Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Fri, 15 Dec 2017 11:51:40 +0100 Subject: [PATCH 1/4] update to Ruby 2.3.5 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3fa5a2d12..b96a5cc49 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ jobs: build: parallelism: 3 docker: - - image: ruby:2.3.1 + - image: ruby:2.3.5 - image: postgres:9.4.1 environment: POSTGRES_USER: tps_test From 40227b9f5ac54120df35608f9c12d85612b8b9ac Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Fri, 15 Dec 2017 12:16:02 +0100 Subject: [PATCH 2/4] Add workflows --- .circleci/config.yml | 104 +++++++++++++++++++++++++++++++++---------- Gemfile | 1 + 2 files changed, 82 insertions(+), 23 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b96a5cc49..e8e451eee 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,32 +1,46 @@ version: 2 + +defaults: &defaults + working_directory: /tps + docker: + - image: ruby:2.3.5 + - image: postgres:9.4.1 + environment: + POSTGRES_USER: tps_test + POSTGRES_PASSWORD: tps_test + POSTGRES_DB: tps_test + +install_system_deps: &install_system_deps + run: + name: Install System Dependencies + command: apt-get update -qq && apt-get install -y build-essential nodejs + +restore_phantomjs_cache: &restore_phantomjs_cache + restore_cache: + key: phantomjs-2-1-1 + +bundle_restore_cache: &bundle_restore_cache + restore_cache: + key: bundle-install-v4-{{ arch }}-{{ checksum "Gemfile.lock" }} + +bundle_install: &bundle_install + run: + name: Install Ruby Dependencies + command: bundle install + jobs: build: - parallelism: 3 - docker: - - image: ruby:2.3.5 - - image: postgres:9.4.1 - environment: - POSTGRES_USER: tps_test - POSTGRES_PASSWORD: tps_test - POSTGRES_DB: tps_test - - working_directory: /tps + <<: *defaults steps: - checkout - - run: - name: Install System Dependencies - command: apt-get update -qq && apt-get install -y build-essential nodejs - - restore_cache: - key: bundle-install-v3-{{ arch }}-{{ checksum "Gemfile.lock" }} - - run: - name: Install Ruby Dependencies - command: bundle install + - *install_system_deps + - *bundle_restore_cache + - *bundle_install - save_cache: - key: bundle-install-v3-{{ arch }}-{{ checksum "Gemfile.lock" }} + key: bundle-install-v4-{{ arch }}-{{ checksum "Gemfile.lock" }} paths: - /usr/local/bundle - - restore_cache: - key: phantomjs-2-1-1 + - *restore_phantomjs_cache - run: name: Install PhantomJS Dependencies command: | @@ -42,6 +56,15 @@ jobs: key: phantomjs-2-1-1 paths: - /usr/local/bin/phantomjs + test: + <<: *defaults + parallelism: 3 + steps: + - checkout + - *install_system_deps + - *restore_phantomjs_cache + - *bundle_restore_cache + - *bundle_install - run: environment: DATABASE_URL: "postgres://tps_test@localhost:5432/tps_test" @@ -52,8 +75,20 @@ jobs: DATABASE_URL: "postgres://tps_test@localhost:5432/tps_test" name: Run Tests, Splitted by Timings command: | - TESTFILES=$(circleci tests glob "spec/**/*.rb"| xargs -n 1 echo | grep -v "spec/factories/" | tr " " "\n" | circleci tests split --split-by=timings) - bundle exec rspec --color --require spec_helper -- ${TESTFILES} + bundle exec rspec --profile 10 \ + --format RspecJunitFormatter \ + --out $CIRCLE_TEST_REPORTS/rspec.xml \ + --format progress \ + $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings) + - store_test_results: + path: $CIRCLE_TEST_REPORTS/rspec.xml + lint: + <<: *defaults + steps: + - checkout + - *install_system_deps + - *bundle_restore_cache + - *bundle_install - run: name: Run rubocop command: bundle exec rubocop -R @@ -66,6 +101,13 @@ jobs: - run: name: Run scss-lint command: bundle exec scss-lint app/assets/stylesheets/ + deploy: + <<: *defaults + steps: + - checkout + - *install_system_deps + - *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" @@ -78,3 +120,19 @@ jobs: 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: + requires: + - test + - lint diff --git a/Gemfile b/Gemfile index a4378791b..fec62ee7f 100644 --- a/Gemfile +++ b/Gemfile @@ -153,4 +153,5 @@ group :development, :test do # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'dotenv-rails' + gem 'rspec_junit_formatter' end From 5e5b99885cf903fd1c74742f1b250e7bb3b26d10 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Fri, 15 Dec 2017 15:42:51 +0100 Subject: [PATCH 3/4] +1 parallelism --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e8e451eee..822903587 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -58,7 +58,7 @@ jobs: - /usr/local/bin/phantomjs test: <<: *defaults - parallelism: 3 + parallelism: 4 steps: - checkout - *install_system_deps From 820fd0a412cfd1209dbdd517750b1e27a20f1bb7 Mon Sep 17 00:00:00 2001 From: Mathieu Magnin Date: Tue, 19 Dec 2017 11:40:47 +0100 Subject: [PATCH 4/4] Deploy job is only run on dev and master --- .circleci/config.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 822903587..10807e7dd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -133,6 +133,11 @@ workflows: requires: - build - deploy: + filters: + branches: + only: + - dev + - master requires: - test - lint