diff options
Diffstat (limited to 'app/presenters/ci')
-rw-r--r-- | app/presenters/ci/bridge_presenter.rb | 4 | ||||
-rw-r--r-- | app/presenters/ci/build_presenter.rb | 6 | ||||
-rw-r--r-- | app/presenters/ci/build_runner_presenter.rb | 57 |
3 files changed, 41 insertions, 26 deletions
diff --git a/app/presenters/ci/bridge_presenter.rb b/app/presenters/ci/bridge_presenter.rb index a62d7cdbbd4..ded3844ac99 100644 --- a/app/presenters/ci/bridge_presenter.rb +++ b/app/presenters/ci/bridge_presenter.rb @@ -2,11 +2,11 @@ module Ci class BridgePresenter < ProcessablePresenter - presents ::Ci::Bridge + presents ::Ci::Bridge, as: :bridge delegator_override :detailed_status def detailed_status - @detailed_status ||= subject.detailed_status(user) + @detailed_status ||= bridge.detailed_status(user) end end end diff --git a/app/presenters/ci/build_presenter.rb b/app/presenters/ci/build_presenter.rb index 65e1c80085f..0be684901d5 100644 --- a/app/presenters/ci/build_presenter.rb +++ b/app/presenters/ci/build_presenter.rb @@ -2,7 +2,7 @@ module Ci class BuildPresenter < ProcessablePresenter - presents ::Ci::Build + presents ::Ci::Build, as: :build def erased_by_user? # Build can be erased through API, therefore it does not have @@ -34,7 +34,7 @@ module Ci end def tooltip_message - "#{subject.name} - #{detailed_status.status_tooltip}" + "#{build.name} - #{detailed_status.status_tooltip}" end def execute_in @@ -48,7 +48,7 @@ module Ci end def detailed_status - @detailed_status ||= subject.detailed_status(user) + @detailed_status ||= build.detailed_status(user) end end end diff --git a/app/presenters/ci/build_runner_presenter.rb b/app/presenters/ci/build_runner_presenter.rb index 082993130a1..015dfc16df0 100644 --- a/app/presenters/ci/build_runner_presenter.rb +++ b/app/presenters/ci/build_runner_presenter.rb @@ -64,35 +64,50 @@ module Ci def create_archive(artifacts) return unless artifacts[:untracked] || artifacts[:paths] - archive = { - artifact_type: :archive, - artifact_format: :zip, - name: artifacts[:name], - untracked: artifacts[:untracked], - paths: artifacts[:paths], - when: artifacts[:when], - expire_in: artifacts[:expire_in] - } - - if artifacts.dig(:exclude).present? - archive.merge(exclude: artifacts[:exclude]) - else - archive + BuildArtifact.for_archive(artifacts).to_h.tap do |artifact| + artifact.delete(:exclude) unless artifact[:exclude].present? end end def create_reports(reports, expire_in:) return unless reports&.any? - reports.map do |report_type, report_paths| - { - artifact_type: report_type.to_sym, - artifact_format: ::Ci::JobArtifact::TYPE_AND_FORMAT_PAIRS.fetch(report_type.to_sym), - name: ::Ci::JobArtifact::DEFAULT_FILE_NAMES.fetch(report_type.to_sym), - paths: report_paths, + reports.map { |report| BuildArtifact.for_report(report, expire_in).to_h.compact } + end + + BuildArtifact = Struct.new(:name, :untracked, :paths, :exclude, :when, :expire_in, :artifact_type, :artifact_format, keyword_init: true) do + def self.for_archive(artifacts) + self.new( + artifact_type: :archive, + artifact_format: :zip, + name: artifacts[:name], + untracked: artifacts[:untracked], + paths: artifacts[:paths], + when: artifacts[:when], + expire_in: artifacts[:expire_in], + exclude: artifacts[:exclude] + ) + end + + def self.for_report(report, expire_in) + type, params = report + + if type == :coverage_report + artifact_type = params[:coverage_format].to_sym + paths = [params[:path]] + else + artifact_type = type + paths = params + end + + self.new( + artifact_type: artifact_type, + artifact_format: ::Ci::JobArtifact::TYPE_AND_FORMAT_PAIRS.fetch(artifact_type), + name: ::Ci::JobArtifact::DEFAULT_FILE_NAMES.fetch(artifact_type), + paths: paths, when: 'always', expire_in: expire_in - } + ) end end |