summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-06-12 13:16:54 +0300
committerValery Sizov <vsv2711@gmail.com>2015-06-12 13:59:37 +0300
commitdc28749419635cf20b1a62a839186adf0640697c (patch)
tree702060acfb8a0953728f501bc4f12dce16f8a6d7
parente744d06515eb4195115d451b744009aa4dd24d1f (diff)
downloadgitlab-ci-dc28749419635cf20b1a62a839186adf0640697c.tar.gz
New syntax of gitlab-ci.yml
-rw-r--r--app/models/commit.rb26
-rw-r--r--app/services/create_commit_service.rb10
-rw-r--r--app/views/commits/show.html.haml4
-rw-r--r--app/views/lints/_create.html.haml27
-rw-r--r--lib/gitlab_ci_yaml_processor.rb122
-rw-r--r--spec/controllers/projects_controller_spec.rb3
-rw-r--r--spec/features/lint_spec.rb9
-rw-r--r--spec/lib/gitlab_ci_yaml_processor_spec.rb179
-rw-r--r--spec/models/commit_spec.rb2
-rw-r--r--spec/models/project_services/hip_chat_message_spec.rb2
-rw-r--r--spec/models/project_services/slack_message_spec.rb2
-rw-r--r--spec/services/create_commit_service_spec.rb50
-rw-r--r--spec/support/gitlab_stubs/gitlab_ci.yml57
13 files changed, 206 insertions, 287 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 3bc38b6..f27a385 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -92,11 +92,15 @@ class Commit < ActiveRecord::Base
end
def create_builds
- filter_param = tag? ? :tags : :branches
- config_processor.builds.each do |build_attrs|
- if build_attrs[filter_param]
- builds.create!({ project: project }.merge(build_attrs.extract!(:name, :commands, :tag_list)))
- end
+ return if push_data[:commits].last[:message] =~ /(\[ci skip\])/
+
+ config_processor.builds_for_ref(ref, tag).each do |build_attrs|
+ builds.create!({
+ project: project,
+ name: build_attrs[:name],
+ commands: build_attrs[:script],
+ tag_list: build_attrs[:tags]
+ })
end
end
@@ -115,8 +119,16 @@ class Commit < ActiveRecord::Base
end
def create_deploy_builds
- config_processor.deploy_builds_for_ref(ref).each do |build_attrs|
- builds.create!({ project: project }.merge(build_attrs))
+ return if push_data[:commits].last[:message] =~ /(\[ci skip\])/
+
+ config_processor.deploy_builds_for_ref(ref, tag).each do |build_attrs|
+ builds.create!({
+ project: project,
+ name: build_attrs[:name],
+ commands: build_attrs[:script],
+ tag_list: build_attrs[:tags],
+ deploy: true
+ })
end
end
diff --git a/app/services/create_commit_service.rb b/app/services/create_commit_service.rb
index 81d552a..de5ece3 100644
--- a/app/services/create_commit_service.rb
+++ b/app/services/create_commit_service.rb
@@ -17,15 +17,7 @@ class CreateCommitService
return false
end
- if params[:commits] && params[:commits].last[:message] =~ /(\[ci skip\])/
- return false
- end
-
- if origin_ref.start_with?('refs/tags/') && !config_processor.create_commit_for_tag?(ref)
- return false
- end
-
- if config_processor.skip_ref?(ref)
+ unless config_processor.any_jobs?(ref, origin_ref.start_with?('refs/tags/'))
return false
end
diff --git a/app/views/commits/show.html.haml b/app/views/commits/show.html.haml
index cb8b866..3353f78 100644
--- a/app/views/commits/show.html.haml
+++ b/app/views/commits/show.html.haml
@@ -53,7 +53,7 @@
%th Status
%th Build ID
%th Trigger
- %th Job
+ %th Name
%th Duration
%th Finished at
- if @project.coverage_enabled?
@@ -71,7 +71,7 @@
%th Status
%th Build ID
%th Trigger
- %th Job
+ %th Name
%th Duration
%th Finished at
- if @project.coverage_enabled?
diff --git a/app/views/lints/_create.html.haml b/app/views/lints/_create.html.haml
index 64a7d65..34920d7 100644
--- a/app/views/lints/_create.html.haml
+++ b/app/views/lints/_create.html.haml
@@ -15,33 +15,32 @@
%td Job - #{build[:name]}
%td
%pre
- = simple_format build[:commands]
+ = simple_format build[:script]
%b Tag list:
- #{build[:tag_list]}
+ = build[:tags]
%br
- %b Build for branches:
- #{build[:branches] ? "true": "false"}
+ %b Refs only:
+ = build[:only] && build[:only].join(", ")
%br
- %b Build for tags:
- #{build[:tags] ? "true": "false"}
+ %b Refs except:
+ = build[:except] && build[:except].join(", ")
- @config_processor.deploy_builds.each do |build|
%tr
%td Deploy Job - #{build[:name]}
%td
%pre
- = simple_format build[:commands]
+ = simple_format build[:script]
%b Tag list:
- #{build[:tag_list]}
+ = build[:tags]
%br
- %b Refs:
- #{build[:refs]}
-
- %tr
- %td Skip Refs
- %td= @config_processor.skip_refs
+ %b Refs only:
+ = build[:only] && build[:only].join(", ")
+ %br
+ %b Refs except:
+ = build[:except] && build[:except].join(", ")
-else
%p
diff --git a/lib/gitlab_ci_yaml_processor.rb b/lib/gitlab_ci_yaml_processor.rb
index 32f7938..274754f 100644
--- a/lib/gitlab_ci_yaml_processor.rb
+++ b/lib/gitlab_ci_yaml_processor.rb
@@ -3,104 +3,86 @@ class GitlabCiYamlProcessor
def initialize(config)
@config = YAML.load(config).deep_symbolize_keys
- @skip_refs = @config[:skip_refs] || ""
@before_script = @config[:before_script] || []
- @jobs = @config[:jobs] || []
- @deploy_jobs = @config[:deploy_jobs] || []
+
+ @config.delete(:before_script)
+
+ @jobs = @config.select{|key, value| value[:test]}
+
+ @deploy_jobs = @config.select{|key, value| value[:deploy]}
end
- def builds
- normalized_jobs.map do |job|
- {
- name: job[:name],
- commands: "#{normalized_script(@before_script)}\n#{job[:script]}",
- tag_list: job[:runner],
- branches: job[:branches],
- tags: job[:tag]
- }
- end
+ def deploy_builds_for_ref(ref, tag = false)
+ deploy_builds.select{|build| process?(build[:only], build[:except], ref, tag)}
end
- def deploy_builds
- normalized_deploy_jobs.map do |job|
- {
- name: job[:name],
- commands: "#{normalized_script(@before_script)}\n#{job[:script]}",
- deploy: true,
- refs: job[:refs],
- tag_list: job[:runner]
- }
- end
+ def builds_for_ref(ref, tag = false)
+ builds.select{|build| process?(build[:only], build[:except], ref, tag)}
end
- def create_commit_for_tag?(ref)
- normalized_jobs.any?{|job| job[:tags] == true} ||
- normalized_deploy_jobs.any?{|job| job[:refs].blank? || refs_matches?(job[:refs].split(",").map(&:strip), ref)}
+ def any_jobs?(ref, tag = false)
+ builds_for_ref(ref, tag).any? || deploy_builds_for_ref(ref, tag).any?
end
- def deploy_builds_for_ref(ref)
- deploy_builds.select do |build_attrs|
- refs = build_attrs.delete(:refs)
- refs.blank? || refs_matches?(refs.split(",").map(&:strip), ref)
+ def builds
+ @jobs.map do |name, job|
+ {
+ script: "#{@before_script.join("\n")}\n#{normilize_script(job[:test])}",
+ tags: job[:tags] || [],
+ name: name,
+ only: job[:only],
+ except: job[:except]
+ }
end
end
- def skip_ref?(ref_name)
- @skip_refs.split(",").each do |ref|
- return true if File.fnmatch(ref, ref_name)
+ def deploy_builds
+ @deploy_jobs.map do |name, job|
+ {
+ script: "#{@before_script.join("\n")}\n#{normilize_script(job[:deploy])}",
+ tags: job[:tags] || [],
+ name: name,
+ only: job[:only],
+ except: job[:except]
+ }
end
-
- false
end
private
- # refs - list of refs. Glob syntax is supported. Ex. ["feature*", "bug"]
- # ref - ref that should be checked
- def refs_matches?(refs, ref)
- refs.each do |ref_pattern|
- return true if File.fnmatch(ref_pattern, ref)
- end
+ def process?(only_params, except_params, ref, tag)
+ return true if only_params.nil? && except_params.nil?
- false
- end
+ if only_params
+ return true if tag && only_params.include?("tags")
+ return true if !tag && only_params.include?("branches")
+
+ only_params.each do |pattern|
+ return match_ref?(pattern, ref)
+ end
+ else
+ return false if tag && except_params.include?("tags")
+ return false if !tag && except_params.include?("branches")
- def normalized_jobs
- @jobs.map do |job|
- if job.is_a?(String)
- { script: job, runner: "", name: job[0..10], branches: true, tags: true }
- else
- {
- script: normalized_script(job[:script]),
- runner: job[:runner] || "",
- name: job[:name] || job[:script][0..10],
- branches: job[:branches].nil? ? true : job[:branches],
- tags: job[:tags].nil? ? true : job[:tags]
- }
+ except_params.each do |pattern|
+ return false if match_ref?(pattern, ref)
end
end
end
- def normalized_deploy_jobs
- @deploy_jobs.map do |job|
- if job.is_a?(String)
- { script: job, runner: "", refs: "", name: job[0..10].strip }
- else
- {
- script: normalized_script(job[:script]),
- refs: job[:refs] || "",
- name: job[:name] || job[:script][0..10].strip,
- runner: job[:runner] || "",
- }
- end
+ def match_ref?(pattern, ref)
+ if pattern.first == "/" && pattern.last == "/"
+ Regexp.new(pattern[1...-1]) =~ ref
+ else
+ pattern == ref
end
end
- def normalized_script(script)
+ def normilize_script(script)
if script.is_a? Array
- script.map(&:strip).join("\n")
+ script.join("\n")
else
- script.strip
+ script
end
end
end
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index 455a213..0069a78 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -12,7 +12,8 @@ describe ProjectsController do
before: '2aa371379db71ac89ae20843fcff3b3477cf1a1d',
after: '1c8a9df454ef68c22c2a33cca8232bb50849e5c5',
token: @project.token,
- ci_yaml_file: gitlab_ci_yaml
+ ci_yaml_file: gitlab_ci_yaml,
+ commits: [ { message: "Message" } ]
expect(response).to be_success
diff --git a/spec/features/lint_spec.rb b/spec/features/lint_spec.rb
index 4a1ea26..1160f24 100644
--- a/spec/features/lint_spec.rb
+++ b/spec/features/lint_spec.rb
@@ -11,11 +11,10 @@ describe "Lint" do
fill_in "content", with: content
click_on "Validate"
within "table" do
- page.should have_content("Skip Refs")
- page.should have_content("Job - Rspec")
- page.should have_content("Job - Spinach")
- page.should have_content("Deploy Job - cap deploy")
- page.should have_content("Deploy Job - Deploy to staging")
+ page.should have_content("Job - rspec")
+ page.should have_content("Job - spinach")
+ page.should have_content("Deploy Job - staging")
+ page.should have_content("Deploy Job - production")
end
end
diff --git a/spec/lib/gitlab_ci_yaml_processor_spec.rb b/spec/lib/gitlab_ci_yaml_processor_spec.rb
index 22d0d6b..96dcf64 100644
--- a/spec/lib/gitlab_ci_yaml_processor_spec.rb
+++ b/spec/lib/gitlab_ci_yaml_processor_spec.rb
@@ -2,217 +2,120 @@ require 'spec_helper'
describe GitlabCiYamlProcessor do
- describe "#builds" do
- it "returns builds from string" do
- config = YAML.dump({
- jobs: ["ls"]
- })
-
- config_processor = GitlabCiYamlProcessor.new(config)
-
- config_processor.builds.size.should == 1
- config_processor.builds.first.should == {
- branches: true,
- commands: "\nls",
- name: "ls",
- tag_list: "",
- tags: nil
- }
- end
-
- it "returns builds from string including before_script" do
+ describe "#builds_for_ref" do
+ it "returns builds if no branch specified" do
config = YAML.dump({
before_script: ["pwd"],
- jobs: ["ls"]
+ rspec: {test: "rspec"}
})
config_processor = GitlabCiYamlProcessor.new(config)
- config_processor.builds.first.should == {
- branches: true,
- commands: "pwd\nls",
- name: "ls",
- tag_list: "",
- tags: nil
+ config_processor.builds_for_ref("master").size.should == 1
+ config_processor.builds_for_ref("master").first.should == {
+ except: nil,
+ name: :rspec,
+ only: nil,
+ script: "pwd\nrspec",
+ tags: []
}
end
- it "returns builds from job hash" do
+ it "does not return builds if only has another branch" do
config = YAML.dump({
before_script: ["pwd"],
- jobs: [{script: "ls", name: "Rspec", runner: "mysql,ruby"}]
- })
-
- config_processor = GitlabCiYamlProcessor.new(config)
-
- config_processor.builds.first.should == {
- branches: true,
- commands: "pwd\nls",
- name: "Rspec",
- tag_list: "mysql,ruby",
- tags: nil
- }
- end
- end
-
- describe "#deploy_builds" do
- it "returns deploy builds from string" do
- config = YAML.dump({
- deploy_jobs: ["ls"]
+ rspec: {test: "rspec", only: ["deploy"]}
})
config_processor = GitlabCiYamlProcessor.new(config)
- config_processor.deploy_builds.size.should == 1
- config_processor.deploy_builds.first.should == {
- commands: "\nls",
- name: "ls",
- deploy: true,
- refs: "",
- tag_list: ""
- }
+ config_processor.builds_for_ref("master").size.should == 0
end
- it "returns deploy builds from string including before_script" do
+ it "does not return builds if only has regexp with another branch" do
config = YAML.dump({
before_script: ["pwd"],
- deploy_jobs: ["ls"]
+ rspec: {test: "rspec", only: ["/^deploy$/"]}
})
config_processor = GitlabCiYamlProcessor.new(config)
- config_processor.deploy_builds.first.should == {
- commands: "pwd\nls",
- name: "ls",
- deploy: true,
- refs: "",
- tag_list: ""
- }
+ config_processor.builds_for_ref("master").size.should == 0
end
- it "returns deploy builds from job hash" do
+ it "returns builds if only has specified this branch" do
config = YAML.dump({
before_script: ["pwd"],
- deploy_jobs: [{script: "ls", name: "Rspec", refs: "master,deploy"}]
+ rspec: {test: "rspec", only: ["master"]}
})
config_processor = GitlabCiYamlProcessor.new(config)
- config_processor.deploy_builds.first.should == {
- commands: "pwd\nls",
- name: "Rspec",
- deploy: true,
- refs: "master,deploy",
- tag_list: ""
- }
+ config_processor.builds_for_ref("master").size.should == 1
end
- end
- describe "create_commit_for_tag?" do
- it "returns true because there is a job for tags" do
+ it "does not build tags" do
config = YAML.dump({
before_script: ["pwd"],
- jobs: [{script: "ls", name: "Rspec", runners: "mysql,ruby", tags: true}],
- deploy_jobs: ["ls"]
+ rspec: {test: "rspec", exclude: ["tags"]}
})
config_processor = GitlabCiYamlProcessor.new(config)
- config_processor.create_commit_for_tag?("deploy").should be_true
- end
-
- it "returns true because there is a deploy job for this tag" do
- config = YAML.dump({
- before_script: ["pwd"],
- jobs: [{script: "ls", name: "Rspec", runner: "mysql,ruby", tags: false}],
- deploy_jobs: [{script: "ls", refs: "deploy"}]
- })
-
- config_processor = GitlabCiYamlProcessor.new(config)
-
- config_processor.create_commit_for_tag?("deploy").should be_true
- end
-
- it "returns true because there is a deploy job without tag specified" do
- config = YAML.dump({
- before_script: ["pwd"],
- jobs: [{script: "ls", name: "Rspec", runner: "mysql,ruby", tags: false}],
- deploy_jobs: ["ls"]
- })
-
- config_processor = GitlabCiYamlProcessor.new(config)
-
- config_processor.create_commit_for_tag?("deploy").should be_true
- end
-
- it "returns false because there is no deploy job for this ref nor job for tags" do
- config = YAML.dump({
- before_script: ["pwd"],
- jobs: [{script: "ls", name: "Rspec", runner: "mysql,ruby", tags: false}],
- deploy_jobs: [{script: "ls", refs: "master"}]
- })
-
- config_processor = GitlabCiYamlProcessor.new(config)
-
- config_processor.create_commit_for_tag?("deploy").should be_false
+ config_processor.builds_for_ref("0-1", true).size.should == 1
end
end
describe "#deploy_builds_for_ref" do
- it "returns deploy job for ref" do
+ it "returns builds if no branch specified" do
config = YAML.dump({
before_script: ["pwd"],
- deploy_jobs: [{script: "ls", name: "Deploy!1", refs: "deploy"}, {script: "pwd", refs: "staging"}]
+ rspec: {deploy: "rspec"}
})
config_processor = GitlabCiYamlProcessor.new(config)
- config_processor.deploy_builds_for_ref("deploy").size.should == 1
- config_processor.deploy_builds_for_ref("deploy").first[:name].should == 'Deploy!1'
+ config_processor.deploy_builds_for_ref("master").size.should == 1
+ config_processor.deploy_builds_for_ref("master").first.should == {
+ except: nil,
+ name: :rspec,
+ only: nil,
+ script: "pwd\nrspec",
+ tags: []
+ }
end
- it "returns deploy job for ref including job without ref specified" do
+ it "does not return builds if only has another branch" do
config = YAML.dump({
before_script: ["pwd"],
- deploy_jobs: [{script: "ls", name: "Deploy!1", refs: "deploy"}, "pwd"]
+ rspec: {deploy: "rspec", only: ["deploy"]}
})
config_processor = GitlabCiYamlProcessor.new(config)
- config_processor.deploy_builds_for_ref("deploy").size.should == 2
+ config_processor.deploy_builds_for_ref("master").size.should == 0
end
- it "returns empty array because there is no deploy job for this ref" do
+ it "does not return builds if only has regexp with another branch" do
config = YAML.dump({
before_script: ["pwd"],
- deploy_jobs: [{script: "ls", name: "Deploy!1", refs: "deploy"}]
+ rspec: {deploy: "rspec", only: ["/^deploy$/"]}
})
config_processor = GitlabCiYamlProcessor.new(config)
config_processor.deploy_builds_for_ref("master").size.should == 0
end
- end
- describe "skip_ref?" do
- it "skips ref" do
+ it "returns builds if only has specified this branch" do
config = YAML.dump({
- skip_refs: "master"
+ before_script: ["pwd"],
+ rspec: {deploy: "rspec", only: ["master"]}
})
config_processor = GitlabCiYamlProcessor.new(config)
- config_processor.skip_ref?("master").should be_true
- config_processor.skip_ref?("deploy").should be_false
- end
-
- it "does not skip ref if no refs specified" do
- config = YAML.dump({})
-
- config_processor = GitlabCiYamlProcessor.new(config)
-
- config_processor.skip_ref?("master").should be_false
+ config_processor.deploy_builds_for_ref("master").size.should == 1
end
end
-
end \ No newline at end of file
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index 1658ae6..8c0073e 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -138,7 +138,7 @@ describe Commit do
commit.create_deploy_builds
commit.builds.reload
- commit.builds.size.should == 1
+ commit.builds.size.should == 2
end
end
diff --git a/spec/models/project_services/hip_chat_message_spec.rb b/spec/models/project_services/hip_chat_message_spec.rb
index d4bfb31..5fa5549 100644
--- a/spec/models/project_services/hip_chat_message_spec.rb
+++ b/spec/models/project_services/hip_chat_message_spec.rb
@@ -8,7 +8,7 @@ describe HipChatMessage do
context "One build" do
let(:commit) do
commit = FactoryGirl.create(:commit, project: project)
- commit.push_data[:ci_yaml_file] = YAML.dump({jobs: ["ls"]})
+ commit.push_data[:ci_yaml_file] = YAML.dump({rspec: { test: 'pwd' }})
commit.save
commit
end
diff --git a/spec/models/project_services/slack_message_spec.rb b/spec/models/project_services/slack_message_spec.rb
index 03c0cd3..857935d 100644
--- a/spec/models/project_services/slack_message_spec.rb
+++ b/spec/models/project_services/slack_message_spec.rb
@@ -8,7 +8,7 @@ describe SlackMessage do
context "One build" do
let(:commit) do
commit = FactoryGirl.create(:commit, project: project)
- commit.push_data[:ci_yaml_file] = YAML.dump({jobs: ["ls"]})
+ commit.push_data[:ci_yaml_file] = YAML.dump({rspec: { test: "ls" }})
commit.save
commit
end
diff --git a/spec/services/create_commit_service_spec.rb b/spec/services/create_commit_service_spec.rb
index ae118e4..c04aaa6 100644
--- a/spec/services/create_commit_service_spec.rb
+++ b/spec/services/create_commit_service_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe CreateCommitService do
let(:service) { CreateCommitService.new }
let(:project) { FactoryGirl.create(:project) }
-
+
describe :execute do
context 'valid params' do
let(:commit) do
@@ -11,8 +11,9 @@ describe CreateCommitService do
ref: 'refs/heads/master',
before: '00000000',
after: '31das312',
- ci_yaml_file: gitlab_ci_yaml
- )
+ ci_yaml_file: gitlab_ci_yaml,
+ commits: [ { message: "Message" } ]
+ )
end
it { commit.should be_kind_of(Commit) }
@@ -24,15 +25,27 @@ describe CreateCommitService do
context "deploy builds" do
it "calls create_deploy_builds if there are no builds" do
- config = YAML.dump({jobs: [], build_jobs: ["ls"]})
+ config = YAML.dump({production: {deploy: "ls"}})
Commit.any_instance.should_receive(:create_deploy_builds)
- service.execute(project, ref: 'refs/heads/master', before: '00000000', after: '31das312', ci_yaml_file: config)
+ service.execute(project,
+ ref: 'refs/heads/master',
+ before: '00000000',
+ after: '31das312',
+ ci_yaml_file: config,
+ commits: [ { message: "Message" } ]
+ )
end
it "does not call create_deploy_builds if there is build" do
- config = YAML.dump({jobs: ["ls"], build_jobs: ["ls"]})
+ config = YAML.dump({rspec: {test: "ls"},production: {deploy: "ls"}})
Commit.any_instance.should_not_receive(:create_deploy_builds)
- service.execute(project, ref: 'refs/heads/master', before: '00000000', after: '31das312', ci_yaml_file: config)
+ service.execute(project,
+ ref: 'refs/heads/master',
+ before: '00000000',
+ after: '31das312',
+ ci_yaml_file: config,
+ commits: [ { message: "Message" } ]
+ )
end
end
@@ -42,7 +55,8 @@ describe CreateCommitService do
ref: 'refs/tags/0_1',
before: '00000000',
after: '31das312',
- ci_yaml_file: gitlab_ci_yaml
+ ci_yaml_file: gitlab_ci_yaml,
+ commits: [ { message: "Message" } ]
)
result.should be_persisted
end
@@ -52,41 +66,43 @@ describe CreateCommitService do
ref: 'refs/tags/0_1',
before: '00000000',
after: '31das312',
- ci_yaml_file: YAML.dump({})
+ ci_yaml_file: YAML.dump({}),
+ commits: [ { message: "Message" } ]
)
result.should be_false
end
it "creates commit if there is no appropriate job but deploy job has right ref setting" do
- config = YAML.dump({deploy_jobs: [{script: "ls", refs: "0_1"}]})
+ config = YAML.dump({deploy: {deploy: "ls", only: ["0_1"]}})
result = service.execute(project,
ref: 'refs/heads/0_1',
before: '00000000',
after: '31das312',
- ci_yaml_file: config
+ ci_yaml_file: config,
+ commits: [ { message: "Message" } ]
)
result.should be_persisted
end
end
describe :ci_skip? do
- it "skips commit creation if there is [ci skip] tag in commit message" do
+ it "skips builds creation if there is [ci skip] tag in commit message" do
commits = [{message: "some message[ci skip]"}]
- result = service.execute(project,
+ commit = service.execute(project,
ref: 'refs/tags/0_1',
before: '00000000',
after: '31das312',
commits: commits,
ci_yaml_file: gitlab_ci_yaml
)
- result.should be_false
+ commit.builds.any?.should be_false
end
- it "does not skips commit creation if there is no [ci skip] tag in commit message" do
+ it "does not skips builds creation if there is no [ci skip] tag in commit message" do
commits = [{message: "some message"}]
- result = service.execute(project,
+ commit = service.execute(project,
ref: 'refs/tags/0_1',
before: '00000000',
after: '31das312',
@@ -94,7 +110,7 @@ describe CreateCommitService do
ci_yaml_file: gitlab_ci_yaml
)
- result.should be_persisted
+ commit.builds.first.name.should == "staging"
end
end
diff --git a/spec/support/gitlab_stubs/gitlab_ci.yml b/spec/support/gitlab_stubs/gitlab_ci.yml
index 4f76e36..bf09f73 100644
--- a/spec/support/gitlab_stubs/gitlab_ci.yml
+++ b/spec/support/gitlab_stubs/gitlab_ci.yml
@@ -1,24 +1,39 @@
-# Refs to skip
-skip_refs: “deploy-*”
-
-# Run before each script
before_script:
- - ls
+ - gem install bundler
+ - bundle install
+ - bundle exec rake db:create
+
+rspec:
+ test: "rake spec"
+ tags:
+ - ruby
+ - postgres
+ only:
+ - branches
+
+spinach:
+ test: "rake spinach"
+ tags:
+ - ruby
+ - mysql
+ except:
+ - tags
-# Parallel jobs, each line is parallel build
-jobs:
- - script: "rake spec"
- runner: "ruby,postgres"
- name: "Rspec"
- - script: "rake spinach"
- runner: "ruby,mysql"
- name: "Spinach"
- tags: true
- branches: true
+staging:
+ deploy: "cap deploy stating"
+ tags:
+ - capistrano
+ - debian
+ except:
+ - stable
-# Parallel deploy jobs
-deploy_jobs:
- - "cap deploy production"
- - script: "cap deploy staging"
- refs: staging
- name: "Deploy to staging"
+production:
+ deploy:
+ - cap deploy production
+ - cap notify
+ tags:
+ - capistrano
+ - debian
+ only:
+ - master
+ - /^deploy-.*$/ \ No newline at end of file