Commit 939fe31a authored by Cédric Tabin's avatar Cédric Tabin Committed by Kamil Trzciński
Browse files

Allows interruptible keyword in default

parent 36a02ae4
......@@ -135,6 +135,7 @@ The following job parameters can be defined inside a `default:` block:
- [`before_script`](#before_script-and-after_script)
- [`after_script`](#before_script-and-after_script)
- [`cache`](#cache)
- [`interruptible`](#interruptible)
 
In the following example, the `ruby:2.5` image is set as the default for all
jobs except the `rspec 2.6` job, which uses the `ruby:2.6` image:
......
......@@ -13,7 +13,7 @@ describe EE::Gitlab::Ci::Config::Entry::Bridge do
# that we know that we don't want to inherit
# as they do not have sense in context of Bridge
let(:ignored_inheritable_columns) do
%i[before_script after_script image services cache]
%i[before_script after_script image services cache interruptible]
end
end
 
......
# frozen_string_literal: true
module Gitlab
module Ci
class Config
module Entry
##
# Entry that represents the interrutible value.
#
class Boolean < ::Gitlab::Config::Entry::Node
include ::Gitlab::Config::Entry::Validatable
validations do
validates :config, boolean: true
end
end
end
end
end
end
......@@ -14,7 +14,7 @@ module Gitlab
include ::Gitlab::Config::Entry::Inheritable
 
ALLOWED_KEYS = %i[before_script image services
after_script cache].freeze
after_script cache interruptible].freeze
 
validations do
validates :config, allowed_keys: ALLOWED_KEYS
......@@ -40,7 +40,11 @@ module Gitlab
description: 'Configure caching between build jobs.',
inherit: true
 
helpers :before_script, :image, :services, :after_script, :cache
entry :interruptible, Entry::Boolean,
description: 'Set jobs interruptible default value.',
inherit: false
helpers :before_script, :image, :services, :after_script, :cache, :interruptible
 
private
 
......
......@@ -38,7 +38,6 @@ module Gitlab
with_options allow_nil: true do
validates :tags, array_of_strings: true
validates :allow_failure, boolean: true
validates :interruptible, boolean: true
validates :parallel, numericality: { only_integer: true,
greater_than_or_equal_to: 2,
less_than_or_equal_to: 50 }
......@@ -100,6 +99,10 @@ module Gitlab
description: 'Services that will be used to execute this job.',
inherit: true
 
entry :interruptible, Entry::Boolean,
description: 'Set jobs interruptible value.',
inherit: true
entry :only, Entry::Policy,
description: 'Refs policy this job will be executed for.',
default: Entry::Policy::DEFAULT_ONLY,
......
......@@ -26,7 +26,7 @@ describe Gitlab::Ci::Config::Entry::Default do
it 'contains the expected node names' do
expect(described_class.nodes.keys)
.to match_array(%i[before_script image services
after_script cache])
after_script cache interruptible])
end
end
end
......
......@@ -24,7 +24,7 @@ describe Gitlab::Ci::Config::Entry::Job do
let(:result) do
%i[before_script script stage type after_script cache
image services only except rules needs variables artifacts
environment coverage retry]
environment coverage retry interruptible]
end
 
it { is_expected.to match_array result }
......
......@@ -108,6 +108,25 @@ module Gitlab
 
it { expect(subject[:interruptible]).to be_falsy }
end
it "returns interruptible when overridden for job" do
config = YAML.dump({ default: { interruptible: true },
rspec: { script: "rspec" } })
config_processor = Gitlab::Ci::YamlProcessor.new(config)
expect(config_processor.stage_builds_attributes("test").size).to eq(1)
expect(config_processor.stage_builds_attributes("test").first).to eq({
stage: "test",
stage_idx: 2,
name: "rspec",
options: { script: ["rspec"] },
interruptible: true,
allow_failure: false,
when: "on_success",
yaml_variables: []
})
end
end
 
describe 'retry entry' do
......
Supports Markdown
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