From 086ce58298c2a05f04b1c0da8263758aae17169c Mon Sep 17 00:00:00 2001 From: Bob Dev Date: Fri, 3 Jul 2026 21:39:42 +0000 Subject: [PATCH 1/4] Replace Codecov with Qlty for code quality and coverage - Add qlty config via `qlty init` with reek and pinned rubocop - Replace codecov gem with simplecov + simplecov_json_formatter - Update spec_helper to use COVERAGE env var with JSON+HTML formatters - Add coverage upload step to CircleCI after unit tests Co-Authored-By: Claude Sonnet 4.5 --- .circleci/config.yml | 7 ++++ .qlty/qlty.toml | 95 ++++++++++++++++++++++++++++++++++++++++++++ Gemfile | 3 +- Gemfile.lock | 5 +-- spec/spec_helper.rb | 16 +++++--- 5 files changed, 116 insertions(+), 10 deletions(-) create mode 100644 .qlty/qlty.toml diff --git a/.circleci/config.yml b/.circleci/config.yml index 3c2d183a..2747c54e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -51,6 +51,8 @@ commands: - install_dependencies - run: name: Run unittests + environment: + COVERAGE: 1 command: | bundle exec rake spec:unit @@ -68,6 +70,11 @@ jobs: - checkout - setup-bundler - unittests + - run: + name: Upload coverage to Qlty + command: | + curl -sL https://qlty.sh | bash + ~/.qlty/bin/qlty coverage publish coverage/.resultset.json license_check: docker: diff --git a/.qlty/qlty.toml b/.qlty/qlty.toml new file mode 100644 index 00000000..afdd6a1a --- /dev/null +++ b/.qlty/qlty.toml @@ -0,0 +1,95 @@ +# This file was automatically generated by `qlty init`. +# You can modify it to suit your needs. +# We recommend you to commit this file to your repository. +# +# This configuration is used by both Qlty CLI and Qlty Cloud. +# +# Qlty CLI -- Code quality toolkit for developers +# Qlty Cloud -- Fully automated Code Health Platform +# +# Try Qlty Cloud: https://qlty.sh +# +# For a guide to configuration, visit https://qlty.sh/d/config +# Or for a full reference, visit https://qlty.sh/d/qlty-toml +config_version = "0" + +exclude_patterns = [ + "*_min.*", + "*-min.*", + "*.min.*", + "**/.yarn/**", + "**/*.d.ts", + "**/assets/**", + "**/bower_components/**", + "**/build/**", + "**/cache/**", + "**/config/**", + "**/db/**", + "**/deps/**", + "**/dist/**", + "**/extern/**", + "**/external/**", + "**/generated/**", + "**/Godeps/**", + "**/gradlew/**", + "**/mvnw/**", + "**/node_modules/**", + "**/protos/**", + "**/seed/**", + "**/target/**", + "**/templates/**", + "**/testdata/**", + "**/vendor/**", +] + +test_patterns = [ + "**/test/**", + "**/spec/**", + "**/*.test.*", + "**/*.spec.*", + "**/*_test.*", + "**/*_spec.*", + "**/test_*.*", + "**/spec_*.*", +] + +[smells] +mode = "comment" + +[[source]] +name = "default" +default = true + + +[[plugin]] +name = "actionlint" + +[[plugin]] +name = "hadolint" + +[[plugin]] +name = "osv-scanner" + +[[plugin]] +name = "radarlint-iac" +mode = "monitor" + +[[plugin]] +name = "ripgrep" +mode = "comment" + +[[plugin]] +name = "reek" + +[[plugin]] +name = "rubocop" +version = "1.75.2" + +[[plugin]] +name = "shellcheck" + +[[plugin]] +name = "trufflehog" + +[[plugin]] +name = "zizmor" diff --git a/Gemfile b/Gemfile index 18ea2098..ab11a01c 100644 --- a/Gemfile +++ b/Gemfile @@ -11,5 +11,6 @@ group :development do end group :test do - gem 'codecov', require: false + gem 'simplecov', require: false + gem 'simplecov_json_formatter', require: false end diff --git a/Gemfile.lock b/Gemfile.lock index 8ed52725..fb5d6a0c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -27,8 +27,6 @@ GEM base64 (0.2.0) bigdecimal (3.1.8) builder (3.2.4) - codecov (0.6.0) - simplecov (>= 0.15, < 0.22) coderay (1.1.3) concurrent-ruby (1.3.4) connection_pool (2.4.1) @@ -124,13 +122,14 @@ PLATFORMS DEPENDENCIES 3scale_toolbox! bundler - codecov dotenv license_finder (~> 7.2) pry rake (~> 13.0) rspec (~> 3.8) rubyzip (>= 1.3.0) + simplecov + simplecov_json_formatter webmock (~> 3.4) BUNDLED WITH diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 842d5373..9e66dae8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -18,12 +18,16 @@ require 'dotenv' Dotenv.load -# Codecov -require 'simplecov' -SimpleCov.start -if ENV['CI'] == 'true' - require 'codecov' - SimpleCov.formatter = SimpleCov::Formatter::Codecov +if ENV['COVERAGE'] && !ENV['COVERAGE'].empty? + require 'simplecov' + require 'simplecov_json_formatter' + SimpleCov.start do + formatter SimpleCov::Formatter::MultiFormatter.new([ + SimpleCov::Formatter::JSONFormatter, + SimpleCov::Formatter::HTMLFormatter + ]) + add_filter '/spec/' + end end require 'webmock/rspec' From aaeb142f8b349d4fc6028d6d977d3922c0274865 Mon Sep 17 00:00:00 2001 From: Bob Dev Date: Fri, 3 Jul 2026 21:43:03 +0000 Subject: [PATCH 2/4] Split CI workflows: manual approval for PRs, auto-run for main Remove deprecated workflows version: 2 key. PR branches require manual approval before all jobs run. Main branch runs automatically. Co-Authored-By: Claude Sonnet 4.5 --- .circleci/config.yml | 47 +++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2747c54e..dd40512f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -158,8 +158,41 @@ jobs: docker run --rm -t app 3scale help workflows: - version: 2 - basic_tests: + pr: + when: + not: + equal: [ main, << pipeline.git.branch >> ] + jobs: + - manual_approval: + type: approval + - ruby-30-unittest: + requires: + - manual_approval + filters: + <<: *tag-trigger + - license_check: + requires: + - manual_approval + filters: + <<: *tag-trigger + - help_test: + requires: + - manual_approval + filters: + <<: *tag-trigger + - image-build: + requires: + - manual_approval + filters: + <<: *tag-trigger + - integration_tests: + context: autotestaccount + requires: + - manual_approval + + main: + when: + equal: [ main, << pipeline.git.branch >> ] jobs: - ruby-30-unittest: filters: @@ -182,13 +215,3 @@ workflows: <<: *tag-trigger branches: ignore: /.*/ - - integration: - jobs: - - manual_approval: # <<< A job that will require manual approval in the web application. - type: approval # <<< This key-value pair will set your workflow to a status of "On Hold" - # On approval of the `hold` job, any successive job that requires the `hold` job will run. - - integration_tests: - context: autotestaccount - requires: - - manual_approval From 1e4c60b8c951a26efdbdebfbd5febd96d038535a Mon Sep 17 00:00:00 2001 From: Bob Dev Date: Fri, 3 Jul 2026 21:49:32 +0000 Subject: [PATCH 3/4] fix(ci): use HTTPS checkout, upload coverage from all test jobs - Add use-https-checkout command to avoid SSH auth failures - Upload coverage with --tag unit and --tag integration separately - Mark uploads as --incomplete, finalize with complete-coverage job - Add integration_tests to main workflow for coverage on main branch Co-Authored-By: Claude Sonnet 4.5 --- .circleci/config.yml | 56 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index dd40512f..e31d0460 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,6 +13,19 @@ only-main-filter: &only-main-filter only: main commands: + use-https-checkout: + steps: + - run: + name: Use HTTPS for git checkout + command: git config --global url."https://github.com/".insteadOf "ssh://git@github.com/" + + install-qlty: + steps: + - run: + name: Install Qlty CLI + command: | + curl -sL https://qlty.sh | bash + setup-bundler: steps: - run: @@ -67,20 +80,22 @@ jobs: - image: cimg/ruby:3.0 working_directory: ~/repo steps: + - use-https-checkout - checkout - setup-bundler - unittests + - install-qlty - run: - name: Upload coverage to Qlty + name: Upload unit test coverage to Qlty command: | - curl -sL https://qlty.sh | bash - ~/.qlty/bin/qlty coverage publish coverage/.resultset.json + ~/.qlty/bin/qlty coverage publish --tag unit --incomplete coverage/.resultset.json license_check: docker: - image: cimg/ruby:3.0 working_directory: ~/repo steps: + - use-https-checkout - checkout - setup-bundler - install_dependencies @@ -94,6 +109,7 @@ jobs: - image: cimg/ruby:3.0 working_directory: ~/repo steps: + - use-https-checkout - checkout - setup-bundler - install_dependencies @@ -107,13 +123,21 @@ jobs: - image: cimg/ruby:3.0 working_directory: ~/repo steps: + - use-https-checkout - checkout - setup-bundler - install_dependencies - run: name: Integration Tests + environment: + COVERAGE: 1 command: | bundle exec rake spec:integration + - install-qlty + - run: + name: Upload integration test coverage to Qlty + command: | + ~/.qlty/bin/qlty coverage publish --tag integration --incomplete coverage/.resultset.json docker_container_help_test: docker: @@ -127,11 +151,26 @@ jobs: docker rmi quay.io/redhat/3scale-toolbox:main || true docker run --rm -t quay.io/redhat/3scale-toolbox:main 3scale help + complete-coverage: + docker: + - image: cimg/ruby:3.0 + working_directory: ~/repo + steps: + - use-https-checkout + - checkout + - install-qlty + - run: + name: Mark coverage as complete + command: | + ~/.qlty/bin/qlty coverage complete --tag unit + ~/.qlty/bin/qlty coverage complete --tag integration + push-rubygems: docker: - image: cimg/ruby:3.0 working_directory: ~/repo steps: + - use-https-checkout - checkout - run: name: Setup Rubygems @@ -147,6 +186,7 @@ jobs: working_directory: /app steps: - setup-docker + - use-https-checkout - checkout - run: name: Build application Docker image @@ -189,6 +229,10 @@ workflows: context: autotestaccount requires: - manual_approval + - complete-coverage: + requires: + - ruby-30-unittest + - integration_tests main: when: @@ -206,6 +250,12 @@ workflows: - image-build: filters: <<: *tag-trigger + - integration_tests: + context: autotestaccount + - complete-coverage: + requires: + - ruby-30-unittest + - integration_tests - push-rubygems: requires: - ruby-30-unittest From 5c99bb84200e52617ca1570180486e7747827d6d Mon Sep 17 00:00:00 2001 From: Bob Dev Date: Fri, 3 Jul 2026 21:54:03 +0000 Subject: [PATCH 4/4] revert(ci): remove HTTPS checkout workaround Deploy key will be used instead. Co-Authored-By: Claude Sonnet 4.5 --- .circleci/config.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e31d0460..d785da85 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,12 +13,6 @@ only-main-filter: &only-main-filter only: main commands: - use-https-checkout: - steps: - - run: - name: Use HTTPS for git checkout - command: git config --global url."https://github.com/".insteadOf "ssh://git@github.com/" - install-qlty: steps: - run: @@ -80,7 +74,6 @@ jobs: - image: cimg/ruby:3.0 working_directory: ~/repo steps: - - use-https-checkout - checkout - setup-bundler - unittests @@ -95,7 +88,6 @@ jobs: - image: cimg/ruby:3.0 working_directory: ~/repo steps: - - use-https-checkout - checkout - setup-bundler - install_dependencies @@ -109,7 +101,6 @@ jobs: - image: cimg/ruby:3.0 working_directory: ~/repo steps: - - use-https-checkout - checkout - setup-bundler - install_dependencies @@ -123,7 +114,6 @@ jobs: - image: cimg/ruby:3.0 working_directory: ~/repo steps: - - use-https-checkout - checkout - setup-bundler - install_dependencies @@ -156,7 +146,6 @@ jobs: - image: cimg/ruby:3.0 working_directory: ~/repo steps: - - use-https-checkout - checkout - install-qlty - run: @@ -170,7 +159,6 @@ jobs: - image: cimg/ruby:3.0 working_directory: ~/repo steps: - - use-https-checkout - checkout - run: name: Setup Rubygems @@ -186,7 +174,6 @@ jobs: working_directory: /app steps: - setup-docker - - use-https-checkout - checkout - run: name: Build application Docker image