From 6b124d42d9861a5f8c3dd5add7cabc864fa3673c Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 15 Apr 2016 15:51:41 +0200 Subject: [PATCH 1/4] Add configurable shared runners text --- CHANGELOG | 2 ++ .../admin/application_settings_controller.rb | 1 + app/helpers/application_settings_helper.rb | 4 ++++ .../admin/application_settings/_form.html.haml | 6 +++++- .../projects/runners/_shared_runners.html.haml | 7 +++++-- ...hared_runners_text_to_application_settings.rb | 5 +++++ db/schema.rb | 3 ++- spec/features/runners_spec.rb | 16 ++++++++++++++++ 8 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20160415133440_add_shared_runners_text_to_application_settings.rb diff --git a/CHANGELOG b/CHANGELOG index 571c31e63a2..d1b20a34b17 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,8 @@ v 8.7.0 (unreleased) - Allow projects to be transfered to a lower visibility level group - Fix `signed_in_ip` being set to 127.0.0.1 when using a reverse proxy !3524 - Improved Markdown rendering performance !3389 + - Improved Markdown rendering performance !3389 (Yorick Peterse) + - Make shared runners text in box configurable (Kamil Trzciński) - Don't attempt to look up an avatar in repo if repo directory does not exist (Stan Hu) - API: Ability to subscribe and unsubscribe from issues and merge requests (Robert Schilling) - Expose project badges in project settings diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index b4a28b8dd3f..2520d4452a2 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -75,6 +75,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController :admin_notification_email, :user_oauth_applications, :shared_runners_enabled, + :shared_runners_text, :max_artifacts_size, :metrics_enabled, :metrics_host, diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index 60a0ff32c9c..914b0ef6042 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -15,6 +15,10 @@ module ApplicationSettingsHelper current_application_settings.sign_in_text end + def shared_runners_text + current_application_settings.shared_runners_text + end + def user_oauth_applications? current_application_settings.user_oauth_applications end diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml index 555aea554f0..e5bc7d4fdbe 100644 --- a/app/views/admin/application_settings/_form.html.haml +++ b/app/views/admin/application_settings/_form.html.haml @@ -153,7 +153,11 @@ = f.label :shared_runners_enabled do = f.check_box :shared_runners_enabled Enable shared runners for new projects - + .form-group + = f.label :shared_runners_text, class: 'control-label col-sm-2' + .col-sm-10 + = f.text_area :shared_runners_text, class: 'form-control', rows: 4 + .help-block Markdown enabled .form-group = f.label :max_artifacts_size, 'Maximum artifacts size (MB)', class: 'control-label col-sm-2' .col-sm-10 diff --git a/app/views/projects/runners/_shared_runners.html.haml b/app/views/projects/runners/_shared_runners.html.haml index 6a37f444bb7..ec47ed79e55 100644 --- a/app/views/projects/runners/_shared_runners.html.haml +++ b/app/views/projects/runners/_shared_runners.html.haml @@ -1,7 +1,10 @@ %h3 Shared runners -.bs-callout.bs-callout-warning - GitLab Runners do not offer secure isolation between projects that they do builds for. You are TRUSTING all GitLab users who can push code to project A, B or C to run shell scripts on the machine hosting runner X. +.bs-callout.bs-callout-warning.shared-runners-description + - if shared_runners_text.present? + = markdown(shared_runners_text) + - else + GitLab Runners do not offer secure isolation between projects that they do builds for. You are TRUSTING all GitLab users who can push code to project A, B or C to run shell scripts on the machine hosting runner X. %hr - if @project.shared_runners_enabled? = link_to toggle_shared_runners_namespace_project_runners_path(@project.namespace, @project), class: 'btn btn-warning', method: :post do diff --git a/db/migrate/20160415133440_add_shared_runners_text_to_application_settings.rb b/db/migrate/20160415133440_add_shared_runners_text_to_application_settings.rb new file mode 100644 index 00000000000..d493044c67b --- /dev/null +++ b/db/migrate/20160415133440_add_shared_runners_text_to_application_settings.rb @@ -0,0 +1,5 @@ +class AddSharedRunnersTextToApplicationSettings < ActiveRecord::Migration + def change + add_column :application_settings, :shared_runners_text, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 42c261003bb..0ab32cab8b4 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: 20160412140240) do +ActiveRecord::Schema.define(version: 20160415133440) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -78,6 +78,7 @@ ActiveRecord::Schema.define(version: 20160412140240) do t.boolean "email_author_in_body", default: false t.integer "default_group_visibility" t.boolean "repository_checks_enabled", default: true + t.text "shared_runners_text" end create_table "audit_events", force: :cascade do |t| diff --git a/spec/features/runners_spec.rb b/spec/features/runners_spec.rb index e8886e7edf9..1fe7645250c 100644 --- a/spec/features/runners_spec.rb +++ b/spec/features/runners_spec.rb @@ -80,6 +80,22 @@ describe "Runners" do end end + describe "shared runners description" do + let(:shared_runners_text) { 'custom shared runners description' } + + before { stub_application_setting(shared_runners_text: shared_runners_text) } + + before do + @project = FactoryGirl.create :empty_project, shared_runners_enabled: false + @project.team << [user, :master] + visit runners_path(@project) + end + + it "sees shared runners description" do + expect(page.find(".shared-runners-description")).to have_content(shared_runners_text) + end + end + describe "show page" do before do @project = FactoryGirl.create :empty_project From 21041525af5a678053cc47e082dc7484a67dfdf5 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 18 Apr 2016 09:56:38 -0400 Subject: [PATCH 2/4] Update according to review comments --- CHANGELOG | 2 +- spec/features/runners_spec.rb | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d1b20a34b17..d691113e198 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,7 +19,7 @@ v 8.7.0 (unreleased) - Fix `signed_in_ip` being set to 127.0.0.1 when using a reverse proxy !3524 - Improved Markdown rendering performance !3389 - Improved Markdown rendering performance !3389 (Yorick Peterse) - - Make shared runners text in box configurable (Kamil Trzciński) + - Make shared runners text in box configurable - Don't attempt to look up an avatar in repo if repo directory does not exist (Stan Hu) - API: Ability to subscribe and unsubscribe from issues and merge requests (Robert Schilling) - Expose project badges in project settings diff --git a/spec/features/runners_spec.rb b/spec/features/runners_spec.rb index 1fe7645250c..789b06d7c67 100644 --- a/spec/features/runners_spec.rb +++ b/spec/features/runners_spec.rb @@ -83,12 +83,11 @@ describe "Runners" do describe "shared runners description" do let(:shared_runners_text) { 'custom shared runners description' } - before { stub_application_setting(shared_runners_text: shared_runners_text) } - before do - @project = FactoryGirl.create :empty_project, shared_runners_enabled: false - @project.team << [user, :master] - visit runners_path(@project) + stub_application_setting(shared_runners_text: shared_runners_text) + project = FactoryGirl.create :empty_project, shared_runners_enabled: false + project.team << [user, :master] + visit runners_path(project) end it "sees shared runners description" do From 1a8fd9d7a5dfd43cc7e3f6b159f8852f722ba4e4 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 18 Apr 2016 15:15:57 -0400 Subject: [PATCH 3/4] Fix CHANGELOG --- CHANGELOG | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index d691113e198..0b3d1003b5f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,7 +18,6 @@ v 8.7.0 (unreleased) - Allow projects to be transfered to a lower visibility level group - Fix `signed_in_ip` being set to 127.0.0.1 when using a reverse proxy !3524 - Improved Markdown rendering performance !3389 - - Improved Markdown rendering performance !3389 (Yorick Peterse) - Make shared runners text in box configurable - Don't attempt to look up an avatar in repo if repo directory does not exist (Stan Hu) - API: Ability to subscribe and unsubscribe from issues and merge requests (Robert Schilling) From d58d88fbd5dca6efdb95d5e07ad0b1c6f43bb565 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 19 Apr 2016 07:39:53 -0400 Subject: [PATCH 4/4] Use different markdown --- app/views/projects/runners/_shared_runners.html.haml | 2 +- spec/features/runners_spec.rb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/projects/runners/_shared_runners.html.haml b/app/views/projects/runners/_shared_runners.html.haml index ec47ed79e55..b31fcfea763 100644 --- a/app/views/projects/runners/_shared_runners.html.haml +++ b/app/views/projects/runners/_shared_runners.html.haml @@ -2,7 +2,7 @@ .bs-callout.bs-callout-warning.shared-runners-description - if shared_runners_text.present? - = markdown(shared_runners_text) + = markdown(shared_runners_text, pipeline: 'plain_markdown') - else GitLab Runners do not offer secure isolation between projects that they do builds for. You are TRUSTING all GitLab users who can push code to project A, B or C to run shell scripts on the machine hosting runner X. %hr diff --git a/spec/features/runners_spec.rb b/spec/features/runners_spec.rb index 789b06d7c67..8edeb8d18af 100644 --- a/spec/features/runners_spec.rb +++ b/spec/features/runners_spec.rb @@ -81,7 +81,8 @@ describe "Runners" do end describe "shared runners description" do - let(:shared_runners_text) { 'custom shared runners description' } + let(:shared_runners_text) { 'custom **shared** runners description' } + let(:shared_runners_html) { 'custom shared runners description' } before do stub_application_setting(shared_runners_text: shared_runners_text) @@ -91,7 +92,7 @@ describe "Runners" do end it "sees shared runners description" do - expect(page.find(".shared-runners-description")).to have_content(shared_runners_text) + expect(page.find(".shared-runners-description")).to have_content(shared_runners_html) end end