Commit aa603812 authored by Shinya Maeda's avatar Shinya Maeda

Bring back the initial commit

parent 76d70841
...@@ -4,29 +4,30 @@ module Ci ...@@ -4,29 +4,30 @@ module Ci
return if job.job_artifacts_trace return if job.job_artifacts_trace
job.trace.read do |stream| job.trace.read do |stream|
return unless stream.file? # rubocop:disable Lint/NonLocalExitFromIterator break unless stream.file?
temp_file!(stream.path, JobArtifactUploader.workhorse_upload_path) do |temp_path|
job.create_job_artifacts_trace!(
project: job.project,
file_type: :trace,
file: UploadedFile.new(temp_path, 'job.log', 'application/octet-stream')
)
end
raise 'Trace artifact not found' unless job.job_artifacts_trace.file.exists?
temp_file!(JobArtifactUploader.workhorse_upload_path) do |temp_path|
FileUtils.cp(stream.path, temp_path)
create_job_trace!(job, temp_path)
FileUtils.rm(stream.path) FileUtils.rm(stream.path)
end end
end end
end
private private
def temp_file!(src_file, temp_dir) def create_job_trace!(job, path)
job.create_job_artifacts_trace!(
project: job.project,
file_type: :trace,
file: UploadedFile.new(path, 'job.log', 'application/octet-stream')
)
end
def temp_file!(temp_dir)
FileUtils.mkdir_p(temp_dir) FileUtils.mkdir_p(temp_dir)
temp_file = Tempfile.new('trace-tmp-', temp_dir) temp_file = Tempfile.new('trace-tmp-', temp_dir)
temp_file&.close temp_file&.close
FileUtils.cp(src_file, temp_file.path)
yield(temp_file.path) yield(temp_file.path)
ensure ensure
temp_file&.close temp_file&.close
......
...@@ -41,18 +41,6 @@ describe Ci::CreateTraceArtifactService do ...@@ -41,18 +41,6 @@ describe Ci::CreateTraceArtifactService do
expect(job.job_artifacts_trace).to be_nil expect(job.job_artifacts_trace).to be_nil
end end
end end
context 'when migrated trace artifact file is not found' do
before do
allow_any_instance_of(CarrierWave::SanitizedFile).to receive(:exists?) { false }
end
it 'raises an error' do
expect { subject }.to raise_error('Trace artifact not found')
expect(File.exist?(legacy_path)).to be_truthy
end
end
end end
context 'when the job does not have a trace file' do context 'when the job does not have a trace file' do
......
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