debian-mirror-gitlab/spec/simplecov_env.rb

84 lines
2.9 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2016-09-13 17:45:13 +05:30
require 'simplecov'
2020-07-28 23:09:34 +05:30
require 'simplecov-cobertura'
2022-01-26 12:08:38 +05:30
require 'simplecov-lcov'
2019-03-02 22:35:43 +05:30
require_relative '../lib/gitlab/utils'
2016-09-13 17:45:13 +05:30
module SimpleCovEnv
extend self
def start!
2022-08-13 15:12:31 +05:30
return if !ENV.key?('SIMPLECOV') || ENV['SIMPLECOV'] == '0'
2016-09-13 17:45:13 +05:30
configure_profile
configure_job
2020-07-28 23:09:34 +05:30
configure_formatter
2016-09-13 17:45:13 +05:30
SimpleCov.start
end
2020-07-28 23:09:34 +05:30
def configure_formatter
2022-01-26 12:08:38 +05:30
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
2023-03-04 22:38:38 +05:30
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new(
[
SimpleCov::Formatter::SimpleFormatter,
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::CoberturaFormatter,
SimpleCov::Formatter::LcovFormatter
]
)
2020-07-28 23:09:34 +05:30
end
2016-09-13 17:45:13 +05:30
def configure_job
SimpleCov.configure do
2017-08-17 22:00:37 +05:30
if ENV['CI_JOB_NAME']
2019-03-02 22:35:43 +05:30
job_name = Gitlab::Utils.slugify(ENV['CI_JOB_NAME'])
coverage_dir "coverage/#{job_name}"
command_name job_name
2016-09-13 17:45:13 +05:30
end
if ENV['CI']
SimpleCov.at_exit do
# In CI environment don't generate formatted reports
# Only generate .resultset.json
SimpleCov.result
end
end
end
end
def configure_profile
SimpleCov.configure do
load_profile 'test_frameworks'
2020-07-28 23:09:34 +05:30
track_files '{app,config/initializers,config/initializers_before_autoloader,db/post_migrate,haml_lint,lib,rubocop,tooling}/**/*.rb'
2016-09-13 17:45:13 +05:30
add_filter '/vendor/ruby/'
2020-07-28 23:09:34 +05:30
add_filter '/bin/'
2022-01-26 12:08:38 +05:30
add_filter 'db/fixtures/development/' # Matches EE files as well
2016-09-13 17:45:13 +05:30
2020-07-28 23:09:34 +05:30
add_group 'Channels', 'app/channels' # Matches EE files as well
add_group 'Controllers', 'app/controllers' # Matches EE files as well
add_group 'Finders', 'app/finders' # Matches EE files as well
add_group 'GraphQL', 'app/graphql' # Matches EE files as well
add_group 'Helpers', 'app/helpers' # Matches EE files as well
add_group 'Mailers', 'app/mailers' # Matches EE files as well
add_group 'Models', 'app/models' # Matches EE files as well
add_group 'Policies', 'app/policies' # Matches EE files as well
add_group 'Presenters', 'app/presenters' # Matches EE files as well
add_group 'Serializers', 'app/serializers' # Matches EE files as well
add_group 'Services', 'app/services' # Matches EE files as well
add_group 'Uploaders', 'app/uploaders' # Matches EE files as well
add_group 'Validators', 'app/validators' # Matches EE files as well
add_group 'Workers', %w[app/jobs app/workers] # Matches EE files as well
add_group 'Initializers', %w[config/initializers config/initializers_before_autoloader] # Matches EE files as well
add_group 'Migrations', %w[db/migrate db/optional_migrations db/post_migrate] # Matches EE files as well
add_group 'Libraries', %w[/lib /ee/lib]
add_group 'Tooling', %w[/haml_lint /rubocop /tooling]
2016-09-13 17:45:13 +05:30
2021-01-03 14:25:43 +05:30
merge_timeout 365 * 24 * 3600
2016-09-13 17:45:13 +05:30
end
end
end