Commit d9b56bc1 authored by Matija Čupić's avatar Matija Čupić

Add parallel keyword to CI config

parent e997b22d
...@@ -12,7 +12,7 @@ module Gitlab ...@@ -12,7 +12,7 @@ module Gitlab
ALLOWED_KEYS = %i[tags script only except type image services ALLOWED_KEYS = %i[tags script only except type image services
allow_failure type stage when start_in artifacts cache allow_failure type stage when start_in artifacts cache
dependencies before_script after_script variables dependencies before_script after_script variables
environment coverage retry extends].freeze environment coverage retry parallel extends].freeze
validations do validations do
validates :config, allowed_keys: ALLOWED_KEYS validates :config, allowed_keys: ALLOWED_KEYS
...@@ -27,6 +27,8 @@ module Gitlab ...@@ -27,6 +27,8 @@ module Gitlab
validates :retry, numericality: { only_integer: true, validates :retry, numericality: { only_integer: true,
greater_than_or_equal_to: 0, greater_than_or_equal_to: 0,
less_than_or_equal_to: 2 } less_than_or_equal_to: 2 }
validates :parallel, numericality: { only_integer: true,
greater_than_or_equal_to: 1 }
validates :when, validates :when,
inclusion: { in: %w[on_success on_failure always manual delayed], inclusion: { in: %w[on_success on_failure always manual delayed],
message: 'should be on_success, on_failure, ' \ message: 'should be on_success, on_failure, ' \
...@@ -84,10 +86,11 @@ module Gitlab ...@@ -84,10 +86,11 @@ module Gitlab
helpers :before_script, :script, :stage, :type, :after_script, helpers :before_script, :script, :stage, :type, :after_script,
:cache, :image, :services, :only, :except, :variables, :cache, :image, :services, :only, :except, :variables,
:artifacts, :commands, :environment, :coverage, :retry :artifacts, :commands, :environment, :coverage, :retry,
:parallel
attributes :script, :tags, :allow_failure, :when, :dependencies, attributes :script, :tags, :allow_failure, :when, :dependencies,
:retry, :extends, :start_in :retry, :parallel, :extends, :start_in
def compose!(deps = nil) def compose!(deps = nil)
super do super do
...@@ -156,6 +159,7 @@ module Gitlab ...@@ -156,6 +159,7 @@ module Gitlab
environment_name: environment_defined? ? environment_value[:name] : nil, environment_name: environment_defined? ? environment_value[:name] : nil,
coverage: coverage_defined? ? coverage_value : nil, coverage: coverage_defined? ? coverage_value : nil,
retry: retry_defined? ? retry_value.to_i : nil, retry: retry_defined? ? retry_value.to_i : nil,
parallel: parallel_defined? ? parallel_value.to_i : nil,
artifacts: artifacts_value, artifacts: artifacts_value,
after_script: after_script_value, after_script: after_script_value,
ignore: ignored? } ignore: ignored? }
......
require 'fast_spec_helper' require 'spec_helper'
require_dependency 'active_model'
describe Gitlab::Ci::Config::Entry::Job do describe Gitlab::Ci::Config::Entry::Job do
let(:entry) { described_class.new(config, name: :rspec) } let(:entry) { described_class.new(config, name: :rspec) }
...@@ -138,6 +137,36 @@ describe Gitlab::Ci::Config::Entry::Job do ...@@ -138,6 +137,36 @@ describe Gitlab::Ci::Config::Entry::Job do
end end
end end
context 'when parallel value is not correct' do
context 'when it is not a numeric value' do
let(:config) { { parallel: true } }
it 'returns error about invalid type' do
expect(entry).not_to be_valid
expect(entry.errors).to include 'job parallel is not a number'
end
end
context 'when it is lower than one' do
let(:config) { { parallel: 0 } }
it 'returns error about value too low' do
expect(entry).not_to be_valid
expect(entry.errors)
.to include 'job parallel must be greater than or equal to 1'
end
end
context 'when it is not an integer' do
let(:config) { { parallel: 1.5 } }
it 'returns error about wrong value' do
expect(entry).not_to be_valid
expect(entry.errors).to include 'job parallel must be an integer'
end
end
end
context 'when delayed job' do context 'when delayed job' do
context 'when start_in is specified' do context 'when start_in is specified' do
let(:config) { { script: 'echo', when: 'delayed', start_in: '1 day' } } let(:config) { { script: 'echo', when: 'delayed', start_in: '1 day' } }
......
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