diff options
Diffstat (limited to 'spec/lib/gitlab/ci/config')
9 files changed, 85 insertions, 76 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/environment_spec.rb b/spec/lib/gitlab/ci/config/entry/environment_spec.rb index dd8a79f0d84..36c26c8ee4f 100644 --- a/spec/lib/gitlab/ci/config/entry/environment_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/environment_spec.rb @@ -92,24 +92,18 @@ RSpec.describe Gitlab::Ci::Config::Entry::Environment do end context 'when valid action is used' do - let(:config) do - { name: 'production', - action: 'start' } - end - - it 'is valid' do - expect(entry).to be_valid + where(:action) do + %w(start stop prepare verify access) end - end - context 'when prepare action is used' do - let(:config) do - { name: 'production', - action: 'prepare' } - end + with_them do + let(:config) do + { name: 'production', action: action } + end - it 'is valid' do - expect(entry).to be_valid + it 'is valid' do + expect(entry).to be_valid + end end end @@ -148,7 +142,7 @@ RSpec.describe Gitlab::Ci::Config::Entry::Environment do describe '#errors' do it 'contains error about invalid action' do expect(entry.errors) - .to include 'environment action should be start, stop or prepare' + .to include 'environment action should be start, stop, prepare, verify, or access' 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 97691504abd..ca336c3ecaa 100644 --- a/spec/lib/gitlab/ci/config/entry/job_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/job_spec.rb @@ -27,7 +27,7 @@ RSpec.describe Gitlab::Ci::Config::Entry::Job do subject { described_class.nodes.keys } let(:result) do - %i[before_script script stage type after_script cache + %i[before_script script stage after_script cache image services only except rules needs variables artifacts environment coverage retry interruptible timeout release tags inherit parallel] diff --git a/spec/lib/gitlab/ci/config/entry/reports_spec.rb b/spec/lib/gitlab/ci/config/entry/reports_spec.rb index 061d8f34c8d..051cccb4833 100644 --- a/spec/lib/gitlab/ci/config/entry/reports_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/reports_spec.rb @@ -45,10 +45,8 @@ RSpec.describe Gitlab::Ci::Config::Entry::Reports do :load_performance | 'load-performance.json' :lsif | 'lsif.json' :dotenv | 'build.dotenv' - :cobertura | 'cobertura-coverage.xml' :terraform | 'tfplan.json' :accessibility | 'gl-accessibility.json' - :cluster_applications | 'gl-cluster-applications.json' end with_them do @@ -90,18 +88,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Reports do expect(entry.value).to eq({ coverage_report: coverage_report, dast: ['gl-dast-report.json'] }) end end - - context 'and a direct coverage report format is specified' do - let(:config) { { coverage_report: coverage_report, cobertura: 'cobertura-coverage.xml' } } - - it 'is not valid' do - expect(entry).not_to be_valid - end - - it 'reports error' do - expect(entry.errors).to include /please use only one the following keys: coverage_report, cobertura/ - end - end end end diff --git a/spec/lib/gitlab/ci/config/entry/root_spec.rb b/spec/lib/gitlab/ci/config/entry/root_spec.rb index b9c32bc51be..55ad119ea21 100644 --- a/spec/lib/gitlab/ci/config/entry/root_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/root_spec.rb @@ -21,7 +21,7 @@ RSpec.describe Gitlab::Ci::Config::Entry::Root do # The purpose of `Root` is have only globally defined configuration. expect(described_class.nodes.keys) .to match_array(%i[before_script image services after_script - variables cache stages types include default workflow]) + variables cache stages include default workflow]) end end end @@ -55,41 +55,6 @@ RSpec.describe Gitlab::Ci::Config::Entry::Root do } end - context 'when deprecated types/type keywords are defined' do - let(:project) { create(:project, :repository) } - let(:user) { create(:user) } - - let(:hash) do - { types: %w(test deploy), - rspec: { script: 'rspec', type: 'test' } } - end - - before do - root.compose! - end - - it 'returns array of types as stages with a warning' do - expect(root.jobs_value[:rspec][:stage]).to eq 'test' - expect(root.stages_value).to eq %w[test deploy] - expect(root.warnings).to match_array([ - "root `types` is deprecated in 9.0 and will be removed in 15.0.", - "jobs:rspec `type` is deprecated in 9.0 and will be removed in 15.0." - ]) - end - - it 'logs usage of keywords' do - expect(Gitlab::AppJsonLogger).to( - receive(:info) - .with(event: 'ci_used_deprecated_keyword', - entry: root[:stages].key.to_s, - user_id: user.id, - project_id: project.id) - ) - - root.compose! - end - end - describe '#compose!' do before do root.compose! diff --git a/spec/lib/gitlab/ci/config/external/file/local_spec.rb b/spec/lib/gitlab/ci/config/external/file/local_spec.rb index c0a0b0009ce..0e78498c98e 100644 --- a/spec/lib/gitlab/ci/config/external/file/local_spec.rb +++ b/spec/lib/gitlab/ci/config/external/file/local_spec.rb @@ -199,6 +199,8 @@ RSpec.describe Gitlab::Ci::Config::External::File::Local do context_sha: '12345', type: :local, location: location, + blob: "http://localhost/#{project.full_path}/-/blob/12345/lib/gitlab/ci/templates/existent-file.yml", + raw: "http://localhost/#{project.full_path}/-/raw/12345/lib/gitlab/ci/templates/existent-file.yml", extra: {} ) } diff --git a/spec/lib/gitlab/ci/config/external/file/project_spec.rb b/spec/lib/gitlab/ci/config/external/file/project_spec.rb index 5d3412a148b..77e542cf933 100644 --- a/spec/lib/gitlab/ci/config/external/file/project_spec.rb +++ b/spec/lib/gitlab/ci/config/external/file/project_spec.rb @@ -207,6 +207,8 @@ RSpec.describe Gitlab::Ci::Config::External::File::Project do context_sha: '12345', type: :file, location: '/file.yml', + blob: "http://localhost/#{project.full_path}/-/blob/#{project.commit('master').id}/file.yml", + raw: "http://localhost/#{project.full_path}/-/raw/#{project.commit('master').id}/file.yml", extra: { project: project.full_path, ref: 'HEAD' } ) } @@ -227,6 +229,8 @@ RSpec.describe Gitlab::Ci::Config::External::File::Project do context_sha: '12345', type: :file, location: '/file.yml', + blob: nil, + raw: nil, extra: { project: 'xxxxxxxxxxxxxxxxxxxxxxxx', ref: 'xxxxxxxxxxxxxxxxxxxxxxxx' } ) } diff --git a/spec/lib/gitlab/ci/config/external/file/remote_spec.rb b/spec/lib/gitlab/ci/config/external/file/remote_spec.rb index 5c07c87fd5a..3e1c4df4e32 100644 --- a/spec/lib/gitlab/ci/config/external/file/remote_spec.rb +++ b/spec/lib/gitlab/ci/config/external/file/remote_spec.rb @@ -213,6 +213,8 @@ RSpec.describe Gitlab::Ci::Config::External::File::Remote do context_sha: '12345', type: :remote, location: 'https://gitlab.com/gitlab-org/gitlab-foss/blob/1234/.xxxxxxxxxxx.yml', + raw: 'https://gitlab.com/gitlab-org/gitlab-foss/blob/1234/.xxxxxxxxxxx.yml', + blob: nil, extra: {} ) } diff --git a/spec/lib/gitlab/ci/config/external/file/template_spec.rb b/spec/lib/gitlab/ci/config/external/file/template_spec.rb index 4da9a933a9f..074e7a1d32d 100644 --- a/spec/lib/gitlab/ci/config/external/file/template_spec.rb +++ b/spec/lib/gitlab/ci/config/external/file/template_spec.rb @@ -124,6 +124,8 @@ RSpec.describe Gitlab::Ci::Config::External::File::Template do context_sha: '12345', type: :template, location: template, + raw: "https://gitlab.com/gitlab-org/gitlab/-/raw/master/lib/gitlab/ci/templates/#{template}", + blob: nil, extra: {} ) } diff --git a/spec/lib/gitlab/ci/config/external/processor_spec.rb b/spec/lib/gitlab/ci/config/external/processor_spec.rb index 56cd006717e..15a0ff40aa4 100644 --- a/spec/lib/gitlab/ci/config/external/processor_spec.rb +++ b/spec/lib/gitlab/ci/config/external/processor_spec.rb @@ -267,11 +267,41 @@ RSpec.describe Gitlab::Ci::Config::External::Processor do perform expect(context.includes).to contain_exactly( - { type: :local, location: '/local/file.yml', extra: {}, context_project: project.full_path, context_sha: '12345' }, - { type: :template, location: 'Ruby.gitlab-ci.yml', extra: {}, context_project: project.full_path, context_sha: '12345' }, - { type: :remote, location: 'http://my.domain.com/config.yml', extra: {}, context_project: project.full_path, context_sha: '12345' }, - { type: :file, location: '/templates/my-workflow.yml', extra: { project: another_project.full_path, ref: 'HEAD' }, context_project: project.full_path, context_sha: '12345' }, - { type: :local, location: '/templates/my-build.yml', extra: {}, context_project: another_project.full_path, context_sha: another_project.commit.sha } + { type: :local, + location: '/local/file.yml', + blob: "http://localhost/#{project.full_path}/-/blob/12345/local/file.yml", + raw: "http://localhost/#{project.full_path}/-/raw/12345/local/file.yml", + extra: {}, + context_project: project.full_path, + context_sha: '12345' }, + { type: :template, + location: 'Ruby.gitlab-ci.yml', + blob: nil, + raw: 'https://gitlab.com/gitlab-org/gitlab/-/raw/master/lib/gitlab/ci/templates/Ruby.gitlab-ci.yml', + extra: {}, + context_project: project.full_path, + context_sha: '12345' }, + { type: :remote, + location: 'http://my.domain.com/config.yml', + blob: nil, + raw: "http://my.domain.com/config.yml", + extra: {}, + context_project: project.full_path, + context_sha: '12345' }, + { type: :file, + location: '/templates/my-workflow.yml', + blob: "http://localhost/#{another_project.full_path}/-/blob/#{another_project.commit.sha}/templates/my-workflow.yml", + raw: "http://localhost/#{another_project.full_path}/-/raw/#{another_project.commit.sha}/templates/my-workflow.yml", + extra: { project: another_project.full_path, ref: 'HEAD' }, + context_project: project.full_path, + context_sha: '12345' }, + { type: :local, + location: '/templates/my-build.yml', + blob: "http://localhost/#{another_project.full_path}/-/blob/#{another_project.commit.sha}/templates/my-build.yml", + raw: "http://localhost/#{another_project.full_path}/-/raw/#{another_project.commit.sha}/templates/my-build.yml", + extra: {}, + context_project: another_project.full_path, + context_sha: another_project.commit.sha } ) end end @@ -394,8 +424,20 @@ RSpec.describe Gitlab::Ci::Config::External::Processor do perform expect(context.includes).to contain_exactly( - { type: :file, location: '/templates/my-build.yml', extra: { project: another_project.full_path, ref: 'HEAD' }, context_project: project.full_path, context_sha: '12345' }, - { type: :file, location: '/templates/my-test.yml', extra: { project: another_project.full_path, ref: 'HEAD' }, context_project: project.full_path, context_sha: '12345' } + { type: :file, + location: '/templates/my-build.yml', + blob: "http://localhost/#{another_project.full_path}/-/blob/#{another_project.commit.sha}/templates/my-build.yml", + raw: "http://localhost/#{another_project.full_path}/-/raw/#{another_project.commit.sha}/templates/my-build.yml", + extra: { project: another_project.full_path, ref: 'HEAD' }, + context_project: project.full_path, + context_sha: '12345' }, + { type: :file, + blob: "http://localhost/#{another_project.full_path}/-/blob/#{another_project.commit.sha}/templates/my-test.yml", + raw: "http://localhost/#{another_project.full_path}/-/raw/#{another_project.commit.sha}/templates/my-test.yml", + location: '/templates/my-test.yml', + extra: { project: another_project.full_path, ref: 'HEAD' }, + context_project: project.full_path, + context_sha: '12345' } ) end end @@ -438,8 +480,20 @@ RSpec.describe Gitlab::Ci::Config::External::Processor do perform expect(context.includes).to contain_exactly( - { type: :local, location: 'myfolder/file1.yml', extra: {}, context_project: project.full_path, context_sha: '12345' }, - { type: :local, location: 'myfolder/file2.yml', extra: {}, context_project: project.full_path, context_sha: '12345' } + { type: :local, + location: 'myfolder/file1.yml', + blob: "http://localhost/#{project.full_path}/-/blob/12345/myfolder/file1.yml", + raw: "http://localhost/#{project.full_path}/-/raw/12345/myfolder/file1.yml", + extra: {}, + context_project: project.full_path, + context_sha: '12345' }, + { type: :local, + blob: "http://localhost/#{project.full_path}/-/blob/12345/myfolder/file2.yml", + raw: "http://localhost/#{project.full_path}/-/raw/12345/myfolder/file2.yml", + location: 'myfolder/file2.yml', + extra: {}, + context_project: project.full_path, + context_sha: '12345' } ) end end |