diff options
author | Sean McGivern <sean@gitlab.com> | 2019-04-05 14:22:45 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-04-05 14:22:45 +0000 |
commit | 6d25cd06acaa2f0f2c1cb422b613997c67eafc35 (patch) | |
tree | 0d6c0c8d4327951131fa179deec434099f407fe4 /spec | |
parent | 66699030ef82c14b4c209045f7cc6cb0d995f989 (diff) | |
parent | e32c82ed1eabc0e409e91d5d210f1ecc6fd4c091 (diff) | |
download | gitlab-ce-6d25cd06acaa2f0f2c1cb422b613997c67eafc35.tar.gz |
Merge branch 'revert-39eb16aa' into 'master'
Revert "Merge branch 'require-all-templates-to-include-default-stages' into 'master'"
See merge request gitlab-org/gitlab-ce!27053
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/ci/templates/templates_spec.rb | 54 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/yaml_processor_spec.rb | 13 |
2 files changed, 37 insertions, 30 deletions
diff --git a/spec/lib/gitlab/ci/templates/templates_spec.rb b/spec/lib/gitlab/ci/templates/templates_spec.rb index b52064b3036..4e3681cd943 100644 --- a/spec/lib/gitlab/ci/templates/templates_spec.rb +++ b/spec/lib/gitlab/ci/templates/templates_spec.rb @@ -3,32 +3,46 @@ require 'spec_helper' describe "CI YML Templates" do - using RSpec::Parameterized::TableSyntax - - subject { Gitlab::Ci::YamlProcessor.new(content) } - - where(:template_name) do - Gitlab::Template::GitlabCiYmlTemplate.all.map(&:full_name) + ABSTRACT_TEMPLATES = %w[Serverless].freeze + # These templates depend on the presence of the `project` + # param to enable processing of `include:` within CI config. + PROJECT_DEPENDENT_TEMPLATES = %w[Auto-DevOps DAST].freeze + + def self.concrete_templates + Gitlab::Template::GitlabCiYmlTemplate.all.reject do |template| + ABSTRACT_TEMPLATES.include?(template.name) + end end - with_them do - let(:content) do - <<~EOS - include: - - template: #{template_name} - - concrete_build_implemented_by_a_user: - stage: test - script: do something - EOS + def self.abstract_templates + Gitlab::Template::GitlabCiYmlTemplate.all.select do |template| + ABSTRACT_TEMPLATES.include?(template.name) end + end + + describe 'concrete templates with CI/CD jobs' do + concrete_templates.each do |template| + it "#{template.name} template should be valid" do + # Trigger processing of included files + project = create(:project, :test_repo) if PROJECT_DEPENDENT_TEMPLATES.include?(template.name) - it 'is valid' do - expect { subject }.not_to raise_error + expect { Gitlab::Ci::YamlProcessor.new(template.content, project: project) } + .not_to raise_error + end end + end - it 'require default stages to be included' do - expect(subject.stages).to include(*Gitlab::Ci::Config::Entry::Stages.default) + describe 'abstract templates without concrete jobs defined' do + abstract_templates.each do |template| + it "#{template.name} template should be valid after being implemented" do + content = template.content + <<~EOS + concrete_build_implemented_by_a_user: + stage: build + script: do something + EOS + + expect { Gitlab::Ci::YamlProcessor.new(content) }.not_to raise_error + end end end end diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index 2bea17ed030..8b39c4e4dd0 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -626,8 +626,8 @@ module Gitlab context "when an array is provided" do let(:include_content) { ["/local.gitlab-ci.yml"] } - it "returns a validation error" do - expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, /does not have project/) + it "does not return any error" do + expect { subject }.not_to raise_error end end @@ -643,18 +643,11 @@ module Gitlab let(:include_content) do [ 'https://gitlab.com/awesome-project/raw/master/.before-script-template.yml', + '/templates/.after-script-template.yml', { template: 'Auto-DevOps.gitlab-ci.yml' } ] end - before do - WebMock.stub_request(:get, 'https://gitlab.com/awesome-project/raw/master/.before-script-template.yml') - .to_return( - status: 200, - headers: { 'Content-Type' => 'application/json' }, - body: 'prepare: { script: ls -al }') - end - it "does not return any error" do expect { subject }.not_to raise_error end |