2019-10-06 23:07:19 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-06-30 13:04:00 -04:00
|
|
|
require 'simplecov'
|
2020-06-23 11:08:41 -04:00
|
|
|
require 'simplecov-cobertura'
|
2021-12-01 19:17:32 -05:00
|
|
|
require 'simplecov-lcov'
|
2019-01-08 08:43:19 -05:00
|
|
|
require_relative '../lib/gitlab/utils'
|
2016-06-30 12:54:03 -04:00
|
|
|
|
2016-07-21 04:44:18 -04:00
|
|
|
module SimpleCovEnv
|
|
|
|
extend self
|
2016-06-30 12:54:03 -04:00
|
|
|
|
2016-07-21 04:44:18 -04:00
|
|
|
def start!
|
|
|
|
return unless ENV['SIMPLECOV']
|
|
|
|
|
|
|
|
configure_profile
|
|
|
|
configure_job
|
2020-06-23 11:08:41 -04:00
|
|
|
configure_formatter
|
2016-07-21 04:44:18 -04:00
|
|
|
|
|
|
|
SimpleCov.start
|
2016-06-30 13:04:00 -04:00
|
|
|
end
|
2016-06-30 12:54:03 -04:00
|
|
|
|
2020-06-23 11:08:41 -04:00
|
|
|
def configure_formatter
|
2021-12-01 19:17:32 -05:00
|
|
|
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
|
|
|
|
|
2020-06-23 11:08:41 -04:00
|
|
|
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([
|
|
|
|
SimpleCov::Formatter::SimpleFormatter,
|
|
|
|
SimpleCov::Formatter::HTMLFormatter,
|
2021-12-01 19:17:32 -05:00
|
|
|
SimpleCov::Formatter::CoberturaFormatter,
|
|
|
|
SimpleCov::Formatter::LcovFormatter
|
2020-06-23 11:08:41 -04:00
|
|
|
])
|
|
|
|
end
|
|
|
|
|
2016-07-21 04:44:18 -04:00
|
|
|
def configure_job
|
|
|
|
SimpleCov.configure do
|
2017-03-10 05:20:08 -05:00
|
|
|
if ENV['CI_JOB_NAME']
|
2019-01-08 08:43:19 -05:00
|
|
|
job_name = Gitlab::Utils.slugify(ENV['CI_JOB_NAME'])
|
|
|
|
coverage_dir "coverage/#{job_name}"
|
|
|
|
command_name job_name
|
2016-07-21 04:44:18 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
if ENV['CI']
|
|
|
|
SimpleCov.at_exit do
|
|
|
|
# In CI environment don't generate formatted reports
|
|
|
|
# Only generate .resultset.json
|
|
|
|
SimpleCov.result
|
|
|
|
end
|
|
|
|
end
|
2016-06-30 13:04:00 -04:00
|
|
|
end
|
2016-06-30 12:54:03 -04:00
|
|
|
end
|
2016-06-30 13:04:00 -04:00
|
|
|
|
2016-07-21 04:44:18 -04:00
|
|
|
def configure_profile
|
|
|
|
SimpleCov.configure do
|
|
|
|
load_profile 'test_frameworks'
|
2020-07-13 05:09:29 -04:00
|
|
|
track_files '{app,config/initializers,config/initializers_before_autoloader,db/post_migrate,haml_lint,lib,rubocop,tooling}/**/*.rb'
|
2016-07-21 04:44:18 -04:00
|
|
|
|
|
|
|
add_filter '/vendor/ruby/'
|
2020-06-21 23:08:17 -04:00
|
|
|
add_filter '/bin/'
|
2021-11-25 22:11:11 -05:00
|
|
|
add_filter 'db/fixtures/development/' # Matches EE files as well
|
2016-07-21 04:44:18 -04:00
|
|
|
|
2020-06-21 23:08:17 -04:00
|
|
|
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]
|
2020-07-13 05:09:29 -04:00
|
|
|
add_group 'Tooling', %w[/haml_lint /rubocop /tooling]
|
2016-07-21 04:44:18 -04:00
|
|
|
|
2020-09-22 08:09:39 -04:00
|
|
|
merge_timeout 365 * 24 * 3600
|
2016-07-21 04:44:18 -04:00
|
|
|
end
|
|
|
|
end
|
2016-06-30 12:54:03 -04:00
|
|
|
end
|