From 5438346da160c1cabe0e00a257f18c0887576916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= <sebastien.gaya@gmail.com> Date: Fri, 23 Dec 2022 00:44:11 +0100 Subject: [PATCH] circle + coverage --- .circleci/config.yml | 86 ++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 3 ++ Gemfile | 1 + Gemfile.lock | 8 +++++ test/test_helper.rb | 3 ++ 5 files changed, 101 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..c93a968d0 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,86 @@ +version: 2 +jobs: + build: + docker: + - image: cimg/ruby:3.1.3-node + environment: + RAILS_ENV: test + RACK_ENV: test + PGHOST: localhost + PGUSER: osuny + - image: cimg/postgres:14.4 + environment: + POSTGRES_PASSWORD: "" + POSTGRES_USER: osuny + POSTGRES_DB: osuny_test + + working_directory: ~/repo + + steps: + - checkout + + # Download and cache dependencies + - restore_cache: + keys: + - v1-dependencies-{{ checksum "Gemfile.lock" }} + + # Install binaries for Active Storage Previews + - run: + name: Install binaries for Active Storage Previews + command: | + sudo apt-get update + sudo apt-get install ffmpeg poppler-utils -y + + # Bundler configuration + - run: + name: Configure Bundler + command: | + echo 'export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")' >> $BASH_ENV + source $BASH_ENV + gem install bundler + + # Restore yarn cache + - restore_cache: + keys: + - app-yarn-{{ checksum "yarn.lock" }} + + # Install gem dependencies + - run: + name: install dependencies + command: | + bundle install --jobs=4 --retry=3 --path vendor/bundle + + # Install yarn dependencies + - run: bin/yarn install + + # Store bundle cache + - save_cache: + paths: + - ./vendor/bundle + key: v1-dependencies-{{ checksum "Gemfile.lock" }} + + # Store yarn cache + - save_cache: + paths: + - ~/.yarn-cache + key: app-yarn-{{ checksum "yarn.lock" }} + + # Database setup + - run: bundle exec rake db:create db:schema:load + + # Code Climate setup + - run: curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter + - run: chmod +x ./cc-test-reporter + + # run tests! + - run: + name: run tests + command: | + bundle exec rake test $(circleci tests glob "test/**/*_test.rb" | circleci tests split --split-by=timings) + + # CodeClimate coverage + - run: ./cc-test-reporter format-coverage --output "coverage/codeclimate.$CIRCLE_NODE_INDEX.json" + + - deploy: + command: | + ./cc-test-reporter sum-coverage --output - --parts $CIRCLE_NODE_TOTAL coverage/codeclimate.*.json | ./cc-test-reporter upload-coverage --input - \ No newline at end of file diff --git a/.gitignore b/.gitignore index d077c9619..b61b1fc40 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ yarn-debug.log* # Ignore db dump /db/latest.dump + +# Ignore coverage report +coverage \ No newline at end of file diff --git a/Gemfile b/Gemfile index 1f1e26e7e..40aa0db98 100644 --- a/Gemfile +++ b/Gemfile @@ -78,6 +78,7 @@ group :test do gem 'capybara', '>= 3.26' gem 'selenium-webdriver' gem 'webdrivers' + gem "simplecov", require: false end gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/Gemfile.lock b/Gemfile.lock index 779a34435..f40ffc6b8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -172,6 +172,7 @@ GEM warden (~> 1.2.3) devise-i18n (1.10.2) devise (>= 4.8.0) + docile (1.4.0) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) encryptor (3.0.0) @@ -436,6 +437,12 @@ GEM simple_form_password_with_hints (0.0.7) rails simple_form + simplecov (0.21.2) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.4) sinatra (3.0.4) mustermann (~> 3.0) rack (~> 2.2, >= 2.2.4) @@ -558,6 +565,7 @@ DEPENDENCIES simple_form simple_form_bs5_file_input simple_form_password_with_hints + simplecov spring sprockets-rails (~> 3.4) summernote-rails! diff --git a/test/test_helper.rb b/test/test_helper.rb index 12cfc7be8..35caf4585 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,6 @@ +require 'simplecov' +SimpleCov.start 'rails' + ENV['RAILS_ENV'] ||= 'test' require_relative "../config/environment" require "rails/test_help" -- GitLab