diff options
-rw-r--r-- | app/models/ci/build.rb | 4 | ||||
-rw-r--r-- | app/models/ci/job_artifact.rb | 13 | ||||
-rw-r--r-- | app/serializers/build_details_entity.rb | 5 | ||||
-rw-r--r-- | app/serializers/job_artifact_report_entity.rb | 13 | ||||
-rw-r--r-- | app/views/admin/users/show.html.haml | 2 | ||||
-rw-r--r-- | app/views/import/bitbucket_server/status.html.haml | 2 | ||||
-rw-r--r-- | lib/api/helpers/issues_helpers.rb | 8 | ||||
-rw-r--r-- | lib/api/issues.rb | 14 | ||||
-rw-r--r-- | locale/gitlab.pot | 3 | ||||
-rw-r--r-- | spec/models/ci/build_spec.rb | 12 | ||||
-rw-r--r-- | spec/models/ci/job_artifact_spec.rb | 15 | ||||
-rw-r--r-- | spec/serializers/build_details_entity_spec.rb | 9 | ||||
-rw-r--r-- | spec/serializers/job_artifact_report_entity_spec.rb | 28 |
13 files changed, 110 insertions, 18 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 1b67a7272bc..56786fae6ea 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -765,6 +765,10 @@ module Ci end end + def report_artifacts + job_artifacts.with_reports + end + # Virtual deployment status depending on the environment status. def deployment_status return unless starts_environment? diff --git a/app/models/ci/job_artifact.rb b/app/models/ci/job_artifact.rb index 3beb76ffc2b..0dbeab30498 100644 --- a/app/models/ci/job_artifact.rb +++ b/app/models/ci/job_artifact.rb @@ -26,10 +26,13 @@ module Ci metrics: 'metrics.txt' }.freeze - TYPE_AND_FORMAT_PAIRS = { + INTERNAL_TYPES = { archive: :zip, metadata: :gzip, - trace: :raw, + trace: :raw + }.freeze + + REPORT_TYPES = { junit: :gzip, metrics: :gzip, @@ -45,6 +48,8 @@ module Ci performance: :raw }.freeze + TYPE_AND_FORMAT_PAIRS = INTERNAL_TYPES.merge(REPORT_TYPES).freeze + belongs_to :project belongs_to :job, class_name: "Ci::Build", foreign_key: :job_id @@ -66,6 +71,10 @@ module Ci where(file_type: types) end + scope :with_reports, -> do + with_file_types(REPORT_TYPES.keys.map(&:to_s)) + end + scope :test_reports, -> do with_file_types(TEST_REPORT_FILE_TYPES) end diff --git a/app/serializers/build_details_entity.rb b/app/serializers/build_details_entity.rb index 6928968edc0..67e44ee9d10 100644 --- a/app/serializers/build_details_entity.rb +++ b/app/serializers/build_details_entity.rb @@ -42,6 +42,11 @@ class BuildDetailsEntity < JobEntity end end + expose :report_artifacts, + as: :reports, + using: JobArtifactReportEntity, + if: -> (*) { can?(current_user, :read_build, build) } + expose :erased_by, if: -> (*) { build.erased? }, using: UserEntity expose :erase_path, if: -> (*) { build.erasable? && can?(current_user, :erase_build, build) } do |build| erase_project_job_path(project, build) diff --git a/app/serializers/job_artifact_report_entity.rb b/app/serializers/job_artifact_report_entity.rb new file mode 100644 index 00000000000..4280351a6b0 --- /dev/null +++ b/app/serializers/job_artifact_report_entity.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class JobArtifactReportEntity < Grape::Entity + include RequestAwareEntity + + expose :file_type + expose :file_format + expose :size + + expose :download_path do |artifact| + download_project_job_artifacts_path(artifact.job.project, artifact.job, file_type: artifact.file_format) + end +end diff --git a/app/views/admin/users/show.html.haml b/app/views/admin/users/show.html.haml index c4178296e67..dcd6f7c8078 100644 --- a/app/views/admin/users/show.html.haml +++ b/app/views/admin/users/show.html.haml @@ -124,6 +124,8 @@ %strong = Gitlab::Access.human_access_with_none(@user.highest_role) + = render_if_exists 'admin/users/using_license_seat', user: @user + - if @user.ldap_user? %li %span.light LDAP uid: diff --git a/app/views/import/bitbucket_server/status.html.haml b/app/views/import/bitbucket_server/status.html.haml index 9280f12e187..40609fddbde 100644 --- a/app/views/import/bitbucket_server/status.html.haml +++ b/app/views/import/bitbucket_server/status.html.haml @@ -29,7 +29,7 @@ %tr %th= _('From Bitbucket Server') %th= _('To GitLab') - %th= _(' Status') + %th= _('Status') %tbody - @already_added_projects.each do |project| %tr{ id: "project_#{project.id}", class: "#{project_status_css_class(project.import_status)}" } diff --git a/lib/api/helpers/issues_helpers.rb b/lib/api/helpers/issues_helpers.rb index fc66cec5341..5b7199fddb0 100644 --- a/lib/api/helpers/issues_helpers.rb +++ b/lib/api/helpers/issues_helpers.rb @@ -3,6 +3,14 @@ module API module Helpers module IssuesHelpers + extend Grape::API::Helpers + + params :optional_issue_params_ee do + end + + params :optional_issues_params_ee do + end + def self.update_params_at_least_one_of [ :assignee_id, diff --git a/lib/api/issues.rb b/lib/api/issues.rb index 0b4da01f3c8..56960a2eb64 100644 --- a/lib/api/issues.rb +++ b/lib/api/issues.rb @@ -9,16 +9,6 @@ module API before { authenticate_non_get! } helpers do - if Gitlab.ee? - params :issues_params_ee do - optional :weight, types: [Integer, String], integer_none_any: true, desc: 'The weight of the issue' - end - - params :issue_params_ee do - optional :weight, type: Integer, desc: 'The weight of the issue' - end - end - params :issues_stats_params do optional :labels, type: Array[String], coerce_with: Validations::Types::LabelsList.coerce, desc: 'Comma-separated list of label names' optional :milestone, type: String, desc: 'Milestone title' @@ -47,7 +37,7 @@ module API optional :my_reaction_emoji, type: String, desc: 'Return issues reacted by the authenticated user by the given emoji' optional :confidential, type: Boolean, desc: 'Filter confidential or public issues' - use :issues_params_ee if Gitlab.ee? + use :optional_issues_params_ee end params :issues_params do @@ -73,7 +63,7 @@ module API optional :confidential, type: Boolean, desc: 'Boolean parameter if the issue should be confidential' optional :discussion_locked, type: Boolean, desc: " Boolean parameter indicating if the issue's discussion is locked" - use :issue_params_ee if Gitlab.ee? + use :optional_issue_params_ee end end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 44dda25c38c..b6025f70e8a 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -19,9 +19,6 @@ msgstr "" msgid " Please sign in." msgstr "" -msgid " Status" -msgstr "" - msgid " Try to %{action} this file again." msgstr "" diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index bc81c34f7ab..32eef9e0e01 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -3490,6 +3490,18 @@ describe Ci::Build do end end + describe '#report_artifacts' do + subject { build.report_artifacts } + + context 'when the build has reports' do + let!(:report) { create(:ci_job_artifact, :codequality, job: build) } + + it 'returns the artifacts with reports' do + expect(subject).to contain_exactly(report) + end + end + end + describe '#artifacts_metadata_entry' do set(:build) { create(:ci_build, project: project) } let(:path) { 'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif' } diff --git a/spec/models/ci/job_artifact_spec.rb b/spec/models/ci/job_artifact_spec.rb index 5964f66c398..e6d682c24d9 100644 --- a/spec/models/ci/job_artifact_spec.rb +++ b/spec/models/ci/job_artifact_spec.rb @@ -23,6 +23,21 @@ describe Ci::JobArtifact do it_behaves_like 'having unique enum values' + describe '.with_reports' do + let!(:artifact) { create(:ci_job_artifact, :archive) } + + subject { described_class.with_reports } + + it { is_expected.to be_empty } + + context 'when there are reports' do + let!(:metrics_report) { create(:ci_job_artifact, :junit) } + let!(:codequality_report) { create(:ci_job_artifact, :codequality) } + + it { is_expected.to eq([metrics_report, codequality_report]) } + end + end + describe '.test_reports' do subject { described_class.test_reports } diff --git a/spec/serializers/build_details_entity_spec.rb b/spec/serializers/build_details_entity_spec.rb index 9c2e5c79a9d..d922e8246c7 100644 --- a/spec/serializers/build_details_entity_spec.rb +++ b/spec/serializers/build_details_entity_spec.rb @@ -146,5 +146,14 @@ describe BuildDetailsEntity do end end end + + context 'when the build has reports' do + let!(:report) { create(:ci_job_artifact, :codequality, job: build) } + + it 'exposes the report artifacts' do + expect(subject[:reports].count).to eq(1) + expect(subject[:reports].first[:file_type]).to eq('codequality') + end + end end end diff --git a/spec/serializers/job_artifact_report_entity_spec.rb b/spec/serializers/job_artifact_report_entity_spec.rb new file mode 100644 index 00000000000..eef5c16d0fb --- /dev/null +++ b/spec/serializers/job_artifact_report_entity_spec.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe JobArtifactReportEntity do + let(:report) { create(:ci_job_artifact, :codequality) } + let(:entity) { described_class.new(report, request: double) } + + describe '#as_json' do + subject { entity.as_json } + + it 'exposes file_type' do + expect(subject[:file_type]).to eq(report.file_type) + end + + it 'exposes file_format' do + expect(subject[:file_format]).to eq(report.file_format) + end + + it 'exposes size' do + expect(subject[:size]).to eq(report.size) + end + + it 'exposes download path' do + expect(subject[:download_path]).to include("jobs/#{report.job.id}/artifacts/download") + end + end +end |