Skip to content
代码片段 群组 项目
未验证 提交 818d7a64 编辑于 作者: Allen Cook's avatar Allen Cook 提交者: GitLab
浏览文件

Merge branch 'j_lar/remove_unused_method_in_usage_data_rake_task' into 'master'

No related branches found
No related tags found
无相关合并请求
......@@ -30,21 +30,6 @@ def expand_template_name(template_name)
Gitlab::Template::GitlabCiYmlTemplate.find(template_name.chomp('.gitlab-ci.yml'))&.full_name
end
def all_included_templates(template_name)
expanded_template_name = expand_template_name(template_name)
results = [expanded_template_name].tap do |result|
template = Gitlab::Template::GitlabCiYmlTemplate.find(template_name.chomp('.gitlab-ci.yml'))
data = Gitlab::Ci::Config::Yaml::Loader.new(template.content).load.content
[data[:include]].compact.flatten.each do |ci_include|
if ci_include_template = ci_include[:template]
result.concat(all_included_templates(ci_include_template))
end
end
end
results.uniq.sort_by { _1['name'] }
end
private
def template_to_event_name(template)
......
......@@ -48,39 +48,5 @@ namespace :gitlab do
FileUtils.mkdir_p(path)
File.write(File.join(path, 'sql_metrics_queries.json'), Gitlab::Json.pretty_generate(queries))
end
# Events for templates included via YAML-less Auto-DevOps
def implicit_auto_devops_includes
Gitlab::UsageDataCounters::CiTemplateUniqueCounter
.all_included_templates('Auto-DevOps.gitlab-ci.yml')
.map { |template| implicit_auto_devops_event(template) }
.uniq
.sort_by { _1['name'] }
end
# Events for templates included in a .gitlab-ci.yml using include:template
def explicit_template_includes
Gitlab::UsageDataCounters::CiTemplateUniqueCounter.ci_templates("lib/gitlab/ci/templates/").each_with_object([]) do |template, result|
expanded_template_name = Gitlab::UsageDataCounters::CiTemplateUniqueCounter.expand_template_name(template)
next unless expanded_template_name # guard against templates unavailable on FOSS
event_name = Gitlab::UsageDataCounters::CiTemplateUniqueCounter.ci_template_event_name(expanded_template_name, :repository_source)
result << ci_template_event(event_name)
end
end
# rubocop:disable Gitlab/NoCodeCoverageComment
# :nocov: remove in https://gitlab.com/gitlab-org/gitlab/-/issues/299453
def ci_template_event(event_name)
{ 'name' => event_name }
end
# :nocov:
# rubocop:enable Gitlab/NoCodeCoverageComment
def implicit_auto_devops_event(expanded_template_name)
event_name = Gitlab::UsageDataCounters::CiTemplateUniqueCounter.ci_template_event_name(expanded_template_name, :auto_devops_source)
ci_template_event(event_name)
end
end
end
......@@ -50,18 +50,6 @@
end
end
context 'with implicit includes', :snowplow do
let(:config_source) { :auto_devops_source }
described_class.all_included_templates('Auto-DevOps.gitlab-ci.yml').each do |template_name|
context "for #{template_name}" do
let(:template_path) { Gitlab::Template::GitlabCiYmlTemplate.find(template_name.delete_suffix('.gitlab-ci.yml')).full_name }
include_examples 'tracks template'
end
end
end
it 'expands short template names' do
expect do
described_class.track_unique_project_event(project: project, template: 'Dependency-Scanning.gitlab-ci.yml', config_source: :repository_source, user: user)
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册