Commit 4119206f authored by James Lopez's avatar James Lopez

fix export performance of CI builds

parent be99f824
...@@ -451,6 +451,10 @@ module Ci ...@@ -451,6 +451,10 @@ module Ci
trace trace
end end
def serializable_hash(options = {})
super(options.merge(when: read_attribute(:when)))
end
private private
def update_artifacts_size def update_artifacts_size
......
...@@ -116,6 +116,7 @@ excluded_attributes: ...@@ -116,6 +116,7 @@ excluded_attributes:
statuses: statuses:
- :trace - :trace
- :token - :token
- :when
push_event_payload: push_event_payload:
- :event_id - :event_id
......
...@@ -18,9 +18,7 @@ module Gitlab ...@@ -18,9 +18,7 @@ module Gitlab
attributes = @attributes_finder.find(:project) attributes = @attributes_finder.find(:project)
project_attributes = attributes.is_a?(Hash) ? attributes[:project] : {} project_attributes = attributes.is_a?(Hash) ? attributes[:project] : {}
build_hash(@tree).each do |sub_hash| project_attributes.merge(include: build_hash(@tree))
yield(project_attributes.merge(include: sub_hash))
end
rescue => e rescue => e
@shared.error(e) @shared.error(e)
false false
......
...@@ -117,6 +117,13 @@ describe Gitlab::ImportExport::ProjectTreeSaver do ...@@ -117,6 +117,13 @@ describe Gitlab::ImportExport::ProjectTreeSaver do
expect(saved_project_json['pipelines'].first['statuses'].count { |hash| hash['type'] == 'Ci::Build' }).to eq(1) expect(saved_project_json['pipelines'].first['statuses'].count { |hash| hash['type'] == 'Ci::Build' }).to eq(1)
end end
it 'builds do not call the attributes for retrieving when' do
allow_any_instance_of(Ci::Pipeline).to receive(:ci_yaml_file).and_return(File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')))
expect_any_instance_of(Ci::GitlabCiYamlProcessor).not_to receive(:build_attributes)
saved_project_json
end
it 'has pipeline commits' do it 'has pipeline commits' do
expect(saved_project_json['pipelines']).not_to be_empty expect(saved_project_json['pipelines']).not_to be_empty
end end
...@@ -251,15 +258,11 @@ describe Gitlab::ImportExport::ProjectTreeSaver do ...@@ -251,15 +258,11 @@ describe Gitlab::ImportExport::ProjectTreeSaver do
create(:label_priority, label: group_label, priority: 1) create(:label_priority, label: group_label, priority: 1)
milestone = create(:milestone, project: project) milestone = create(:milestone, project: project)
merge_request = create(:merge_request, source_project: project, milestone: milestone) merge_request = create(:merge_request, source_project: project, milestone: milestone)
commit_status = create(:commit_status, project: project)
ci_pipeline = create(:ci_pipeline, ci_build = create(:ci_build, project: project, when: nil)
project: project, ci_build.pipeline.update(project: project)
sha: merge_request.diff_head_sha, commit_status = create(:commit_status, project: project, pipeline: ci_build.pipeline)
ref: merge_request.source_branch,
statuses: [commit_status])
create(:ci_build, pipeline: ci_pipeline, project: project)
create(:milestone, project: project) create(:milestone, project: project)
create(:note, noteable: issue, project: project) create(:note, noteable: issue, project: project)
create(:note, noteable: merge_request, project: project) create(:note, noteable: merge_request, project: project)
...@@ -267,7 +270,7 @@ describe Gitlab::ImportExport::ProjectTreeSaver do ...@@ -267,7 +270,7 @@ describe Gitlab::ImportExport::ProjectTreeSaver do
create(:note_on_commit, create(:note_on_commit,
author: user, author: user,
project: project, project: project,
commit_id: ci_pipeline.sha) commit_id: ci_build.pipeline.sha)
create(:event, :created, target: milestone, project: project, author: user) create(:event, :created, target: milestone, project: project, author: user)
create(:service, project: project, type: 'CustomIssueTrackerService', category: 'issue_tracker') create(:service, project: project, type: 'CustomIssueTrackerService', category: 'issue_tracker')
......
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