diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-03-06 18:41:23 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-03-06 18:41:23 +0000 |
commit | ee2cfd0f5a30582bd8588fe8a0196dfb887f3a0a (patch) | |
tree | 40fb6b279e5626b987ce53914b5046e301272910 | |
parent | c5160c11c0364bb577d7b4ef56784fc709b301d4 (diff) | |
parent | 0b49e8e646e114d213c15e9fc3e360e644fcd5b3 (diff) | |
download | gitlab-ce-ee2cfd0f5a30582bd8588fe8a0196dfb887f3a0a.tar.gz |
Merge branch 'sha256-checksum-for-trace' into 'master'
Set sha256 checksum when archiving traces
Closes #43940
See merge request gitlab-org/gitlab-ce!17570
-rw-r--r-- | lib/gitlab/ci/trace.rb | 3 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/trace_spec.rb | 10 |
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/gitlab/ci/trace.rb b/lib/gitlab/ci/trace.rb index c5356af2f02..cedf4171ab1 100644 --- a/lib/gitlab/ci/trace.rb +++ b/lib/gitlab/ci/trace.rb @@ -137,7 +137,8 @@ module Gitlab job.create_job_artifacts_trace!( project: job.project, file_type: :trace, - file: stream) + file: stream, + file_sha256: Digest::SHA256.file(path).hexdigest) end end diff --git a/spec/lib/gitlab/ci/trace_spec.rb b/spec/lib/gitlab/ci/trace_spec.rb index 1c73043cfbd..448c6fb57dd 100644 --- a/spec/lib/gitlab/ci/trace_spec.rb +++ b/spec/lib/gitlab/ci/trace_spec.rb @@ -413,7 +413,8 @@ describe Gitlab::Ci::Trace do expect(build.job_artifacts_trace.file.filename).to eq('job.log') expect(File.exist?(src_path)).to be_falsy expect(src_checksum) - .to eq(Digest::SHA256.file(build.job_artifacts_trace.file.path).digest) + .to eq(Digest::SHA256.file(build.job_artifacts_trace.file.path).hexdigest) + expect(build.job_artifacts_trace.file_sha256).to eq(src_checksum) end end @@ -438,7 +439,8 @@ describe Gitlab::Ci::Trace do expect(build.job_artifacts_trace.file.filename).to eq('job.log') expect(build.old_trace).to be_nil expect(src_checksum) - .to eq(Digest::SHA256.file(build.job_artifacts_trace.file.path).digest) + .to eq(Digest::SHA256.file(build.job_artifacts_trace.file.path).hexdigest) + expect(build.job_artifacts_trace.file_sha256).to eq(src_checksum) end end @@ -457,7 +459,7 @@ describe Gitlab::Ci::Trace do context 'when trace file stored in default path' do let!(:build) { create(:ci_build, :success, :trace_live) } let!(:src_path) { trace.read { |s| return s.path } } - let!(:src_checksum) { Digest::SHA256.file(src_path).digest } + let!(:src_checksum) { Digest::SHA256.file(src_path).hexdigest } it_behaves_like 'archive trace file' @@ -483,7 +485,7 @@ describe Gitlab::Ci::Trace do context 'when trace is stored in database' do let(:build) { create(:ci_build, :success) } let(:trace_content) { 'Sample trace' } - let!(:src_checksum) { Digest::SHA256.digest(trace_content) } + let!(:src_checksum) { Digest::SHA256.hexdigest(trace_content) } before do build.update_column(:trace, trace_content) |