Commit 3925083c authored by Robert Speicher's avatar Robert Speicher

Merge branch 'mo-extract-file-format-adapter-to-concern' into 'master'

Add Artifactable module

See merge request gitlab-org/gitlab!39224
parents 610bbf29 7363b6b3
...@@ -8,6 +8,7 @@ module Ci ...@@ -8,6 +8,7 @@ module Ci
include UsageStatistics include UsageStatistics
include Sortable include Sortable
include IgnorableColumns include IgnorableColumns
include Artifactable
extend Gitlab::Ci::Model extend Gitlab::Ci::Model
NotSupportedAdapterError = Class.new(StandardError) NotSupportedAdapterError = Class.new(StandardError)
...@@ -200,12 +201,6 @@ module Ci ...@@ -200,12 +201,6 @@ module Ci
load_performance: 25 ## EE-specific load_performance: 25 ## EE-specific
} }
enum file_format: {
raw: 1,
zip: 2,
gzip: 3
}, _suffix: true
# `file_location` indicates where actual files are stored. # `file_location` indicates where actual files are stored.
# Ideally, actual files should be stored in the same directory, and use the same # Ideally, actual files should be stored in the same directory, and use the same
# convention to generate its path. However, sometimes we can't do so due to backward-compatibility. # convention to generate its path. However, sometimes we can't do so due to backward-compatibility.
...@@ -220,11 +215,6 @@ module Ci ...@@ -220,11 +215,6 @@ module Ci
hashed_path: 2 hashed_path: 2
} }
FILE_FORMAT_ADAPTERS = {
gzip: Gitlab::Ci::Build::Artifacts::Adapters::GzipStream,
raw: Gitlab::Ci::Build::Artifacts::Adapters::RawStream
}.freeze
def validate_supported_file_format! def validate_supported_file_format!
return if Feature.disabled?(:drop_license_management_artifact, project, default_enabled: true) return if Feature.disabled?(:drop_license_management_artifact, project, default_enabled: true)
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
module Ci module Ci
class PipelineArtifact < ApplicationRecord class PipelineArtifact < ApplicationRecord
extend Gitlab::Ci::Model extend Gitlab::Ci::Model
include Artifactable
FILE_STORE_SUPPORTED = [ FILE_STORE_SUPPORTED = [
ObjectStorage::Store::LOCAL, ObjectStorage::Store::LOCAL,
...@@ -24,11 +25,5 @@ module Ci ...@@ -24,11 +25,5 @@ module Ci
enum file_type: { enum file_type: {
code_coverage: 1 code_coverage: 1
} }
enum file_format: {
raw: 1,
zip: 2,
gzip: 3
}, _suffix: true
end end
end end
# frozen_string_literal: true
module Ci
module Artifactable
extend ActiveSupport::Concern
FILE_FORMAT_ADAPTERS = {
gzip: Gitlab::Ci::Build::Artifacts::Adapters::GzipStream,
raw: Gitlab::Ci::Build::Artifacts::Adapters::RawStream
}.freeze
included do
enum file_format: {
raw: 1,
zip: 2,
gzip: 3
}, _suffix: true
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ci::Artifactable do
let(:ci_job_artifact) { build(:ci_job_artifact) }
describe 'artifact properties are included' do
context 'when enum is defined' do
subject { ci_job_artifact }
it { is_expected.to define_enum_for(:file_format).with_values(raw: 1, zip: 2, gzip: 3).with_suffix }
end
context 'when const is defined' do
subject { ci_job_artifact.class }
it { is_expected.to be_const_defined(:FILE_FORMAT_ADAPTERS) }
end
end
end
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