Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Commit

Permalink
Merge branch 'runner_tags_fix' into 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
vsizov committed Jun 22, 2015
2 parents fe7fea3 + 585259f commit b46a152
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
@@ -1,3 +1,6 @@
v7.12.1
- Runner without tag should pick builds without tag only

v7.12.0
- Endless scroll on the dashboard
- Add notification if there are no runners
Expand Down
12 changes: 4 additions & 8 deletions app/services/register_build_service.rb
Expand Up @@ -15,14 +15,10 @@ def execute(current_runner)

builds = builds.order('created_at ASC')

build =
if current_runner.tag_list.present?
builds.find do |build|
(build.tag_list - current_runner.tag_list).empty?
end
else
builds.first
end
build = builds.find do |build|
(build.tag_list - current_runner.tag_list).empty?
end


if build
# In case when 2 runners try to assign the same build, second runner will be declined
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/api/builds_spec.rb
Expand Up @@ -3,7 +3,7 @@
describe API::API do
include ApiHelpers

let(:runner) { FactoryGirl.create(:runner) }
let(:runner) { FactoryGirl.create(:runner, tag_list: ["mysql", "ruby"]) }
let(:project) { FactoryGirl.create(:project) }

describe "Builds API for runners" do
Expand Down
31 changes: 31 additions & 0 deletions spec/services/register_build_service_spec.rb
Expand Up @@ -13,6 +13,37 @@
end

describe :execute do
context 'runner follow tag list' do
it "picks build with the same tag" do
pending_build.tag_list = ["linux"]
pending_build.save
specific_runner.tag_list = ["linux"]
service.execute(specific_runner).should == pending_build
end

it "does not pick build with different tag" do
pending_build.tag_list = ["linux"]
pending_build.save
specific_runner.tag_list = ["win32"]
service.execute(specific_runner).should be_false
end

it "picks build without tag" do
service.execute(specific_runner).should == pending_build
end

it "does not pick build with tag" do
pending_build.tag_list = ["linux"]
pending_build.save
service.execute(specific_runner).should be_false
end

it "pick build without tag" do
specific_runner.tag_list = ["win32"]
service.execute(specific_runner).should == pending_build
end
end

context 'allow shared runners' do
before do
project.shared_runners_enabled = true
Expand Down

0 comments on commit b46a152

Please sign in to comment.