From 0a9edd4c3bee31d6e674edabc21e503a8baf7216 Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Sat, 30 Aug 2025 21:09:34 +0200 Subject: [PATCH] ci(circleci): switch coverage reporting to Qlty orb (#12337) --- .circleci/config.yml | 36 ++++++++++++++---------------------- Gemfile | 3 ++- Gemfile.lock | 16 +++++++++------- spec/coverage_helper.rb | 8 ++++++++ spec/spec_helper.rb | 2 -- spec/test_helper.rb | 2 -- 6 files changed, 33 insertions(+), 34 deletions(-) create mode 100644 spec/coverage_helper.rb diff --git a/.circleci/config.yml b/.circleci/config.yml index 99795db91..65ceda04c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,7 @@ version: 2.1 orbs: node: circleci/node@6.1.0 + qlty-orb: qltysh/qlty-orb@0.0 defaults: &defaults working_directory: ~/build @@ -89,14 +90,6 @@ jobs: command: | source ~/.rvm/scripts/rvm bundle install - # pnpm install - - - run: - name: Download cc-test-reporter - command: | - mkdir -p ~/tmp - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ~/tmp/cc-test-reporter - chmod +x ~/tmp/cc-test-reporter # Swagger verification - run: @@ -108,10 +101,11 @@ jobs: echo "ERROR: The swagger.json file is not in sync with the yaml specification. Run 'rake swagger:build' and commit 'swagger/swagger.json'." exit 1 fi + mkdir -p ~/tmp curl -L https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/6.3.0/openapi-generator-cli-6.3.0.jar > ~/tmp/openapi-generator-cli-6.3.0.jar java -jar ~/tmp/openapi-generator-cli-6.3.0.jar validate -i swagger/swagger.json - # we remove the FRONTED_URL from the .env before running the tests + # Configure environment and database - run: name: Database Setup and Configure Environment Variables command: | @@ -149,17 +143,11 @@ jobs: command: pnpm run eslint - run: - name: Run frontend tests + name: Run frontend tests (with coverage) command: | mkdir -p ~/build/coverage/frontend - ~/tmp/cc-test-reporter before-build pnpm run test:coverage - - run: - name: Code Climate Test Coverage (Frontend) - command: | - ~/tmp/cc-test-reporter format-coverage -t lcov -o "~/build/coverage/frontend/codeclimate.frontend_$CIRCLE_NODE_INDEX.json" - # Run backend tests - run: name: Run backend tests @@ -167,18 +155,18 @@ jobs: mkdir -p ~/tmp/test-results/rspec mkdir -p ~/tmp/test-artifacts mkdir -p ~/build/coverage/backend - ~/tmp/cc-test-reporter before-build TESTFILES=$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings) - bundle exec rspec --format progress \ + bundle exec rspec -I ./spec --require coverage_helper --require spec_helper --format progress \ --format RspecJunitFormatter \ --out ~/tmp/test-results/rspec.xml \ -- ${TESTFILES} no_output_timeout: 30m - - run: - name: Code Climate Test Coverage (Backend) - command: | - ~/tmp/cc-test-reporter format-coverage -t simplecov -o "~/build/coverage/backend/codeclimate.$CIRCLE_NODE_INDEX.json" + # Qlty coverage publish + - qlty-orb/coverage_publish: + files: | + coverage/coverage.json + coverage/lcov.info - run: name: List coverage directory contents @@ -189,3 +177,7 @@ jobs: root: ~/build paths: - coverage + + - store_artifacts: + path: coverage + destination: coverage diff --git a/Gemfile b/Gemfile index 1148251af..03d0b62b9 100644 --- a/Gemfile +++ b/Gemfile @@ -227,6 +227,7 @@ group :test do gem 'webmock' # test profiling gem 'test-prof' + gem 'simplecov_json_formatter', require: false end group :development, :test do @@ -251,7 +252,7 @@ group :development, :test do gem 'rubocop-factory_bot', require: false gem 'seed_dump' gem 'shoulda-matchers' - gem 'simplecov', '0.17.1', require: false + gem 'simplecov', '>= 0.21', require: false gem 'spring' gem 'spring-watcher-listen' end diff --git a/Gemfile.lock b/Gemfile.lock index 26814db59..e8bccf54e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -219,7 +219,7 @@ GEM diff-lcs (1.5.1) digest-crc (0.6.5) rake (>= 12.0.0, < 14.0.0) - docile (1.4.0) + docile (1.4.1) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) dotenv (3.1.2) @@ -447,7 +447,7 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (2.12.0) + json (2.13.2) json_refs (0.1.8) hana json_schemer (0.2.24) @@ -857,11 +857,12 @@ GEM faraday (>= 0.17.5, < 3.a) jwt (>= 1.5, < 3.0) multi_json (~> 1.10) - simplecov (0.17.1) + simplecov (0.22.0) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.2) + simplecov_json_formatter (0.1.4) slack-ruby-client (2.5.2) faraday (>= 2.0) faraday-mashify @@ -1085,7 +1086,8 @@ DEPENDENCIES sidekiq (>= 7.3.1) sidekiq-cron (>= 1.12.0) sidekiq_alive - simplecov (= 0.17.1) + simplecov (>= 0.21) + simplecov_json_formatter slack-ruby-client (~> 2.5.2) spring spring-watcher-listen diff --git a/spec/coverage_helper.rb b/spec/coverage_helper.rb new file mode 100644 index 000000000..288ab87d7 --- /dev/null +++ b/spec/coverage_helper.rb @@ -0,0 +1,8 @@ +require 'simplecov' +require 'simplecov_json_formatter' + +# Configure SimpleCov to emit JSON for Qlty and HTML locally if needed +SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter +SimpleCov.start 'rails' do + SimpleCov.coverage_dir 'coverage' +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3c275aeb4..d91a22500 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,5 @@ -require 'simplecov' require 'webmock/rspec' -SimpleCov.start 'rails' WebMock.disable_net_connect!(allow_localhost: true) RSpec.configure do |config| diff --git a/spec/test_helper.rb b/spec/test_helper.rb index f657305ef..dcb5cdf93 100644 --- a/spec/test_helper.rb +++ b/spec/test_helper.rb @@ -1,6 +1,4 @@ ENV['RAILS_ENV'] ||= 'test' -require 'simplecov' -SimpleCov.start 'rails' require File.expand_path('../config/environment', __dir__) require 'rails/test_help'