diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-06-24 14:41:36 +0300 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-06-24 14:43:13 +0300 |
commit | 306acf65c32963b38d7db74677d3eaedcf441771 (patch) | |
tree | dc84eb9baa9f608bf18672861610105ddd9c60af | |
parent | 592f66868ad1e661cef394bb9f9bae2432f1cad4 (diff) | |
download | gitlab-ci-306acf65c32963b38d7db74677d3eaedcf441771.tar.gz |
improved lint stability
-rw-r--r-- | CHANGELOG | 2 | ||||
-rw-r--r-- | app/controllers/lints_controller.rb | 2 | ||||
-rw-r--r-- | app/views/lints/_create.html.haml | 4 | ||||
-rw-r--r-- | lib/gitlab_ci_yaml_processor.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab_ci_yaml_processor_spec.rb | 9 |
5 files changed, 18 insertions, 3 deletions
@@ -2,6 +2,8 @@ v7.13.0 - Fix: No runner notification can see managers only - Fix: lint with relative subpath - Update web hook example + - Improved Lint stability + - Add one more validation rule for .gitlab-ci.yml v7.12.1 - Runner without tag should pick builds without tag only diff --git a/app/controllers/lints_controller.rb b/app/controllers/lints_controller.rb index 33ee206..9d5f445 100644 --- a/app/controllers/lints_controller.rb +++ b/app/controllers/lints_controller.rb @@ -10,6 +10,8 @@ class LintsController < ApplicationController @error = "Please provide content of .gitlab-ci.yml" else @config_processor = GitlabCiYamlProcessor.new params[:content] + @builds = @config_processor.builds + @deploy_builds = @config_processor.deploy_builds @status = true end rescue GitlabCiYamlProcessor::ValidationError => e diff --git a/app/views/lints/_create.html.haml b/app/views/lints/_create.html.haml index 454ca4b..70b6f8c 100644 --- a/app/views/lints/_create.html.haml +++ b/app/views/lints/_create.html.haml @@ -10,7 +10,7 @@ %th Parameter %th Value %tbody - - @config_processor.builds.each do |build| + - @builds.each do |build| %tr %td Job - #{build[:name]} %td @@ -26,7 +26,7 @@ %b Refs except: = build[:except] && build[:except].join(", ") - - @config_processor.deploy_builds.each do |build| + - @deploy_builds.each do |build| %tr %td Deploy Job - #{build[:name]} %td diff --git a/lib/gitlab_ci_yaml_processor.rb b/lib/gitlab_ci_yaml_processor.rb index 6bb1c4b..a6806d3 100644 --- a/lib/gitlab_ci_yaml_processor.rb +++ b/lib/gitlab_ci_yaml_processor.rb @@ -95,6 +95,10 @@ class GitlabCiYamlProcessor end def validate! + unless @before_script.is_a?(Array) + raise ValidationError, "before_script should be an array" + end + @jobs.each do |name, job| if job[:tags] && !job[:tags].is_a?(Array) raise ValidationError, "#{name} job: tags parameter should be an array" diff --git a/spec/lib/gitlab_ci_yaml_processor_spec.rb b/spec/lib/gitlab_ci_yaml_processor_spec.rb index 0bbe5c1..070e0c0 100644 --- a/spec/lib/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/gitlab_ci_yaml_processor_spec.rb @@ -124,11 +124,18 @@ describe GitlabCiYamlProcessor do expect{GitlabCiYamlProcessor.new("invalid_yaml\n!ccdvlf%612334@@@@")}.to raise_error(GitlabCiYamlProcessor::ValidationError) end - it "returns errors" do + it "returns errors if tags parameter is invalid" do config = YAML.dump({rspec: {tags: "mysql"}}) expect do GitlabCiYamlProcessor.new(config) end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: tags parameter should be an array") end + + it "returns errors if before_script parameter is invalid" do + config = YAML.dump({before_script: "bundle update"}) + expect do + GitlabCiYamlProcessor.new(config) + end.to raise_error(GitlabCiYamlProcessor::ValidationError, "before_script should be an array") + end end end
\ No newline at end of file |