Commit 7363b6b3 authored by Maxime Orefice's avatar Maxime Orefice

Add artifactable module

This new module will be used to share comon logic
between our job artifact and our pipeline artifact.
parent 82678ecc
......@@ -8,6 +8,7 @@ module Ci
include UsageStatistics
include Sortable
include IgnorableColumns
include Artifactable
extend Gitlab::Ci::Model
NotSupportedAdapterError = Class.new(StandardError)
......@@ -200,12 +201,6 @@ module Ci
load_performance: 25 ## EE-specific
}
enum file_format: {
raw: 1,
zip: 2,
gzip: 3
}, _suffix: true
# `file_location` indicates where actual files are stored.
# 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.
......@@ -220,11 +215,6 @@ module Ci
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!
return if Feature.disabled?(:drop_license_management_artifact, project, default_enabled: true)
......
......@@ -5,6 +5,7 @@
module Ci
class PipelineArtifact < ApplicationRecord
extend Gitlab::Ci::Model
include Artifactable
FILE_STORE_SUPPORTED = [
ObjectStorage::Store::LOCAL,
......@@ -24,11 +25,5 @@ module Ci
enum file_type: {
code_coverage: 1
}
enum file_format: {
raw: 1,
zip: 2,
gzip: 3
}, _suffix: true
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