-
Notifications
You must be signed in to change notification settings - Fork 117
Support for multiple runners #97
base: master
Are you sure you want to change the base?
Changes from 7 commits
b1337b9
46c3305
584b8cc
106aaf4
75a36c6
eba679f
d8755ca
031f098
b7bc8ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,10 @@ module GitlabCi | |
| class Network | ||
| include HTTParty | ||
|
|
||
| def initialize(runner) | ||
| @runner = runner | ||
| end | ||
|
|
||
| # check for available build from coordinator | ||
| # and pick a pending one | ||
| # { | ||
|
|
@@ -95,7 +99,7 @@ def register_runner(token) | |
| private | ||
|
|
||
| def broadcast message | ||
| print "#{Time.now.to_s} | #{message}" | ||
| print "#{Time.now.to_s} | #{@runner} | #{message}" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant use of
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not a ruby expert, so could you please show me how to fix this issue and I will apply it to later ones |
||
| end | ||
|
|
||
| def api_url | ||
|
|
@@ -107,7 +111,7 @@ def token | |
| end | ||
|
|
||
| def config | ||
| @config ||= Config.new | ||
| @config ||= Config.new(@runner) | ||
| end | ||
|
|
||
| def default_options | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,8 +5,9 @@ module GitlabCi | |
| class Runner | ||
| attr_accessor :current_build, :thread | ||
|
|
||
| def initialize | ||
| puts '* Gitlab CI Runner started' | ||
| def initialize(runner) | ||
| @runner = runner | ||
| puts "* Gitlab CI Runner #{@runner} started" | ||
| puts '* Waiting for builds' | ||
| loop do | ||
| if running? | ||
|
|
@@ -34,7 +35,7 @@ def abort_if_timeout | |
|
|
||
| def update_build | ||
| return unless @current_build.completed? | ||
| puts "#{Time.now.to_s} | Completed build #{@current_build.id}, #{@current_build.state}." | ||
| puts "#{Time.now.to_s} | Completed build #{@current_build.id}, #{@current_build.state} on runner #{@runner}." | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant use of |
||
|
|
||
| # Make sure we push latest build info submitted | ||
| # before we clean build | ||
|
|
@@ -70,14 +71,14 @@ def get_build | |
| end | ||
|
|
||
| def network | ||
| @network ||= Network.new | ||
| @network ||= Network.new(@runner) | ||
| end | ||
|
|
||
| def run(build_data) | ||
| @current_build = GitlabCi::Build.new(build_data) | ||
| puts "#{Time.now.to_s} | Starting new build #{@current_build.id}..." | ||
| @current_build = GitlabCi::Build.new(@runner, build_data) | ||
| puts "#{Time.now.to_s} | Starting new build #{@current_build.id} with runner #{@runner}..." | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant use of |
||
| @current_build.run | ||
| puts "#{Time.now.to_s} | Build #{@current_build.id} started." | ||
| puts "#{Time.now.to_s} | Build #{@current_build.id} on runner #{@runner} started." | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant use of |
||
| end | ||
|
|
||
| def collect_trace | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,7 +47,7 @@ def register_runner | |
| def write_token(token) | ||
| puts "Runner token: #{token}" | ||
|
|
||
| Config.new.write('token', token) | ||
| Config.new(0).write('token', token) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
| end | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
|
|
||
| describe 'Build' do | ||
| describe :run do | ||
| let(:build) { GitlabCi::Build.new(build_data) } | ||
| let(:build) { GitlabCi::Build.new(0, build_data) } | ||
|
|
||
| before do | ||
| build.run | ||
|
|
@@ -27,3 +27,4 @@ def build_data | |
| } | ||
| end | ||
| end | ||
|
|
||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [87/80]
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just followed convention in the same file ...
See line below:
opts.on('-CWORKING_DIRECTORY', 'Specify the working directory for gitlab-ci-runner') do |v|
Anyway, I will fix single quotes