diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-10-26 22:02:09 +0200 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-10-26 22:02:18 +0200 |
commit | d9b56bc13b94bdc69a14a2b4201e25e141a62ce4 (patch) | |
tree | 05c2a52bad0f160c565d160b518c7baa6c93eb4d | |
parent | e997b22df50a46759cac9936a6557993310f8888 (diff) | |
download | gitlab-ce-d9b56bc13b94bdc69a14a2b4201e25e141a62ce4.tar.gz |
Add parallel keyword to CI config
-rw-r--r-- | lib/gitlab/ci/config/entry/job.rb | 14 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/job_spec.rb | 33 |
2 files changed, 40 insertions, 7 deletions
diff --git a/lib/gitlab/ci/config/entry/job.rb b/lib/gitlab/ci/config/entry/job.rb index f290ff3a565..368b5eb2a89 100644 --- a/lib/gitlab/ci/config/entry/job.rb +++ b/lib/gitlab/ci/config/entry/job.rb @@ -12,7 +12,7 @@ module Gitlab ALLOWED_KEYS = %i[tags script only except type image services allow_failure type stage when start_in artifacts cache dependencies before_script after_script variables - environment coverage retry extends].freeze + environment coverage retry parallel extends].freeze validations do validates :config, allowed_keys: ALLOWED_KEYS @@ -27,6 +27,8 @@ module Gitlab validates :retry, numericality: { only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 2 } + validates :parallel, numericality: { only_integer: true, + greater_than_or_equal_to: 1 } validates :when, inclusion: { in: %w[on_success on_failure always manual delayed], message: 'should be on_success, on_failure, ' \ @@ -77,17 +79,18 @@ module Gitlab description: 'Artifacts configuration for this job.' entry :environment, Entry::Environment, - description: 'Environment configuration for this job.' + description: 'Environment configuration for this job.' entry :coverage, Entry::Coverage, - description: 'Coverage configuration for this job.' + description: 'Coverage configuration for this job.' helpers :before_script, :script, :stage, :type, :after_script, :cache, :image, :services, :only, :except, :variables, - :artifacts, :commands, :environment, :coverage, :retry + :artifacts, :commands, :environment, :coverage, :retry, + :parallel attributes :script, :tags, :allow_failure, :when, :dependencies, - :retry, :extends, :start_in + :retry, :parallel, :extends, :start_in def compose!(deps = nil) super do @@ -156,6 +159,7 @@ module Gitlab environment_name: environment_defined? ? environment_value[:name] : nil, coverage: coverage_defined? ? coverage_value : nil, retry: retry_defined? ? retry_value.to_i : nil, + parallel: parallel_defined? ? parallel_value.to_i : nil, artifacts: artifacts_value, after_script: after_script_value, ignore: ignored? } diff --git a/spec/lib/gitlab/ci/config/entry/job_spec.rb b/spec/lib/gitlab/ci/config/entry/job_spec.rb index 1169938b80c..718098c364e 100644 --- a/spec/lib/gitlab/ci/config/entry/job_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/job_spec.rb @@ -1,5 +1,4 @@ -require 'fast_spec_helper' -require_dependency 'active_model' +require 'spec_helper' describe Gitlab::Ci::Config::Entry::Job do let(:entry) { described_class.new(config, name: :rspec) } @@ -138,6 +137,36 @@ describe Gitlab::Ci::Config::Entry::Job do 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 start_in is specified' do let(:config) { { script: 'echo', when: 'delayed', start_in: '1 day' } } |