diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-04-03 21:01:03 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-04-03 21:01:03 +0300 |
commit | 59a158955e1ae09420ad05e53782e0dbc512e9c8 (patch) | |
tree | 3f85ca0670ae670122abb1e7f94e263ed818a51e | |
parent | cdc7d5a64326fd873548f5d7253c0206e930e22d (diff) | |
parent | b92b481b2ccbea651a1b6777cba13edf5c2919ff (diff) |
Merge branch '43745-store-metadata-checksum-for-artifacts' into 'master'
Store sha256 checksum of Metadata in `ci_job_artifacts` table
See merge request gitlab-org/gitlab-ce!18149
-rw-r--r-- | changelogs/unreleased/43745-store-metadata-checksum-for-artifacts.yml | 5 | ||||
-rw-r--r-- | lib/api/runner.rb | 3 | ||||
-rw-r--r-- | spec/requests/api/runner_spec.rb | 6 |
3 files changed, 12 insertions, 2 deletions
diff --git a/changelogs/unreleased/43745-store-metadata-checksum-for-artifacts.yml b/changelogs/unreleased/43745-store-metadata-checksum-for-artifacts.yml new file mode 100644 index 00000000000..6283e797930 --- /dev/null +++ b/changelogs/unreleased/43745-store-metadata-checksum-for-artifacts.yml @@ -0,0 +1,5 @@ +--- +title: Store sha256 checksum of artifact metadata +merge_request: 18149 +author: +type: added diff --git a/lib/api/runner.rb b/lib/api/runner.rb index 57c0a729535..834253d8e94 100644 --- a/lib/api/runner.rb +++ b/lib/api/runner.rb @@ -208,6 +208,7 @@ module API optional 'file.sha256', type: String, desc: %q(sha256 checksum of the file) optional 'metadata.path', type: String, desc: %q(path to locally stored body (generated by Workhorse)) optional 'metadata.name', type: String, desc: %q(filename (generated by Workhorse)) + optional 'metadata.sha256', type: String, desc: %q(sha256 checksum of the file) end post '/:id/artifacts' do not_allowed! unless Gitlab.config.artifacts.enabled @@ -227,7 +228,7 @@ module API Gitlab::CurrentSettings.current_application_settings.default_artifacts_expire_in job.build_job_artifacts_archive(project: job.project, file_type: :archive, file: artifacts, file_sha256: params['file.sha256'], expire_in: expire_in) - job.build_job_artifacts_metadata(project: job.project, file_type: :metadata, file: metadata, expire_in: expire_in) if metadata + job.build_job_artifacts_metadata(project: job.project, file_type: :metadata, file: metadata, file_sha256: params['metadata.sha256'], expire_in: expire_in) if metadata job.artifacts_expire_in = expire_in if job.save diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index 5084b36c761..4f3420cc0ad 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -1159,11 +1159,13 @@ describe API::Runner do let!(:artifacts) { file_upload } let!(:artifacts_sha256) { Digest::SHA256.file(artifacts.path).hexdigest } let!(:metadata) { file_upload2 } + let!(:metadata_sha256) { Digest::SHA256.file(metadata.path).hexdigest } let(:stored_artifacts_file) { job.reload.artifacts_file.file } let(:stored_metadata_file) { job.reload.artifacts_metadata.file } let(:stored_artifacts_size) { job.reload.artifacts_size } let(:stored_artifacts_sha256) { job.reload.job_artifacts_archive.file_sha256 } + let(:stored_metadata_sha256) { job.reload.job_artifacts_metadata.file_sha256 } before do post(api("/jobs/#{job.id}/artifacts"), post_data, headers_with_token) @@ -1175,7 +1177,8 @@ describe API::Runner do 'file.name' => artifacts.original_filename, 'file.sha256' => artifacts_sha256, 'metadata.path' => metadata.path, - 'metadata.name' => metadata.original_filename } + 'metadata.name' => metadata.original_filename, + 'metadata.sha256' => metadata_sha256 } end it 'stores artifacts and artifacts metadata' do @@ -1184,6 +1187,7 @@ describe API::Runner do expect(stored_metadata_file.original_filename).to eq(metadata.original_filename) expect(stored_artifacts_size).to eq(72821) expect(stored_artifacts_sha256).to eq(artifacts_sha256) + expect(stored_metadata_sha256).to eq(metadata_sha256) end end |