Commit 8fe37da6 authored by Kamil Trzciński's avatar Kamil Trzciński

More clever way for testing runner features

parent 6f264888
...@@ -15,6 +15,10 @@ module Ci ...@@ -15,6 +15,10 @@ module Ci
has_many :deployments, as: :deployable has_many :deployments, as: :deployable
RUNNER_FEATURES = {
upload_multiple_artifacts: -> (build) { build.publishes_artifacts_reports? }
}.freeze
has_one :last_deployment, -> { order('deployments.id DESC') }, as: :deployable, class_name: 'Deployment' has_one :last_deployment, -> { order('deployments.id DESC') }, as: :deployable, class_name: 'Deployment'
has_many :trace_sections, class_name: 'Ci::BuildTraceSection' has_many :trace_sections, class_name: 'Ci::BuildTraceSection'
has_many :trace_chunks, class_name: 'Ci::BuildTraceChunk', foreign_key: :build_id has_many :trace_chunks, class_name: 'Ci::BuildTraceChunk', foreign_key: :build_id
...@@ -337,12 +341,6 @@ module Ci ...@@ -337,12 +341,6 @@ module Ci
{ trace_sections: true } { trace_sections: true }
end end
def runner_required_features
features = []
features << :upload_multiple_artifacts if publishes_artifacts_reports?
features
end
def merge_request def merge_request
return @merge_request if defined?(@merge_request) return @merge_request if defined?(@merge_request)
...@@ -594,14 +592,22 @@ module Ci ...@@ -594,14 +592,22 @@ module Ci
true true
end end
def runner_required_feature_names
strong_memoize(:runner_required_feature_names) do
RUNNER_FEATURES.select do |feature, method|
method.call(self)
end.keys
end
end
def supported_runner?(features) def supported_runner?(features)
runner_required_features.all? do |feature_name| runner_required_feature_names.all? do |feature_name|
features&.dig(feature_name) features&.dig(feature_name)
end end
end end
def publishes_artifacts_reports? def publishes_artifacts_reports?
options.dig(:artifacts, :reports).any? options&.dig(:artifacts, :reports)&.any?
end end
def hide_secrets(trace) def hide_secrets(trace)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment