diff options
author | Rémy Coutable <remy@rymai.me> | 2016-07-20 13:59:43 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-07-20 13:59:43 +0000 |
commit | 6623d36b65a87f8db9d35a83f832ee2e0564f8b1 (patch) | |
tree | 65b290a14f3530df312114292ff8f48a964a0aba | |
parent | f3d03af4215763d6c51c4b26702200ba679baded (diff) | |
parent | 545cecb28c02a2350b6ecb7a8c0080f9663734d3 (diff) | |
download | gitlab-ce-6623d36b65a87f8db9d35a83f832ee2e0564f8b1.tar.gz |
Merge branch '15343-build-settiings' into 'master'
Resolve "Move Build badges settings to Builds page (or Builds settings)"
## What does this MR do?
Removes pipeline settings section from project settings & creates a new pipelines settings page
Adds builds badge to pipelines settings page & removes badge page
## Are there points in the code the reviewer needs to double check?
All Rails updates -> particularly `builds_controller.rb` and `routes`
Spacing needs to be updated across all settings pages and will be in a separate MR (https://gitlab.com/gitlab-org/gitlab-ce/issues/19827)
## What are the relevant issue numbers?
Closes #15343
Part of #18920
## Screenshots (if relevant)
![Screen_Shot_2016-07-19_at_5.47.29_AM](/uploads/48e6d203de4cbe0b697280128695d980/Screen_Shot_2016-07-19_at_5.47.29_AM.png)
![Screen_Shot_2016-07-14_at_9.25.13_AM](/uploads/59118440f3e7bb903f44260abb119376/Screen_Shot_2016-07-14_at_9.25.13_AM.png)
See merge request !5244
-rw-r--r-- | CHANGELOG | 2 | ||||
-rw-r--r-- | app/controllers/projects/badges_controller.rb | 5 | ||||
-rw-r--r-- | app/controllers/projects/pipelines_settings_controller.rb | 30 | ||||
-rw-r--r-- | app/controllers/projects/refs_controller.rb | 2 | ||||
-rw-r--r-- | app/views/layouts/nav/_project_settings.html.haml | 6 | ||||
-rw-r--r-- | app/views/projects/_builds_settings.html.haml | 65 | ||||
-rw-r--r-- | app/views/projects/badges/index.html.haml | 23 | ||||
-rw-r--r-- | app/views/projects/edit.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/pipelines_settings/show.html.haml | 103 | ||||
-rw-r--r-- | config/routes.rb | 4 | ||||
-rw-r--r-- | spec/features/pipelines_settings_spec.rb | 35 | ||||
-rw-r--r-- | spec/features/projects/badges/list_spec.rb | 2 |
12 files changed, 179 insertions, 100 deletions
diff --git a/CHANGELOG b/CHANGELOG index 748128f100a..e7526d8ef28 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -138,6 +138,8 @@ v 8.10.0 (unreleased) - Render only commit message title in builds (Katarzyna Kobierska Ula Budziszewska) - Allow bulk (un)subscription from issues in issue index - Fix MR diff encoding issues exporting GitLab projects + - Move builds settings out of project settings and rename Pipelines + - Add builds badge to Pipelines settings page - Export and import avatar as part of project import/export - Fix migration corrupting import data for old version upgrades diff --git a/app/controllers/projects/badges_controller.rb b/app/controllers/projects/badges_controller.rb index 824aa41db51..a9f482c8787 100644 --- a/app/controllers/projects/badges_controller.rb +++ b/app/controllers/projects/badges_controller.rb @@ -3,11 +3,6 @@ class Projects::BadgesController < Projects::ApplicationController before_action :authorize_admin_project!, only: [:index] before_action :no_cache_headers, except: [:index] - def index - @ref = params[:ref] || @project.default_branch || 'master' - @build_badge = Gitlab::Badge::Build.new(@project, @ref) - end - def build badge = Gitlab::Badge::Build.new(project, params[:ref]) diff --git a/app/controllers/projects/pipelines_settings_controller.rb b/app/controllers/projects/pipelines_settings_controller.rb new file mode 100644 index 00000000000..85ba706e5cd --- /dev/null +++ b/app/controllers/projects/pipelines_settings_controller.rb @@ -0,0 +1,30 @@ +class Projects::PipelinesSettingsController < Projects::ApplicationController + before_action :authorize_admin_pipeline! + + def show + @ref = params[:ref] || @project.default_branch || 'master' + @build_badge = Gitlab::Badge::Build.new(@project, @ref) + end + + def update + if @project.update_attributes(update_params) + flash[:notice] = "CI/CD Pipelines settings for '#{@project.name}' were successfully updated." + redirect_to namespace_project_pipelines_settings_path(@project.namespace, @project) + else + render 'index' + end + end + + private + + def create_params + params.require(:pipeline).permit(:ref) + end + + def update_params + params.require(:project).permit( + :runners_token, :builds_enabled, :build_allow_git_fetch, :build_timeout_in_minutes, :build_coverage_regex, + :public_builds + ) + end +end diff --git a/app/controllers/projects/refs_controller.rb b/app/controllers/projects/refs_controller.rb index d79f16e6a5a..3602b3d5e58 100644 --- a/app/controllers/projects/refs_controller.rb +++ b/app/controllers/projects/refs_controller.rb @@ -25,7 +25,7 @@ class Projects::RefsController < Projects::ApplicationController when "graphs_commits" commits_namespace_project_graph_path(@project.namespace, @project, @id) when "badges" - namespace_project_badges_path(@project.namespace, @project, ref: @id) + namespace_project_pipelines_settings_path(@project.namespace, @project, ref: @id) else namespace_project_commits_path(@project.namespace, @project, @id) end diff --git a/app/views/layouts/nav/_project_settings.html.haml b/app/views/layouts/nav/_project_settings.html.haml index 51a54b4f262..52a5bdc1a1b 100644 --- a/app/views/layouts/nav/_project_settings.html.haml +++ b/app/views/layouts/nav/_project_settings.html.haml @@ -39,7 +39,7 @@ = link_to namespace_project_triggers_path(@project.namespace, @project), title: 'Triggers' do %span Triggers - = nav_link(controller: :badges) do - = link_to namespace_project_badges_path(@project.namespace, @project), title: 'Badges' do + = nav_link(controller: :pipelines_settings) do + = link_to namespace_project_pipelines_settings_path(@project.namespace, @project), title: 'CI/CD Pipelines' do %span - Badges + CI/CD Pipelines diff --git a/app/views/projects/_builds_settings.html.haml b/app/views/projects/_builds_settings.html.haml deleted file mode 100644 index fff30f11d82..00000000000 --- a/app/views/projects/_builds_settings.html.haml +++ /dev/null @@ -1,65 +0,0 @@ -%fieldset.builds-feature - %h5.prepend-top-0 - Builds - - unless @repository.gitlab_ci_yml - .form-group - %p Builds need to be configured before you can begin using Continuous Integration. - = link_to 'Get started with Builds', help_page_path('ci/quick_start/README'), class: 'btn btn-info' - .form-group - %p Get recent application code using the following command: - .radio - = f.label :build_allow_git_fetch_false do - = f.radio_button :build_allow_git_fetch, 'false' - %strong git clone - %br - %span.descr Slower but makes sure you have a clean dir before every build - .radio - = f.label :build_allow_git_fetch_true do - = f.radio_button :build_allow_git_fetch, 'true' - %strong git fetch - %br - %span.descr Faster - - .form-group - = f.label :build_timeout_in_minutes, 'Timeout', class: 'label-light' - = f.number_field :build_timeout_in_minutes, class: 'form-control', min: '0' - %p.help-block per build in minutes - .form-group - = f.label :build_coverage_regex, "Test coverage parsing", class: 'label-light' - .input-group - %span.input-group-addon / - = f.text_field :build_coverage_regex, class: 'form-control', placeholder: '\(\d+.\d+\%\) covered' - %span.input-group-addon / - %p.help-block - We will use this regular expression to find test coverage output in build trace. - Leave blank if you want to disable this feature - .bs-callout.bs-callout-info - %p Below are examples of regex for existing tools: - %ul - %li - Simplecov (Ruby) - - %code \(\d+.\d+\%\) covered - %li - pytest-cov (Python) - - %code \d+\%\s*$ - %li - phpunit --coverage-text --colors=never (PHP) - - %code ^\s*Lines:\s*\d+.\d+\% - %li - gcovr (C/C++) - - %code ^TOTAL.*\s+(\d+\%)$ - %li - tap --coverage-report=text-summary (Node.js) - - %code ^Statements\s*:\s*([^%]+) - - .form-group - .checkbox - = f.label :public_builds do - = f.check_box :public_builds - %strong Public builds - .help-block Allow everyone to access builds for Public and Internal projects - - .form-group.append-bottom-0 - = f.label :runners_token, "Runners token", class: 'label-light' - = f.text_field :runners_token, class: "form-control", placeholder: 'xEeFCaDAB89' - %p.help-block The secure token used to checkout project. diff --git a/app/views/projects/badges/index.html.haml b/app/views/projects/badges/index.html.haml deleted file mode 100644 index ac80951dd4f..00000000000 --- a/app/views/projects/badges/index.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -- page_title 'Badges' -- badges_path = namespace_project_badges_path(@project.namespace, @project) - -.prepend-top-10 - .panel.panel-default - .panel-heading - %b Builds badge · - = @build_badge.to_html - .pull-right - = render 'shared/ref_switcher', destination: 'badges', align_right: true - .panel-body - .row - .col-md-2.text-center - Markdown - .col-md-10.code.js-syntax-highlight - = highlight('.md', @build_badge.to_markdown) - .row - %hr - .row - .col-md-2.text-center - HTML - .col-md-10.code.js-syntax-highlight - = highlight('.html', @build_badge.to_html) diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml index 541d81e65e5..921155e970b 100644 --- a/app/views/projects/edit.html.haml +++ b/app/views/projects/edit.html.haml @@ -90,8 +90,6 @@ %hr = render 'merge_request_settings', f: f %hr - = render 'builds_settings', f: f - %hr %fieldset.features.append-bottom-default %h5.prepend-top-0 Project avatar diff --git a/app/views/projects/pipelines_settings/show.html.haml b/app/views/projects/pipelines_settings/show.html.haml new file mode 100644 index 00000000000..228bad36ebd --- /dev/null +++ b/app/views/projects/pipelines_settings/show.html.haml @@ -0,0 +1,103 @@ +- page_title "CI/CD Pipelines" + +.row.prepend-top-default + .col-lg-3.profile-settings-sidebar + %h4.prepend-top-0 + = page_title + .col-lg-9 + %h5.prepend-top-0 + Pipelines + = form_for @project, url: namespace_project_pipelines_settings_path(@project.namespace.becomes(Namespace), @project), remote: true, authenticity_token: true do |f| + %fieldset.builds-feature + - unless @repository.gitlab_ci_yml + .form-group + %p Pipelines need to be configured before you can begin using Continuous Integration. + = link_to 'Get started with CI/CD Pipelines', help_page_path('ci/quick_start/README'), class: 'btn btn-info' + .form-group + %p Get recent application code using the following command: + .radio + = f.label :build_allow_git_fetch_false do + = f.radio_button :build_allow_git_fetch, 'false' + %strong git clone + %br + %span.descr Slower but makes sure you have a clean dir before every build + .radio + = f.label :build_allow_git_fetch_true do + = f.radio_button :build_allow_git_fetch, 'true' + %strong git fetch + %br + %span.descr Faster + + .form-group + = f.label :build_timeout_in_minutes, 'Timeout', class: 'label-light' + = f.number_field :build_timeout_in_minutes, class: 'form-control', min: '0' + %p.help-block per build in minutes + .form-group + = f.label :build_coverage_regex, "Test coverage parsing", class: 'label-light' + .input-group + %span.input-group-addon / + = f.text_field :build_coverage_regex, class: 'form-control', placeholder: '\(\d+.\d+\%\) covered' + %span.input-group-addon / + %p.help-block + We will use this regular expression to find test coverage output in build trace. + Leave blank if you want to disable this feature + .bs-callout.bs-callout-info + %p Below are examples of regex for existing tools: + %ul + %li + Simplecov (Ruby) - + %code \(\d+.\d+\%\) covered + %li + pytest-cov (Python) - + %code \d+\%\s*$ + %li + phpunit --coverage-text --colors=never (PHP) - + %code ^\s*Lines:\s*\d+.\d+\% + %li + gcovr (C/C++) - + %code ^TOTAL.*\s+(\d+\%)$ + %li + tap --coverage-report=text-summary (Node.js) - + %code ^Statements\s*:\s*([^%]+) + + .form-group + .checkbox + = f.label :public_builds do + = f.check_box :public_builds + %strong Public pipelines + .help-block Allow everyone to access pipelines for Public and Internal projects + + .form-group.append-bottom-default + = f.label :runners_token, "Runners token", class: 'label-light' + = f.text_field :runners_token, class: "form-control", placeholder: 'xEeFCaDAB89' + %p.help-block The secure token used to checkout project. + + = f.submit 'Save changes', class: "btn btn-save" + +%hr + +.row.prepend-top-default + .col-lg-3.profile-settings-sidebar + %h4.prepend-top-0 + Builds Badge + .col-lg-9 + .prepend-top-10 + .panel.panel-default + .panel-heading + %b Builds badge · + = @build_badge.to_html + .pull-right + = render 'shared/ref_switcher', destination: 'badges', align_right: true + .panel-body + .row + .col-md-2.text-center + Markdown + .col-md-10.code.js-syntax-highlight + = highlight('.md', @build_badge.to_markdown) + .row + %hr + .row + .col-md-2.text-center + HTML + .col-md-10.code.js-syntax-highlight + = highlight('.html', @build_badge.to_html) diff --git a/config/routes.rb b/config/routes.rb index 2a9fe30b0e6..21f3585bacd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -732,6 +732,10 @@ Rails.application.routes.draw do resources :triggers, only: [:index, :create, :destroy] resources :pipelines, only: [:index, :new, :create, :show] do + collection do + resource :pipelines_settings, path: 'settings', only: [:show, :update] + end + member do post :cancel post :retry diff --git a/spec/features/pipelines_settings_spec.rb b/spec/features/pipelines_settings_spec.rb new file mode 100644 index 00000000000..dcc364a3d01 --- /dev/null +++ b/spec/features/pipelines_settings_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +feature "Pipelines settings", feature: true do + include GitlabRoutingHelper + + let(:project) { create(:empty_project) } + let(:user) { create(:user) } + let(:role) { :developer } + + background do + login_as(user) + project.team << [user, role] + visit namespace_project_pipelines_settings_path(project.namespace, project) + end + + context 'for developer' do + given(:role) { :developer } + + scenario 'to be disallowed to view' do + expect(page.status_code).to eq(404) + end + end + + context 'for master' do + given(:role) { :master } + + scenario 'be allowed to change' do + fill_in('Test coverage parsing', with: 'coverage_regex') + click_on 'Save changes' + + expect(page.status_code).to eq(200) + expect(page).to have_field('Test coverage parsing', with: 'coverage_regex') + end + end +end diff --git a/spec/features/projects/badges/list_spec.rb b/spec/features/projects/badges/list_spec.rb index 01e90618a98..75166bca119 100644 --- a/spec/features/projects/badges/list_spec.rb +++ b/spec/features/projects/badges/list_spec.rb @@ -6,7 +6,7 @@ feature 'list of badges' do project = create(:project) project.team << [user, :master] login_as(user) - visit namespace_project_badges_path(project.namespace, project) + visit namespace_project_pipelines_settings_path(project.namespace, project) end scenario 'user displays list of badges' do |