diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-06-15 16:37:57 +0300 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-06-15 16:37:57 +0300 |
commit | 0088a8eebc13cd980a4a9a6d242e33ee3d271dd2 (patch) | |
tree | 7ca8fbf08c2bf5c059b24239b8f322141798c4a8 | |
parent | 2555bc84b25a1d66c52e2b24768ae7fb1e6dadbb (diff) | |
download | gitlab-ci-0088a8eebc13cd980a4a9a6d242e33ee3d271dd2.tar.gz |
improve parser
-rw-r--r-- | lib/gitlab_ci_yaml_processor.rb | 8 | ||||
-rw-r--r-- | spec/lib/gitlab_ci_yaml_processor_spec.rb | 18 | ||||
-rw-r--r-- | spec/services/create_commit_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/support/gitlab_stubs/gitlab_ci.yml | 10 |
4 files changed, 20 insertions, 18 deletions
diff --git a/lib/gitlab_ci_yaml_processor.rb b/lib/gitlab_ci_yaml_processor.rb index 274754f..9a69ca6 100644 --- a/lib/gitlab_ci_yaml_processor.rb +++ b/lib/gitlab_ci_yaml_processor.rb @@ -7,9 +7,9 @@ class GitlabCiYamlProcessor @config.delete(:before_script) - @jobs = @config.select{|key, value| value[:test]} + @jobs = @config.select{|key, value| value[:type] != "deploy"} - @deploy_jobs = @config.select{|key, value| value[:deploy]} + @deploy_jobs = @config.select{|key, value| value[:type] == "deploy"} end def deploy_builds_for_ref(ref, tag = false) @@ -27,7 +27,7 @@ class GitlabCiYamlProcessor def builds @jobs.map do |name, job| { - script: "#{@before_script.join("\n")}\n#{normilize_script(job[:test])}", + script: "#{@before_script.join("\n")}\n#{normilize_script(job[:script])}", tags: job[:tags] || [], name: name, only: job[:only], @@ -39,7 +39,7 @@ class GitlabCiYamlProcessor def deploy_builds @deploy_jobs.map do |name, job| { - script: "#{@before_script.join("\n")}\n#{normilize_script(job[:deploy])}", + script: "#{@before_script.join("\n")}\n#{normilize_script(job[:script])}", tags: job[:tags] || [], name: name, only: job[:only], diff --git a/spec/lib/gitlab_ci_yaml_processor_spec.rb b/spec/lib/gitlab_ci_yaml_processor_spec.rb index 96dcf64..8976c12 100644 --- a/spec/lib/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/gitlab_ci_yaml_processor_spec.rb @@ -6,7 +6,7 @@ describe GitlabCiYamlProcessor do it "returns builds if no branch specified" do config = YAML.dump({ before_script: ["pwd"], - rspec: {test: "rspec"} + rspec: {script: "rspec"} }) config_processor = GitlabCiYamlProcessor.new(config) @@ -24,7 +24,7 @@ describe GitlabCiYamlProcessor do it "does not return builds if only has another branch" do config = YAML.dump({ before_script: ["pwd"], - rspec: {test: "rspec", only: ["deploy"]} + rspec: {script: "rspec", only: ["deploy"]} }) config_processor = GitlabCiYamlProcessor.new(config) @@ -35,7 +35,7 @@ describe GitlabCiYamlProcessor do it "does not return builds if only has regexp with another branch" do config = YAML.dump({ before_script: ["pwd"], - rspec: {test: "rspec", only: ["/^deploy$/"]} + rspec: {script: "rspec", only: ["/^deploy$/"]} }) config_processor = GitlabCiYamlProcessor.new(config) @@ -46,7 +46,7 @@ describe GitlabCiYamlProcessor do it "returns builds if only has specified this branch" do config = YAML.dump({ before_script: ["pwd"], - rspec: {test: "rspec", only: ["master"]} + rspec: {script: "rspec", only: ["master"]} }) config_processor = GitlabCiYamlProcessor.new(config) @@ -57,7 +57,7 @@ describe GitlabCiYamlProcessor do it "does not build tags" do config = YAML.dump({ before_script: ["pwd"], - rspec: {test: "rspec", exclude: ["tags"]} + rspec: {script: "rspec", exclude: ["tags"]} }) config_processor = GitlabCiYamlProcessor.new(config) @@ -70,7 +70,7 @@ describe GitlabCiYamlProcessor do it "returns builds if no branch specified" do config = YAML.dump({ before_script: ["pwd"], - rspec: {deploy: "rspec"} + rspec: {script: "rspec", type: "deploy"} }) config_processor = GitlabCiYamlProcessor.new(config) @@ -88,7 +88,7 @@ describe GitlabCiYamlProcessor do it "does not return builds if only has another branch" do config = YAML.dump({ before_script: ["pwd"], - rspec: {deploy: "rspec", only: ["deploy"]} + rspec: {script: "rspec", type: "deploy", only: ["deploy"]} }) config_processor = GitlabCiYamlProcessor.new(config) @@ -99,7 +99,7 @@ describe GitlabCiYamlProcessor do it "does not return builds if only has regexp with another branch" do config = YAML.dump({ before_script: ["pwd"], - rspec: {deploy: "rspec", only: ["/^deploy$/"]} + rspec: {script: "rspec", type: "deploy", only: ["/^deploy$/"]} }) config_processor = GitlabCiYamlProcessor.new(config) @@ -110,7 +110,7 @@ describe GitlabCiYamlProcessor do it "returns builds if only has specified this branch" do config = YAML.dump({ before_script: ["pwd"], - rspec: {deploy: "rspec", only: ["master"]} + rspec: {script: "rspec", type: "deploy", only: ["master"]} }) config_processor = GitlabCiYamlProcessor.new(config) diff --git a/spec/services/create_commit_service_spec.rb b/spec/services/create_commit_service_spec.rb index c04aaa6..f6255f6 100644 --- a/spec/services/create_commit_service_spec.rb +++ b/spec/services/create_commit_service_spec.rb @@ -25,7 +25,7 @@ describe CreateCommitService do context "deploy builds" do it "calls create_deploy_builds if there are no builds" do - config = YAML.dump({production: {deploy: "ls"}}) + config = YAML.dump({production: {script: "ls", type: "deploy"}}) Commit.any_instance.should_receive(:create_deploy_builds) service.execute(project, ref: 'refs/heads/master', diff --git a/spec/support/gitlab_stubs/gitlab_ci.yml b/spec/support/gitlab_stubs/gitlab_ci.yml index bf09f73..5de4e6d 100644 --- a/spec/support/gitlab_stubs/gitlab_ci.yml +++ b/spec/support/gitlab_stubs/gitlab_ci.yml @@ -4,7 +4,7 @@ before_script: - bundle exec rake db:create rspec: - test: "rake spec" + script: "rake spec" tags: - ruby - postgres @@ -12,7 +12,7 @@ rspec: - branches spinach: - test: "rake spinach" + script: "rake spinach" tags: - ruby - mysql @@ -20,7 +20,8 @@ spinach: - tags staging: - deploy: "cap deploy stating" + script: "cap deploy stating" + type: deploy tags: - capistrano - debian @@ -28,7 +29,8 @@ staging: - stable production: - deploy: + type: deploy + script: - cap deploy production - cap notify tags: |