diff --git a/.circleci/config.yml b/.circleci/config.yml index 3c2d183a..d785da85 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,6 +13,13 @@ only-main-filter: &only-main-filter only: main commands: + install-qlty: + steps: + - run: + name: Install Qlty CLI + command: | + curl -sL https://qlty.sh | bash + setup-bundler: steps: - run: @@ -51,6 +58,8 @@ commands: - install_dependencies - run: name: Run unittests + environment: + COVERAGE: 1 command: | bundle exec rake spec:unit @@ -68,6 +77,11 @@ jobs: - checkout - setup-bundler - unittests + - install-qlty + - run: + name: Upload unit test coverage to Qlty + command: | + ~/.qlty/bin/qlty coverage publish --tag unit --incomplete coverage/.resultset.json license_check: docker: @@ -105,8 +119,15 @@ jobs: - 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: @@ -120,6 +141,19 @@ 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: + - 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 @@ -151,8 +185,45 @@ 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 + - complete-coverage: + requires: + - ruby-30-unittest + - integration_tests + + main: + when: + equal: [ main, << pipeline.git.branch >> ] jobs: - ruby-30-unittest: filters: @@ -166,6 +237,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 @@ -175,13 +252,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 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'