debian-mirror-gitlab/spec/simplecov_env.rb

82 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'
2016-09-13 17:45:13 +05:30
require 'active_support/core_ext/numeric/time'
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!
return unless ENV['SIMPLECOV']
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
SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::SimpleFormatter,
SimpleCov::Formatter::HTMLFormatter,
SimpleCov::Formatter::CoberturaFormatter
])
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 '/app/controllers/sherlock/'
add_filter '/bin/'
add_filter 'db/fixtures/' # Matches EE files as well
add_filter '/lib/gitlab/sidekiq_middleware/'
add_filter '/lib/system_check/'
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
merge_timeout 365.days
end
end
end