diff options
Diffstat (limited to 'spec/lib/gitlab/ci/config')
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/bridge_spec.rb | 3 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/include/rules/rule_spec.rb | 90 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/include/rules_spec.rb | 98 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/include_spec.rb | 40 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/inherit/variables_spec.rb | 15 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/job_spec.rb | 15 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/jobs_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/processable_spec.rb | 71 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/root_spec.rb | 5 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/rules_spec.rb | 72 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/external/mapper_spec.rb | 50 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/external/rules_spec.rb | 35 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/normalizer/matrix_strategy_spec.rb | 16 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/normalizer_spec.rb | 10 |
14 files changed, 365 insertions, 157 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/bridge_spec.rb b/spec/lib/gitlab/ci/config/entry/bridge_spec.rb index d294eca7f15..6c9c8fa5df5 100644 --- a/spec/lib/gitlab/ci/config/entry/bridge_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/bridge_spec.rb @@ -106,7 +106,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Bridge do ignore: false, stage: 'test', only: { refs: %w[branches tags] }, - variables: {}, job_variables: {}, root_variables_inheritance: true, scheduling_type: :stage) @@ -131,7 +130,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Bridge do ignore: false, stage: 'test', only: { refs: %w[branches tags] }, - variables: {}, job_variables: {}, root_variables_inheritance: true, scheduling_type: :stage) @@ -287,7 +285,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Bridge do only: { refs: %w[branches tags] }, parallel: { matrix: [{ 'PROVIDER' => ['aws'], 'STACK' => %w(monitoring app1) }, { 'PROVIDER' => ['gcp'], 'STACK' => %w(data) }] }, - variables: {}, job_variables: {}, root_variables_inheritance: true, scheduling_type: :stage diff --git a/spec/lib/gitlab/ci/config/entry/include/rules/rule_spec.rb b/spec/lib/gitlab/ci/config/entry/include/rules/rule_spec.rb new file mode 100644 index 00000000000..b99048e2c18 --- /dev/null +++ b/spec/lib/gitlab/ci/config/entry/include/rules/rule_spec.rb @@ -0,0 +1,90 @@ +# frozen_string_literal: true + +require 'fast_spec_helper' + +RSpec.describe Gitlab::Ci::Config::Entry::Include::Rules::Rule do + let(:factory) do + Gitlab::Config::Entry::Factory.new(described_class) + .value(config) + end + + subject(:entry) { factory.create! } + + describe '.new' do + shared_examples 'an invalid config' do |error_message| + it { is_expected.not_to be_valid } + + it 'has errors' do + expect(entry.errors).to include(error_message) + end + end + + context 'when specifying an if: clause' do + let(:config) { { if: '$THIS || $THAT' } } + + it { is_expected.to be_valid } + end + + context 'using a list of multiple expressions' do + let(:config) { { if: ['$MY_VAR == "this"', '$YOUR_VAR == "that"'] } } + + it_behaves_like 'an invalid config', /invalid expression syntax/ + end + + context 'when specifying an invalid if: clause expression' do + let(:config) { { if: ['$MY_VAR =='] } } + + it_behaves_like 'an invalid config', /invalid expression syntax/ + end + + context 'when specifying an if: clause expression with an invalid token' do + let(:config) { { if: ['$MY_VAR == 123'] } } + + it_behaves_like 'an invalid config', /invalid expression syntax/ + end + + context 'when using invalid regex in an if: clause' do + let(:config) { { if: ['$MY_VAR =~ /some ( thing/'] } } + + it_behaves_like 'an invalid config', /invalid expression syntax/ + end + + context 'when using an if: clause with lookahead regex character "?"' do + let(:config) { { if: '$CI_COMMIT_REF =~ /^(?!master).+/' } } + + context 'when allow_unsafe_ruby_regexp is disabled' do + it_behaves_like 'an invalid config', /invalid expression syntax/ + end + end + + context 'when specifying unknown policy' do + let(:config) { { invalid: :something } } + + it_behaves_like 'an invalid config', /unknown keys: invalid/ + end + + context 'when clause is empty' do + let(:config) { {} } + + it_behaves_like 'an invalid config', /can't be blank/ + end + + context 'when policy strategy does not match' do + let(:config) { 'string strategy' } + + it_behaves_like 'an invalid config', /should be a hash/ + end + end + + describe '#value' do + subject(:value) { entry.value } + + context 'when specifying an if: clause' do + let(:config) { { if: '$THIS || $THAT' } } + + it 'returns the config' do + expect(subject).to eq(if: '$THIS || $THAT') + end + end + end +end diff --git a/spec/lib/gitlab/ci/config/entry/include/rules_spec.rb b/spec/lib/gitlab/ci/config/entry/include/rules_spec.rb new file mode 100644 index 00000000000..c255d6e9dd6 --- /dev/null +++ b/spec/lib/gitlab/ci/config/entry/include/rules_spec.rb @@ -0,0 +1,98 @@ +# frozen_string_literal: true + +require 'fast_spec_helper' + +RSpec.describe Gitlab::Ci::Config::Entry::Include::Rules do + let(:factory) do + Gitlab::Config::Entry::Factory.new(described_class) + .value(config) + end + + subject(:entry) { factory.create! } + + describe '.new' do + shared_examples 'a valid config' do + it { is_expected.to be_valid } + + context 'when composed' do + before do + entry.compose! + end + + it { is_expected.to be_valid } + end + end + + shared_examples 'an invalid config' do |error_message| + it { is_expected.not_to be_valid } + + it 'has errors' do + expect(entry.errors).to include(error_message) + end + end + + context 'with an "if"' do + let(:config) do + [{ if: '$THIS == "that"' }] + end + + it_behaves_like 'a valid config' + end + + context 'with a "changes"' do + let(:config) do + [{ changes: ['filename.txt'] }] + end + + context 'when composed' do + before do + entry.compose! + end + + it_behaves_like 'an invalid config', /contains unknown keys: changes/ + end + end + + context 'with a list of two rules' do + let(:config) do + [ + { if: '$THIS == "that"' }, + { if: '$SKIP' } + ] + end + + it_behaves_like 'a valid config' + end + + context 'without an array' do + let(:config) do + { if: '$SKIP' } + end + + it_behaves_like 'an invalid config', /should be a array/ + end + end + + describe '#value' do + subject(:value) { entry.value } + + context 'with an "if"' do + let(:config) do + [{ if: '$THIS == "that"' }] + end + + it { is_expected.to eq(config) } + end + + context 'with a list of two rules' do + let(:config) do + [ + { if: '$THIS == "that"' }, + { if: '$SKIP' } + ] + end + + it { is_expected.to eq(config) } + end + end +end diff --git a/spec/lib/gitlab/ci/config/entry/include_spec.rb b/spec/lib/gitlab/ci/config/entry/include_spec.rb index 59f0b0e7a48..275cdcddeb0 100644 --- a/spec/lib/gitlab/ci/config/entry/include_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/include_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' RSpec.describe ::Gitlab::Ci::Config::Entry::Include do subject(:include_entry) { described_class.new(config) } @@ -86,6 +86,22 @@ RSpec.describe ::Gitlab::Ci::Config::Entry::Include do end end end + + context 'when using with "rules"' do + let(:config) { { local: 'test.yml', rules: [{ if: '$VARIABLE' }] } } + + it { is_expected.to be_valid } + + context 'when rules is not an array of hashes' do + let(:config) { { local: 'test.yml', rules: ['$VARIABLE'] } } + + it { is_expected.not_to be_valid } + + it 'has specific error' do + expect(include_entry.errors).to include('include rules should be an array of hashes') + end + end + end end context 'when value is something else' do @@ -94,4 +110,26 @@ RSpec.describe ::Gitlab::Ci::Config::Entry::Include do it { is_expected.not_to be_valid } end end + + describe '#value' do + subject(:value) { include_entry.value } + + context 'when config is a string' do + let(:config) { 'test.yml' } + + it { is_expected.to eq('test.yml') } + end + + context 'when config is a hash' do + let(:config) { { local: 'test.yml' } } + + it { is_expected.to eq(local: 'test.yml') } + end + + context 'when config has "rules"' do + let(:config) { { local: 'test.yml', rules: [{ if: '$VARIABLE' }] } } + + it { is_expected.to eq(local: 'test.yml', rules: [{ if: '$VARIABLE' }]) } + end + end end diff --git a/spec/lib/gitlab/ci/config/entry/inherit/variables_spec.rb b/spec/lib/gitlab/ci/config/entry/inherit/variables_spec.rb index b1a8fbcdbe0..bdb4d25c142 100644 --- a/spec/lib/gitlab/ci/config/entry/inherit/variables_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/inherit/variables_spec.rb @@ -24,19 +24,4 @@ RSpec.describe ::Gitlab::Ci::Config::Entry::Inherit::Variables do end end end - - describe '#inherit?' do - where(:config, :inherit) do - true | true - false | false - %w[A] | true - %w[B] | false - end - - with_them do - it do - expect(subject.inherit?('A')).to eq(inherit) - end - end - end end diff --git a/spec/lib/gitlab/ci/config/entry/job_spec.rb b/spec/lib/gitlab/ci/config/entry/job_spec.rb index 1d23ab0c2c7..5b47d3a3922 100644 --- a/spec/lib/gitlab/ci/config/entry/job_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/job_spec.rb @@ -434,20 +434,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Job do expect(entry.errors).to include 'job dependencies the another-job should be part of needs' end end - - context 'when stage: is missing' do - let(:config) do - { - script: 'echo', - needs: ['build-job'] - } - end - - it 'returns error about invalid data' do - expect(entry).not_to be_valid - expect(entry.errors).to include 'job config missing required keys: stage' - end - end end context 'when timeout value is not correct' do @@ -626,7 +612,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Job do ignore: false, after_script: %w[cleanup], only: { refs: %w[branches tags] }, - variables: {}, job_variables: {}, root_variables_inheritance: true, scheduling_type: :stage) diff --git a/spec/lib/gitlab/ci/config/entry/jobs_spec.rb b/spec/lib/gitlab/ci/config/entry/jobs_spec.rb index cb73044b62b..9a2a67389fc 100644 --- a/spec/lib/gitlab/ci/config/entry/jobs_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/jobs_spec.rb @@ -99,7 +99,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Jobs do only: { refs: %w[branches tags] }, stage: 'test', trigger: { project: 'my/project' }, - variables: {}, job_variables: {}, root_variables_inheritance: true, scheduling_type: :stage @@ -110,7 +109,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Jobs do only: { refs: %w[branches tags] }, script: ['something'], stage: 'test', - variables: {}, job_variables: {}, root_variables_inheritance: true, scheduling_type: :stage diff --git a/spec/lib/gitlab/ci/config/entry/processable_spec.rb b/spec/lib/gitlab/ci/config/entry/processable_spec.rb index f98a6a869d6..b872f6644a2 100644 --- a/spec/lib/gitlab/ci/config/entry/processable_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/processable_spec.rb @@ -362,76 +362,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Processable do end context 'with inheritance' do - context 'of variables' do - let(:config) do - { variables: { A: 'job', B: 'job' } } - end - - before do - entry.compose!(deps) - end - - context 'with only job variables' do - it 'does return defined variables' do - expect(entry.value).to include( - variables: { 'A' => 'job', 'B' => 'job' }, - job_variables: { 'A' => 'job', 'B' => 'job' }, - root_variables_inheritance: true - ) - end - end - - context 'when root yaml variables are used' do - let(:variables) do - Gitlab::Ci::Config::Entry::Variables.new( - { A: 'root', C: 'root', D: 'root' } - ).value - end - - it 'does return job and root variables' do - expect(entry.value).to include( - variables: { 'A' => 'job', 'B' => 'job', 'C' => 'root', 'D' => 'root' }, - job_variables: { 'A' => 'job', 'B' => 'job' }, - root_variables_inheritance: true - ) - end - - context 'when inherit of defaults is disabled' do - let(:config) do - { - variables: { A: 'job', B: 'job' }, - inherit: { variables: false } - } - end - - it 'does return job and root variables' do - expect(entry.value).to include( - variables: { 'A' => 'job', 'B' => 'job' }, - job_variables: { 'A' => 'job', 'B' => 'job' }, - root_variables_inheritance: false - ) - end - end - - context 'when inherit of only specific variable is enabled' do - let(:config) do - { - variables: { A: 'job', B: 'job' }, - inherit: { variables: ['D'] } - } - end - - it 'does return job and root variables' do - expect(entry.value).to include( - variables: { 'A' => 'job', 'B' => 'job', 'D' => 'root' }, - job_variables: { 'A' => 'job', 'B' => 'job' }, - root_variables_inheritance: ['D'] - ) - end - end - end - end - context 'of default:tags' do using RSpec::Parameterized::TableSyntax @@ -493,7 +423,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Processable do name: :rspec, stage: 'test', only: { refs: %w[branches tags] }, - variables: {}, job_variables: {}, root_variables_inheritance: true ) diff --git a/spec/lib/gitlab/ci/config/entry/root_spec.rb b/spec/lib/gitlab/ci/config/entry/root_spec.rb index 31e3545e8d8..d862fbf5b78 100644 --- a/spec/lib/gitlab/ci/config/entry/root_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/root_spec.rb @@ -132,7 +132,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Root do services: [{ name: 'postgres:9.1' }, { name: 'mysql:5.5' }], stage: 'test', cache: [{ key: 'k', untracked: true, paths: ['public/'], policy: 'pull-push', when: 'on_success' }], - variables: { 'VAR' => 'root', 'VAR2' => 'val 2' }, job_variables: {}, root_variables_inheritance: true, ignore: false, @@ -148,7 +147,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Root do services: [{ name: 'postgres:9.1' }, { name: 'mysql:5.5' }], stage: 'test', cache: [{ key: 'k', untracked: true, paths: ['public/'], policy: 'pull-push', when: 'on_success' }], - variables: { 'VAR' => 'root', 'VAR2' => 'val 2' }, job_variables: {}, root_variables_inheritance: true, ignore: false, @@ -166,7 +164,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Root do services: [{ name: "postgres:9.1" }, { name: "mysql:5.5" }], cache: [{ key: "k", untracked: true, paths: ["public/"], policy: "pull-push", when: 'on_success' }], only: { refs: %w(branches tags) }, - variables: { 'VAR' => 'job', 'VAR2' => 'val 2' }, job_variables: { 'VAR' => 'job' }, root_variables_inheritance: true, after_script: [], @@ -214,7 +211,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Root do services: [{ name: 'postgres:9.1' }, { name: 'mysql:5.5' }], stage: 'test', cache: [{ key: 'k', untracked: true, paths: ['public/'], policy: 'pull-push', when: 'on_success' }], - variables: { 'VAR' => 'root' }, job_variables: {}, root_variables_inheritance: true, ignore: false, @@ -228,7 +224,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Root do services: [{ name: 'postgres:9.1' }, { name: 'mysql:5.5' }], stage: 'test', cache: [{ key: 'k', untracked: true, paths: ['public/'], policy: 'pull-push', when: 'on_success' }], - variables: { 'VAR' => 'job' }, job_variables: { 'VAR' => 'job' }, root_variables_inheritance: true, ignore: false, diff --git a/spec/lib/gitlab/ci/config/entry/rules_spec.rb b/spec/lib/gitlab/ci/config/entry/rules_spec.rb index 7d26365e7b3..91252378541 100644 --- a/spec/lib/gitlab/ci/config/entry/rules_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/rules_spec.rb @@ -17,6 +17,10 @@ RSpec.describe Gitlab::Ci::Config::Entry::Rules do describe '.new' do subject { entry } + before do + subject.compose! + end + context 'with a list of rule rule' do let(:config) do [{ if: '$THIS == "that"', when: 'never' }] @@ -24,14 +28,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Rules do it { is_expected.to be_a(described_class) } it { is_expected.to be_valid } - - context 'when composed' do - before do - subject.compose! - end - - it { is_expected.to be_valid } - end end context 'with a list of two rules' do @@ -42,21 +38,34 @@ RSpec.describe Gitlab::Ci::Config::Entry::Rules do ] end - it { is_expected.to be_a(described_class) } it { is_expected.to be_valid } + end - context 'when composed' do - before do - subject.compose! - end + context 'with a single rule object' do + let(:config) do + { if: '$SKIP', when: 'never' } + end - it { is_expected.to be_valid } + it { is_expected.not_to be_valid } + end + + context 'with nested rules' do + let(:config) do + [ + { if: '$THIS == "that"', when: 'always' }, + [{ if: '$SKIP', when: 'never' }] + ] end + + it { is_expected.to be_valid } end - context 'with a single rule object' do + context 'with rules nested more than one level' do let(:config) do - { if: '$SKIP', when: 'never' } + [ + { if: '$THIS == "that"', when: 'always' }, + [{ if: '$SKIP', when: 'never' }, [{ if: '$THIS == "other"', when: 'aways' }]] + ] end it { is_expected.not_to be_valid } @@ -90,7 +99,36 @@ RSpec.describe Gitlab::Ci::Config::Entry::Rules do { if: '$SKIP', when: 'never' } end - it { is_expected.to eq(config) } + it { is_expected.to eq([config]) } + end + + context 'with nested rules' do + let(:first_rule) { { if: '$THIS == "that"', when: 'always' } } + let(:second_rule) { { if: '$SKIP', when: 'never' } } + + let(:config) do + [ + first_rule, + [second_rule] + ] + end + + it { is_expected.to contain_exactly(first_rule, second_rule) } + end + + context 'with rules nested more than one level' do + let(:first_rule) { { if: '$THIS == "that"', when: 'always' } } + let(:second_rule) { { if: '$SKIP', when: 'never' } } + let(:third_rule) { { if: '$THIS == "other"', when: 'aways' } } + + let(:config) do + [ + first_rule, + [second_rule, [third_rule]] + ] + end + + it { is_expected.to contain_exactly(first_rule, second_rule, third_rule) } end end diff --git a/spec/lib/gitlab/ci/config/external/mapper_spec.rb b/spec/lib/gitlab/ci/config/external/mapper_spec.rb index 88097f3f56a..a471997e43a 100644 --- a/spec/lib/gitlab/ci/config/external/mapper_spec.rb +++ b/spec/lib/gitlab/ci/config/external/mapper_spec.rb @@ -11,7 +11,7 @@ RSpec.describe Gitlab::Ci::Config::External::Mapper do let(:local_file) { '/lib/gitlab/ci/templates/non-existent-file.yml' } let(:remote_url) { 'https://gitlab.com/gitlab-org/gitlab-foss/blob/1234/.gitlab-ci-1.yml' } let(:template_file) { 'Auto-DevOps.gitlab-ci.yml' } - let(:context_params) { { project: project, sha: '123456', user: user, variables: project.predefined_variables.to_runner_variables } } + let(:context_params) { { project: project, sha: '123456', user: user, variables: project.predefined_variables } } let(:context) { Gitlab::Ci::Config::External::Context.new(**context_params) } let(:file_content) do @@ -347,15 +347,51 @@ RSpec.describe Gitlab::Ci::Config::External::Mapper do expect(subject.map(&:location)).to contain_exactly('myfolder/file1.yml', 'myfolder/file2.yml') end + end + + context "when 'include' has rules" do + let(:values) do + { include: [{ remote: remote_url }, + { local: local_file, rules: [{ if: "$CI_PROJECT_ID == '#{project_id}'" }] }], + image: 'ruby:2.7' } + end - context 'when the FF ci_wildcard_file_paths is disabled' do - before do - stub_feature_flags(ci_wildcard_file_paths: false) + context 'when the rules matches' do + let(:project_id) { project.id } + + it 'includes the file' do + expect(subject).to contain_exactly(an_instance_of(Gitlab::Ci::Config::External::File::Remote), + an_instance_of(Gitlab::Ci::Config::External::File::Local)) end - it 'cannot find any file returns an error message' do - expect(subject).to contain_exactly(an_instance_of(Gitlab::Ci::Config::External::File::Local)) - expect(subject[0].errors).to eq(['Local file `myfolder/*.yml` does not exist!']) + context 'when the FF ci_include_rules is disabled' do + before do + stub_feature_flags(ci_include_rules: false) + end + + it 'includes the file' do + expect(subject).to contain_exactly(an_instance_of(Gitlab::Ci::Config::External::File::Remote), + an_instance_of(Gitlab::Ci::Config::External::File::Local)) + end + end + end + + context 'when the rules does not match' do + let(:project_id) { non_existing_record_id } + + it 'does not include the file' do + expect(subject).to contain_exactly(an_instance_of(Gitlab::Ci::Config::External::File::Remote)) + end + + context 'when the FF ci_include_rules is disabled' do + before do + stub_feature_flags(ci_include_rules: false) + end + + it 'includes the file' do + expect(subject).to contain_exactly(an_instance_of(Gitlab::Ci::Config::External::File::Remote), + an_instance_of(Gitlab::Ci::Config::External::File::Local)) + end end end end diff --git a/spec/lib/gitlab/ci/config/external/rules_spec.rb b/spec/lib/gitlab/ci/config/external/rules_spec.rb new file mode 100644 index 00000000000..89ea13d710d --- /dev/null +++ b/spec/lib/gitlab/ci/config/external/rules_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require 'fast_spec_helper' + +RSpec.describe Gitlab::Ci::Config::External::Rules do + let(:rule_hashes) {} + + subject(:rules) { described_class.new(rule_hashes) } + + describe '#evaluate' do + let(:context) { double(variables: {}) } + + subject(:result) { rules.evaluate(context).pass? } + + context 'when there is no rule' do + it { is_expected.to eq(true) } + end + + context 'when there is a rule' do + let(:rule_hashes) { [{ if: '$MY_VAR == "hello"' }] } + + context 'when the rule matches' do + let(:context) { double(variables: { MY_VAR: 'hello' }) } + + it { is_expected.to eq(true) } + end + + context 'when the rule does not match' do + let(:context) { double(variables: { MY_VAR: 'invalid' }) } + + it { is_expected.to eq(false) } + end + end + end +end diff --git a/spec/lib/gitlab/ci/config/normalizer/matrix_strategy_spec.rb b/spec/lib/gitlab/ci/config/normalizer/matrix_strategy_spec.rb index e5f0341c5fe..a29471706cc 100644 --- a/spec/lib/gitlab/ci/config/normalizer/matrix_strategy_spec.rb +++ b/spec/lib/gitlab/ci/config/normalizer/matrix_strategy_spec.rb @@ -50,10 +50,6 @@ RSpec.describe Gitlab::Ci::Config::Normalizer::MatrixStrategy do name: 'test: [aws, app1]', instance: 1, parallel: { total: 4 }, - variables: { - 'PROVIDER' => 'aws', - 'STACK' => 'app1' - }, job_variables: { 'PROVIDER' => 'aws', 'STACK' => 'app1' @@ -63,10 +59,6 @@ RSpec.describe Gitlab::Ci::Config::Normalizer::MatrixStrategy do name: 'test: [aws, app2]', instance: 2, parallel: { total: 4 }, - variables: { - 'PROVIDER' => 'aws', - 'STACK' => 'app2' - }, job_variables: { 'PROVIDER' => 'aws', 'STACK' => 'app2' @@ -76,10 +68,6 @@ RSpec.describe Gitlab::Ci::Config::Normalizer::MatrixStrategy do name: 'test: [ovh, app]', instance: 3, parallel: { total: 4 }, - variables: { - 'PROVIDER' => 'ovh', - 'STACK' => 'app' - }, job_variables: { 'PROVIDER' => 'ovh', 'STACK' => 'app' @@ -89,10 +77,6 @@ RSpec.describe Gitlab::Ci::Config::Normalizer::MatrixStrategy do name: 'test: [gcp, app]', instance: 4, parallel: { total: 4 }, - variables: { - 'PROVIDER' => 'gcp', - 'STACK' => 'app' - }, job_variables: { 'PROVIDER' => 'gcp', 'STACK' => 'app' diff --git a/spec/lib/gitlab/ci/config/normalizer_spec.rb b/spec/lib/gitlab/ci/config/normalizer_spec.rb index 4c19657413c..354392eb42e 100644 --- a/spec/lib/gitlab/ci/config/normalizer_spec.rb +++ b/spec/lib/gitlab/ci/config/normalizer_spec.rb @@ -4,7 +4,7 @@ require 'fast_spec_helper' RSpec.describe Gitlab::Ci::Config::Normalizer do let(:job_name) { :rspec } - let(:job_config) { { script: 'rspec', parallel: parallel_config, name: 'rspec', variables: variables_config } } + let(:job_config) { { script: 'rspec', parallel: parallel_config, name: 'rspec', job_variables: variables_config } } let(:config) { { job_name => job_config } } describe '.normalize_jobs' do @@ -202,21 +202,21 @@ RSpec.describe Gitlab::Ci::Config::Normalizer do it 'sets job variables', :aggregate_failures do expect(subject.values[0]).to match( - a_hash_including(variables: { VAR_1: 'A', VAR_2: 'B', USER_VARIABLE: 'user value' }) + a_hash_including(job_variables: { VAR_1: 'A', VAR_2: 'B', USER_VARIABLE: 'user value' }) ) expect(subject.values[1]).to match( - a_hash_including(variables: { VAR_1: 'A', VAR_2: 'C', USER_VARIABLE: 'user value' }) + a_hash_including(job_variables: { VAR_1: 'A', VAR_2: 'C', USER_VARIABLE: 'user value' }) ) end it 'parallelizes jobs with original config' do configs = subject.values.map do |config| - config.except(:name, :instance, :variables) + config.except(:name, :instance, :job_variables) end original_config = config[job_name] - .except(:name, :variables) + .except(:name, :job_variables) .deep_merge(parallel: { total: 2 }) expect(configs).to all(match(a_hash_including(original_config))) |