Move tags and allow_failure CI entries to new config

This commit is contained in:
Grzegorz Bizon 2016-07-18 16:33:20 +02:00
parent 6d466733a2
commit 943ae747ea
3 changed files with 10 additions and 10 deletions

View file

@ -99,14 +99,6 @@ module Ci
end
def validate_job_types!(name, job)
if job[:tags] && !validate_array_of_strings(job[:tags])
raise ValidationError, "#{name} job: tags parameter should be an array of strings"
end
if job[:allow_failure] && !validate_boolean(job[:allow_failure])
raise ValidationError, "#{name} job: allow_failure parameter should be an boolean"
end
if job[:when] && !job[:when].in?(%w[on_success on_failure always])
raise ValidationError, "#{name} job: when parameter should be on_success, on_failure or always"
end

View file

@ -7,6 +7,9 @@ module Gitlab
#
class Job < Entry
include Configurable
include Attributable
attributes :tags, :allow_failure
validations do
validates :config, allowed_keys:
@ -17,6 +20,11 @@ module Gitlab
validates :config, presence: true
validates :name, presence: true
validates :name, type: Symbol
with_options allow_nil: true do
validates :tags, array_of_strings: true
validates :allow_failure, boolean: true
end
end
node :before_script, Script,

View file

@ -956,7 +956,7 @@ EOT
config = YAML.dump({ rspec: { script: "test", tags: "mysql" } })
expect do
GitlabCiYamlProcessor.new(config, path)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: tags parameter should be an array of strings")
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec tags should be an array of strings")
end
it "returns errors if before_script parameter is invalid" do
@ -1075,7 +1075,7 @@ EOT
config = YAML.dump({ rspec: { script: "test", allow_failure: "string" } })
expect do
GitlabCiYamlProcessor.new(config, path)
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: allow_failure parameter should be an boolean")
end.to raise_error(GitlabCiYamlProcessor::ValidationError, "jobs:rspec allow failure should be a boolean value")
end
it "returns errors if job stage is not a string" do