summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-05-12 17:41:12 +0300
committerValery Sizov <vsv2711@gmail.com>2015-05-12 19:47:41 +0300
commite93b0a4ccb0b13d88ff833525fea3683f8a4de30 (patch)
tree5865bb56132c5e1cb55aa43044aecf122a5fc441
parent5b3450f9b4241feee5fa69f78366392015ab25f1 (diff)
downloadgitlab-ci-save_info_from_runner.tar.gz
storing runner infosave_info_from_runner
-rw-r--r--CHANGELOG1
-rw-r--r--app/controllers/runners_controller.rb5
-rw-r--r--app/views/layouts/_nav_project.html.haml2
-rw-r--r--app/views/runners/_runner.html.haml2
-rw-r--r--app/views/runners/show.html.haml64
-rw-r--r--config/routes.rb2
-rw-r--r--db/migrate/20150508011360_add_info_fields_to_runner.rb9
-rw-r--r--db/schema.rb7
-rw-r--r--lib/api/builds.rb1
-rw-r--r--lib/api/helpers.rb11
-rw-r--r--spec/factories/runners.rb2
-rw-r--r--spec/features/runners_spec.rb17
-rw-r--r--spec/requests/api/builds_spec.rb3
13 files changed, 118 insertions, 8 deletions
diff --git a/CHANGELOG b/CHANGELOG
index cc933f2..b3cbe69 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,7 @@ v7.11.0
- Remove projects IDs from dashboard
- UI fix: Remove page headers from the admin area
- Improve Email templates
+ - Coordinator stores information(version, platform, revision, etc.) about runners.
v7.10.1
- Fix failing migration when update to 7.10 from 7.8 and older versions
diff --git a/app/controllers/runners_controller.rb b/app/controllers/runners_controller.rb
index 12578b3..2efa637 100644
--- a/app/controllers/runners_controller.rb
+++ b/app/controllers/runners_controller.rb
@@ -1,7 +1,7 @@
class RunnersController < ApplicationController
before_filter :authenticate_user!
before_filter :project
- before_filter :set_runner, only: [:edit, :update, :destroy, :pause, :resume]
+ before_filter :set_runner, only: [:edit, :update, :destroy, :pause, :resume, :show]
before_filter :authorize_access_project!
before_filter :authorize_manage_project!
@@ -50,6 +50,9 @@ class RunnersController < ApplicationController
end
end
+ def show
+ end
+
protected
def project
diff --git a/app/views/layouts/_nav_project.html.haml b/app/views/layouts/_nav_project.html.haml
index 4f3e3b3..7a8286e 100644
--- a/app/views/layouts/_nav_project.html.haml
+++ b/app/views/layouts/_nav_project.html.haml
@@ -8,7 +8,7 @@
= link_to project_charts_path(@project) do
%i.icon-bar-chart
Charts
- = nav_link path: 'runners#index' do
+ = nav_link path: ['runners#index', 'runners#show'] do
= link_to project_runners_path(@project) do
%i.icon-cog
Runners
diff --git a/app/views/runners/_runner.html.haml b/app/views/runners/_runner.html.haml
index 4cb2879..fc78ffc 100644
--- a/app/views/runners/_runner.html.haml
+++ b/app/views/runners/_runner.html.haml
@@ -2,7 +2,7 @@
%h4
= runner_status_icon(runner)
%span.monospace
- = runner.short_sha
+ = link_to runner.short_sha, [@project, runner]
- if @runners.include?(runner)
%small
=link_to edit_project_runner_path(@project, runner) do
diff --git a/app/views/runners/show.html.haml b/app/views/runners/show.html.haml
new file mode 100644
index 0000000..427e7ed
--- /dev/null
+++ b/app/views/runners/show.html.haml
@@ -0,0 +1,64 @@
+= content_for :title do
+ %h3.project-title
+ Runner ##{@runner.id}
+ .pull-right
+ - if @runner.shared?
+ %span.runner-state.runner-state-shared
+ Shared
+ - else
+ %span.runner-state.runner-state-specific
+ Specific
+
+%table.table
+ %thead
+ %tr
+ %th Property Name
+ %th Value
+ %tr
+ %td
+ Tags
+ %td
+ - @runner.tag_list.each do |tag|
+ %span.label.label-primary
+ = tag
+ %tr
+ %td
+ Name
+ %td
+ = @runner.name
+ %tr
+ %td
+ Varsion
+ %td
+ = @runner.version
+ %tr
+ %td
+ Revision
+ %td
+ = @runner.revision
+ %tr
+ %td
+ Platform
+ %td
+ = @runner.platform
+ %tr
+ %td
+ Architecture
+ %td
+ = @runner.architecture
+ %tr
+ %td
+ Description
+ %td
+ = @runner.description
+ %tr
+ %td
+ Last contact
+ %td
+ - if @runner.contacted_at
+ #{time_ago_in_words(@runner.contacted_at)} ago
+ - else
+ Never
+
+
+
diff --git a/config/routes.rb b/config/routes.rb
index 01c665a..b92b523 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -52,7 +52,7 @@ Rails.application.routes.draw do
end
end
- resources :runners, only: [:index, :edit, :update, :destroy] do
+ resources :runners, only: [:index, :edit, :update, :destroy, :show] do
member do
get :resume
get :pause
diff --git a/db/migrate/20150508011360_add_info_fields_to_runner.rb b/db/migrate/20150508011360_add_info_fields_to_runner.rb
new file mode 100644
index 0000000..607d5cc
--- /dev/null
+++ b/db/migrate/20150508011360_add_info_fields_to_runner.rb
@@ -0,0 +1,9 @@
+class AddInfoFieldsToRunner < ActiveRecord::Migration
+ def change
+ add_column :runners, :name, :string
+ add_column :runners, :version, :string
+ add_column :runners, :revision, :string
+ add_column :runners, :platform, :string
+ add_column :runners, :architecture, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 596e11f..04ad428 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20150504010250) do
+ActiveRecord::Schema.define(version: 20150508011360) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -120,6 +120,11 @@ ActiveRecord::Schema.define(version: 20150504010250) do
t.datetime "contacted_at"
t.boolean "active", default: true, null: false
t.boolean "is_shared", default: false
+ t.string "name"
+ t.string "version"
+ t.string "revision"
+ t.string "platform"
+ t.string "architecture"
end
create_table "services", force: true do |t|
diff --git a/lib/api/builds.rb b/lib/api/builds.rb
index 0f9c2a9..67b73db 100644
--- a/lib/api/builds.rb
+++ b/lib/api/builds.rb
@@ -18,6 +18,7 @@ module API
build = RegisterBuildService.new.execute(current_runner)
if build
+ update_runner_info
present build, with: Entities::Build
else
not_found!
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index d09af26..215792a 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -39,6 +39,12 @@ module API
end
end
+ def update_runner_info
+ return unless params["info"].present?
+ info = attributes_for_keys(["name", "version", "revision", "platform", "architecture"], params["info"])
+ current_runner.update(info)
+ end
+
# Checks the occurrences of required attributes, each attribute must be present in the params hash
# or a Bad Request error is invoked.
#
@@ -50,10 +56,11 @@ module API
end
end
- def attributes_for_keys(keys)
+ def attributes_for_keys(keys, custom_params = nil)
+ params_hash = custom_params || params
attrs = {}
keys.each do |key|
- attrs[key] = params[key] if params[key].present?
+ attrs[key] = params_hash[key] if params_hash[key].present?
end
attrs
end
diff --git a/spec/factories/runners.rb b/spec/factories/runners.rb
index 32af2ce..72d3e3d 100644
--- a/spec/factories/runners.rb
+++ b/spec/factories/runners.rb
@@ -20,6 +20,8 @@ FactoryGirl.define do
"My runner#{n}"
end
+ platform "darwin"
+
factory :shared_runner do
is_shared true
end
diff --git a/spec/features/runners_spec.rb b/spec/features/runners_spec.rb
index 36b7fab..c312f83 100644
--- a/spec/features/runners_spec.rb
+++ b/spec/features/runners_spec.rb
@@ -72,4 +72,21 @@ describe "Runners" do
@project.reload.shared_runners_enabled.should be_true
end
end
+
+ describe "show page" do
+ before do
+ @project = FactoryGirl.create :project
+ stub_js_gitlab_calls
+ @specific_runner = FactoryGirl.create :specific_runner
+ @project.runners << @specific_runner
+ end
+
+ it "shows runner information" do
+ visit project_runners_path(@project)
+
+ click_on @specific_runner.short_sha
+
+ page.should have_content(@specific_runner.platform)
+ end
+ end
end
diff --git a/spec/requests/api/builds_spec.rb b/spec/requests/api/builds_spec.rb
index f69aac8..2960388 100644
--- a/spec/requests/api/builds_spec.rb
+++ b/spec/requests/api/builds_spec.rb
@@ -20,10 +20,11 @@ describe API::API do
job = FactoryGirl.create :job, project: project
build = commit.create_builds.first
- post api("/builds/register"), token: runner.token
+ post api("/builds/register"), token: runner.token, info: {platform: :darwin}
response.status.should == 201
json_response['sha'].should == build.sha
+ runner.reload.platform.should == "darwin"
end
it "should return 404 error if no pending build found" do