From 80f9aff34b07fd8dc490a06cd6281b5af4310438 Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Tue, 13 Mar 2018 11:57:16 -0600 Subject: [PATCH 1/8] Make ci/lint page context aware: - Create ci/lints controller inside project/ - Move js pages to be inside projects/ - Copy view ci/lint view to be inside project folder - Remove ci/lint view and js files Closes #43603 --- .../{ => projects}/ci/lints/ci_lint_editor.js | 0 .../ci/lints/create}/index.js | 0 .../pages/projects/ci/lints/show/index.js | 3 + app/controllers/ci/lints_controller.rb | 15 --- .../projects/ci/lints_controller.rb | 31 +++++ app/views/ci/lints/show.html.haml | 29 +---- .../{ => projects}/ci/lints/_create.html.haml | 0 app/views/projects/ci/lints/show.html.haml | 27 ++++ app/views/projects/pipelines/index.html.haml | 2 +- .../unreleased/43603-ci-lint-support.yml | 5 + config/routes/ci.rb | 2 +- config/routes/project.rb | 4 + lib/gitlab/ci/config.rb | 2 +- lib/gitlab/ci/yaml_processor.rb | 8 +- .../projects/ci/lints_controller_spec.rb | 123 ++++++++++++++++++ .../ci/lint_spec.rb} | 10 +- .../ci/lints/show.html.haml_spec.rb | 6 +- 17 files changed, 216 insertions(+), 51 deletions(-) rename app/assets/javascripts/pages/{ => projects}/ci/lints/ci_lint_editor.js (100%) rename app/assets/javascripts/pages/{ci/lints/show => projects/ci/lints/create}/index.js (100%) create mode 100644 app/assets/javascripts/pages/projects/ci/lints/show/index.js create mode 100644 app/controllers/projects/ci/lints_controller.rb rename app/views/{ => projects}/ci/lints/_create.html.haml (100%) create mode 100644 app/views/projects/ci/lints/show.html.haml create mode 100644 changelogs/unreleased/43603-ci-lint-support.yml create mode 100644 spec/controllers/projects/ci/lints_controller_spec.rb rename spec/features/{ci_lint_spec.rb => projects/ci/lint_spec.rb} (91%) rename spec/views/{ => projects}/ci/lints/show.html.haml_spec.rb (92%) diff --git a/app/assets/javascripts/pages/ci/lints/ci_lint_editor.js b/app/assets/javascripts/pages/projects/ci/lints/ci_lint_editor.js similarity index 100% rename from app/assets/javascripts/pages/ci/lints/ci_lint_editor.js rename to app/assets/javascripts/pages/projects/ci/lints/ci_lint_editor.js diff --git a/app/assets/javascripts/pages/ci/lints/show/index.js b/app/assets/javascripts/pages/projects/ci/lints/create/index.js similarity index 100% rename from app/assets/javascripts/pages/ci/lints/show/index.js rename to app/assets/javascripts/pages/projects/ci/lints/create/index.js diff --git a/app/assets/javascripts/pages/projects/ci/lints/show/index.js b/app/assets/javascripts/pages/projects/ci/lints/show/index.js new file mode 100644 index 00000000000..8e8a843da0b --- /dev/null +++ b/app/assets/javascripts/pages/projects/ci/lints/show/index.js @@ -0,0 +1,3 @@ +import CILintEditor from '../ci_lint_editor'; + +document.addEventListener('DOMContentLoaded', () => new CILintEditor()); diff --git a/app/controllers/ci/lints_controller.rb b/app/controllers/ci/lints_controller.rb index e9bd1689a1e..738a6a5173e 100644 --- a/app/controllers/ci/lints_controller.rb +++ b/app/controllers/ci/lints_controller.rb @@ -4,20 +4,5 @@ module Ci def show end - - def create - @content = params[:content] - @error = Gitlab::Ci::YamlProcessor.validation_message(@content) - @status = @error.blank? - - if @error.blank? - @config_processor = Gitlab::Ci::YamlProcessor.new(@content) - @stages = @config_processor.stages - @builds = @config_processor.builds - @jobs = @config_processor.jobs - end - - render :show - end end end diff --git a/app/controllers/projects/ci/lints_controller.rb b/app/controllers/projects/ci/lints_controller.rb new file mode 100644 index 00000000000..47328504cd5 --- /dev/null +++ b/app/controllers/projects/ci/lints_controller.rb @@ -0,0 +1,31 @@ +class Projects::Ci::LintsController < Projects::ApplicationController + before_action :ensure_user_access + + def show + end + + def create + @content = params[:content] + @error = Gitlab::Ci::YamlProcessor.validation_message(@content, yaml_processor_options) + @status = @error.blank? + + if @error.blank? + @config_processor = Gitlab::Ci::YamlProcessor.new(@content, yaml_processor_options) + @stages = @config_processor.stages + @builds = @config_processor.builds + @jobs = @config_processor.jobs + end + + render :show + end + + private + + def yaml_processor_options + { project: @project, sha: project.repository.commit.sha } + end + + def ensure_user_access + return access_denied! unless can?(current_user, :create_pipeline, @project) + end +end diff --git a/app/views/ci/lints/show.html.haml b/app/views/ci/lints/show.html.haml index 3c0881caa06..2f8387dc762 100644 --- a/app/views/ci/lints/show.html.haml +++ b/app/views/ci/lints/show.html.haml @@ -1,27 +1,6 @@ - page_title "CI Lint" -- page_description "Validate your GitLab CI configuration file" -- content_for :library_javascripts do - = page_specific_javascript_tag('lib/ace.js') -%h2 Check your .gitlab-ci.yml - -.ci-linter - .row - = form_tag ci_lint_path, method: :post do - .form-group - .col-sm-12 - .file-holder - .js-file-title.file-title.clearfix - Content of .gitlab-ci.yml - #ci-editor.ci-editor= @content - = text_area_tag(:content, @content, class: 'hidden form-control span1', rows: 7, require: true) - .col-sm-12 - .pull-left.prepend-top-10 - = submit_tag('Validate', class: 'btn btn-success submit-yml') - .pull-right.prepend-top-10 - = button_tag('Clear', type: 'button', class: 'btn btn-default clear-yml') - - .row.prepend-top-20 - .col-sm-12 - .results.ci-template - = render partial: 'create' if defined?(@status) +.center + = image_tag 'illustrations/feature_moved.svg' + %h3 GitLab CI Linter has been moved + %p To validate your GitLab CI configurations, go to 'CI/CD → Pipelines' inside your project, and click on the "CI Lint" button. diff --git a/app/views/ci/lints/_create.html.haml b/app/views/projects/ci/lints/_create.html.haml similarity index 100% rename from app/views/ci/lints/_create.html.haml rename to app/views/projects/ci/lints/_create.html.haml diff --git a/app/views/projects/ci/lints/show.html.haml b/app/views/projects/ci/lints/show.html.haml new file mode 100644 index 00000000000..cf2a25ce844 --- /dev/null +++ b/app/views/projects/ci/lints/show.html.haml @@ -0,0 +1,27 @@ +- page_title "CI Lint" +- page_description "Validate your GitLab CI configuration file" +- content_for :library_javascripts do + = page_specific_javascript_tag('lib/ace.js') + +%h2 Check your .gitlab-ci.yml + +.ci-linter + .row + = form_tag project_ci_lint_path(@project), method: :post do + .form-group + .col-sm-12 + .file-holder + .js-file-title.file-title.clearfix + Content of .gitlab-ci.yml + #ci-editor.ci-editor= @content + = text_area_tag(:content, @content, class: 'hidden form-control span1', rows: 7, require: true) + .col-sm-12 + .pull-left.prepend-top-10 + = submit_tag('Validate', class: 'btn btn-success submit-yml') + .pull-right.prepend-top-10 + = button_tag('Clear', type: 'button', class: 'btn btn-default clear-yml') + + .row.prepend-top-20 + .col-sm-12 + .results.ci-template + = render partial: 'create' if defined?(@status) diff --git a/app/views/projects/pipelines/index.html.haml b/app/views/projects/pipelines/index.html.haml index 3e6b3346787..c0ee81fe28d 100644 --- a/app/views/projects/pipelines/index.html.haml +++ b/app/views/projects/pipelines/index.html.haml @@ -10,6 +10,6 @@ "no-pipelines-svg-path" => image_path('illustrations/pipelines_pending.svg'), "can-create-pipeline" => can?(current_user, :create_pipeline, @project).to_s, "new-pipeline-path" => can?(current_user, :create_pipeline, @project) && new_project_pipeline_path(@project), - "ci-lint-path" => can?(current_user, :create_pipeline, @project) && ci_lint_path, + "ci-lint-path" => can?(current_user, :create_pipeline, @project) && project_ci_lint_path(@project), "reset-cache-path" => can?(current_user, :admin_pipeline, @project) && reset_cache_project_settings_ci_cd_path(@project) , "has-gitlab-ci" => (@project.has_ci? && @project.builds_enabled?).to_s } } diff --git a/changelogs/unreleased/43603-ci-lint-support.yml b/changelogs/unreleased/43603-ci-lint-support.yml new file mode 100644 index 00000000000..8e4a92c0287 --- /dev/null +++ b/changelogs/unreleased/43603-ci-lint-support.yml @@ -0,0 +1,5 @@ +--- +title: Move ci/lint under project's namespace +merge_request: 17729 +author: +type: added diff --git a/config/routes/ci.rb b/config/routes/ci.rb index 60c1724bc05..ebd321ed097 100644 --- a/config/routes/ci.rb +++ b/config/routes/ci.rb @@ -1,5 +1,5 @@ namespace :ci do - resource :lint, only: [:show, :create] + resource :lint, only: :show root to: redirect('') end diff --git a/config/routes/project.rb b/config/routes/project.rb index f50b9aded8d..656ba6834f2 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -423,6 +423,10 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do resource :repository, only: [:show], controller: :repository end + namespace :ci do + resource :lint, only: [:show, :create] + end + # Since both wiki and repository routing contains wildcard characters # its preferable to keep it below all other project routes draw :wiki diff --git a/lib/gitlab/ci/config.rb b/lib/gitlab/ci/config.rb index f7ff7ea212e..1c2e86cd1cb 100644 --- a/lib/gitlab/ci/config.rb +++ b/lib/gitlab/ci/config.rb @@ -4,7 +4,7 @@ module Gitlab # Base GitLab CI Configuration facade # class Config - def initialize(config) + def initialize(config, opts = {}) @config = Loader.new(config).load! @global = Entry::Global.new(@config) diff --git a/lib/gitlab/ci/yaml_processor.rb b/lib/gitlab/ci/yaml_processor.rb index bc2a6f98dae..e829f2a95f8 100644 --- a/lib/gitlab/ci/yaml_processor.rb +++ b/lib/gitlab/ci/yaml_processor.rb @@ -7,8 +7,8 @@ module Gitlab attr_reader :cache, :stages, :jobs - def initialize(config) - @ci_config = Gitlab::Ci::Config.new(config) + def initialize(config, opts = {}) + @ci_config = Gitlab::Ci::Config.new(config, opts) @config = @ci_config.to_hash unless @ci_config.valid? @@ -73,11 +73,11 @@ module Gitlab end end - def self.validation_message(content) + def self.validation_message(content, opts = {}) return 'Please provide content of .gitlab-ci.yml' if content.blank? begin - Gitlab::Ci::YamlProcessor.new(content) + Gitlab::Ci::YamlProcessor.new(content, opts) nil rescue ValidationError => e e.message diff --git a/spec/controllers/projects/ci/lints_controller_spec.rb b/spec/controllers/projects/ci/lints_controller_spec.rb new file mode 100644 index 00000000000..1249a5528a9 --- /dev/null +++ b/spec/controllers/projects/ci/lints_controller_spec.rb @@ -0,0 +1,123 @@ +require 'spec_helper' + +describe Projects::Ci::LintsController do + let(:project) { create(:project, :repository) } + let(:user) { create(:user) } + + before do + sign_in(user) + end + + describe 'GET #show' do + context 'with enough privileges' do + before do + project.add_developer(user) + + get :show, namespace_id: project.namespace, project_id: project + end + + it 'should be success' do + expect(response).to be_success + end + + it 'should render show page' do + expect(response).to render_template :show + end + + it 'should retrieve project' do + expect(assigns(:project)).to eq(project) + end + end + + context 'without enough privileges' do + before do + project.add_guest(user) + + get :show, namespace_id: project.namespace, project_id: project + end + + it 'should respond with 404' do + expect(response).to have_gitlab_http_status(404) + end + end + end + + describe 'POST #create' do + let(:remote_file_path) { 'https://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml' } + + let(:remote_file_content) do + <<~HEREDOC + before_script: + - apt-get update -qq && apt-get install -y -qq sqlite3 libsqlite3-dev nodejs + - ruby -v + - which ruby + - gem install bundler --no-ri --no-rdoc + - bundle install --jobs $(nproc) "${FLAGS[@]}" + HEREDOC + end + + let(:content) do + <<~HEREDOC + include: + - #{remote_file_path} + + rubocop: + script: + - bundle exec rubocop + HEREDOC + end + + context 'with a valid gitlab-ci.yml' do + before do + WebMock.stub_request(:get, remote_file_path).to_return(body: remote_file_content) + project.add_developer(user) + + post :create, namespace_id: project.namespace, project_id: project, content: content + end + + it 'should be success' do + expect(response).to be_success + end + + it 'render show page' do + expect(response).to render_template :show + end + + it 'should retrieve project' do + expect(assigns(:project)).to eq(project) + end + end + + context 'with an invalid gitlab-ci.yml' do + let(:content) do + <<~HEREDOC + rubocop: + scriptt: + - bundle exec rubocop + HEREDOC + end + + before do + project.add_developer(user) + + post :create, namespace_id: project.namespace, project_id: project, content: content + end + + it 'should assign errors' do + expect(assigns[:error]).to eq('jobs:rubocop config contains unknown keys: scriptt') + end + end + + context 'without enough privileges' do + before do + project.add_guest(user) + + post :create, namespace_id: project.namespace, project_id: project, content: content + end + + it 'should respond with 404' do + expect(response).to have_gitlab_http_status(404) + end + end + end +end diff --git a/spec/features/ci_lint_spec.rb b/spec/features/projects/ci/lint_spec.rb similarity index 91% rename from spec/features/ci_lint_spec.rb rename to spec/features/projects/ci/lint_spec.rb index 220b934154e..313950072e7 100644 --- a/spec/features/ci_lint_spec.rb +++ b/spec/features/projects/ci/lint_spec.rb @@ -1,10 +1,14 @@ require 'spec_helper' describe 'CI Lint', :js do - before do - sign_in(create(:user)) + let(:project) { create(:project, :repository) } + let(:user) { create(:user) } - visit ci_lint_path + before do + project.add_developer(user) + sign_in(user) + + visit project_ci_lint_path(project) find('#ci-editor') execute_script("ace.edit('ci-editor').setValue(#{yaml_content.to_json});") diff --git a/spec/views/ci/lints/show.html.haml_spec.rb b/spec/views/projects/ci/lints/show.html.haml_spec.rb similarity index 92% rename from spec/views/ci/lints/show.html.haml_spec.rb rename to spec/views/projects/ci/lints/show.html.haml_spec.rb index ded320793ea..b50acc54276 100644 --- a/spec/views/ci/lints/show.html.haml_spec.rb +++ b/spec/views/projects/ci/lints/show.html.haml_spec.rb @@ -1,12 +1,14 @@ require 'spec_helper' -describe 'ci/lints/show' do +describe 'projects/ci/lints/show' do include Devise::Test::ControllerHelpers + let(:project) { create(:project, :repository) } describe 'XSS protection' do let(:config_processor) { Gitlab::Ci::YamlProcessor.new(YAML.dump(content)) } before do + assign(:project, project) assign(:status, true) assign(:builds, config_processor.builds) assign(:stages, config_processor.stages) @@ -64,6 +66,7 @@ describe 'ci/lints/show' do context 'when the content is valid' do before do + assign(:project, project) assign(:status, true) assign(:builds, config_processor.builds) assign(:stages, config_processor.stages) @@ -83,6 +86,7 @@ describe 'ci/lints/show' do context 'when the content is invalid' do before do + assign(:project, project) assign(:status, false) assign(:error, 'Undefined error') end From 02bc89983a4b4b81a2f6279c39622b8a14430e3d Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Tue, 13 Mar 2018 14:57:42 -0600 Subject: [PATCH 2/8] Build ci/lint page - Includes new image from gitlab-svgs - Updates dependency for svgs --- app/assets/stylesheets/pages/lint.scss | 31 ++++++++----------- app/assets/stylesheets/pages/projects.scss | 22 +++++++++++++ .../projects/settings/ci_cd_controller.rb | 6 ++-- app/views/ci/lints/show.html.haml | 11 +++---- app/views/projects/ci/lints/show.html.haml | 4 +-- .../projects/ci/lints/show.html.haml_spec.rb | 29 ++++++++--------- 6 files changed, 58 insertions(+), 45 deletions(-) diff --git a/app/assets/stylesheets/pages/lint.scss b/app/assets/stylesheets/pages/lint.scss index 68b6c5ecbd4..5da774828d9 100644 --- a/app/assets/stylesheets/pages/lint.scss +++ b/app/assets/stylesheets/pages/lint.scss @@ -1,21 +1,16 @@ -.ci-body { - .incorrect-syntax { - font-size: 18px; - color: $lint-incorrect-color; - } - - .correct-syntax { - font-size: 18px; - color: $lint-correct-color; - } +.ci-linter-container { + align-items: center; + display: flex; + height: calc(100vh - #{$header-height + $performance-bar-height}); + justify-content: center; + text-align: center; } -.ci-linter { - .ci-editor { - height: 400px; - } - - .ci-template pre { - white-space: pre-wrap; - } +.ci-linter-inner { + width: auto; +} + +.ci-linter-description { + color: $common-gray-light; + width: 500px; } diff --git a/app/assets/stylesheets/pages/projects.scss b/app/assets/stylesheets/pages/projects.scss index 584b0579b72..9a770d77685 100644 --- a/app/assets/stylesheets/pages/projects.scss +++ b/app/assets/stylesheets/pages/projects.scss @@ -1121,3 +1121,25 @@ pre.light-well { padding-top: $gl-padding; padding-bottom: 37px; } + +.project-ci-body { + .incorrect-syntax { + font-size: 18px; + color: $lint-incorrect-color; + } + + .correct-syntax { + font-size: 18px; + color: $lint-correct-color; + } +} + +.project-ci-linter { + .ci-editor { + height: 400px; + } + + .ci-template pre { + white-space: pre-wrap; + } +} diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb index 259809f3429..96125b549b7 100644 --- a/app/controllers/projects/settings/ci_cd_controller.rb +++ b/app/controllers/projects/settings/ci_cd_controller.rb @@ -29,12 +29,12 @@ module Projects @project_runners = @project.runners.ordered @assignable_runners = current_user.ci_authorized_runners .assignable_for(project).ordered.page(params[:page]).per(20) - @shared_runners = Ci::Runner.shared.active + @shared_runners = ::Ci::Runner.shared.active @shared_runners_count = @shared_runners.count(:all) end def define_secret_variables - @variable = Ci::Variable.new(project: project) + @variable = ::Ci::Variable.new(project: project) .present(current_user: current_user) @variables = project.variables.order_key_asc .map { |variable| variable.present(current_user: current_user) } @@ -42,7 +42,7 @@ module Projects def define_triggers_variables @triggers = @project.triggers - @trigger = Ci::Trigger.new + @trigger = ::Ci::Trigger.new end def define_badges_variables diff --git a/app/views/ci/lints/show.html.haml b/app/views/ci/lints/show.html.haml index 2f8387dc762..ffd44c2af8d 100644 --- a/app/views/ci/lints/show.html.haml +++ b/app/views/ci/lints/show.html.haml @@ -1,6 +1,5 @@ -- page_title "CI Lint" - -.center - = image_tag 'illustrations/feature_moved.svg' - %h3 GitLab CI Linter has been moved - %p To validate your GitLab CI configurations, go to 'CI/CD → Pipelines' inside your project, and click on the "CI Lint" button. +.ci-linter-container + .ci-linter-inner + = image_tag 'illustrations/feature_moved.svg' + %h3 GitLab CI Linter has been moved + %p.ci-linter-description To validate your GitLab CI configurations, go to 'CI/CD → Pipelines' inside your project, and click on the 'CI Lint' button. diff --git a/app/views/projects/ci/lints/show.html.haml b/app/views/projects/ci/lints/show.html.haml index cf2a25ce844..6ca8152183d 100644 --- a/app/views/projects/ci/lints/show.html.haml +++ b/app/views/projects/ci/lints/show.html.haml @@ -5,7 +5,7 @@ %h2 Check your .gitlab-ci.yml -.ci-linter +.project-ci-linter .row = form_tag project_ci_lint_path(@project), method: :post do .form-group @@ -23,5 +23,5 @@ .row.prepend-top-20 .col-sm-12 - .results.ci-template + .results.project-ci-template = render partial: 'create' if defined?(@status) diff --git a/spec/views/projects/ci/lints/show.html.haml_spec.rb b/spec/views/projects/ci/lints/show.html.haml_spec.rb index b50acc54276..2f0cd38c14a 100644 --- a/spec/views/projects/ci/lints/show.html.haml_spec.rb +++ b/spec/views/projects/ci/lints/show.html.haml_spec.rb @@ -3,10 +3,9 @@ require 'spec_helper' describe 'projects/ci/lints/show' do include Devise::Test::ControllerHelpers let(:project) { create(:project, :repository) } + let(:config_processor) { Gitlab::Ci::YamlProcessor.new(YAML.dump(content)) } describe 'XSS protection' do - let(:config_processor) { Gitlab::Ci::YamlProcessor.new(YAML.dump(content)) } - before do assign(:project, project) assign(:status, true) @@ -50,21 +49,19 @@ describe 'projects/ci/lints/show' do end end - let(:content) do - { - build_template: { - script: './build.sh', - tags: ['dotnet'], - only: ['test@dude/repo'], - except: ['deploy'], - environment: 'testing' - } - } - end - - let(:config_processor) { Gitlab::Ci::YamlProcessor.new(YAML.dump(content)) } - context 'when the content is valid' do + let(:content) do + { + build_template: { + script: './build.sh', + tags: ['dotnet'], + only: ['test@dude/repo'], + except: ['deploy'], + environment: 'testing' + } + } + end + before do assign(:project, project) assign(:status, true) From 5ad7378fc7ed27bad7bd7fe33ac39754119ed6a5 Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Wed, 14 Mar 2018 09:40:09 -0600 Subject: [PATCH 3/8] Change ci/lint page to use a template structure - Removes duplicated CSS - Includes translations for strings --- .../pages/projects/ci/lints/create/index.js | 3 --- .../pages/{ => projects}/ci/lints/new/index.js | 0 app/assets/stylesheets/pages/lint.scss | 13 ------------- app/views/ci/lints/show.html.haml | 14 +++++++++----- 4 files changed, 9 insertions(+), 21 deletions(-) delete mode 100644 app/assets/javascripts/pages/projects/ci/lints/create/index.js rename app/assets/javascripts/pages/{ => projects}/ci/lints/new/index.js (100%) diff --git a/app/assets/javascripts/pages/projects/ci/lints/create/index.js b/app/assets/javascripts/pages/projects/ci/lints/create/index.js deleted file mode 100644 index 8e8a843da0b..00000000000 --- a/app/assets/javascripts/pages/projects/ci/lints/create/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import CILintEditor from '../ci_lint_editor'; - -document.addEventListener('DOMContentLoaded', () => new CILintEditor()); diff --git a/app/assets/javascripts/pages/ci/lints/new/index.js b/app/assets/javascripts/pages/projects/ci/lints/new/index.js similarity index 100% rename from app/assets/javascripts/pages/ci/lints/new/index.js rename to app/assets/javascripts/pages/projects/ci/lints/new/index.js diff --git a/app/assets/stylesheets/pages/lint.scss b/app/assets/stylesheets/pages/lint.scss index 5da774828d9..9eb3a472458 100644 --- a/app/assets/stylesheets/pages/lint.scss +++ b/app/assets/stylesheets/pages/lint.scss @@ -1,16 +1,3 @@ -.ci-linter-container { - align-items: center; - display: flex; - height: calc(100vh - #{$header-height + $performance-bar-height}); - justify-content: center; - text-align: center; -} - -.ci-linter-inner { - width: auto; -} - .ci-linter-description { color: $common-gray-light; - width: 500px; } diff --git a/app/views/ci/lints/show.html.haml b/app/views/ci/lints/show.html.haml index ffd44c2af8d..2cca0e37314 100644 --- a/app/views/ci/lints/show.html.haml +++ b/app/views/ci/lints/show.html.haml @@ -1,5 +1,9 @@ -.ci-linter-container - .ci-linter-inner - = image_tag 'illustrations/feature_moved.svg' - %h3 GitLab CI Linter has been moved - %p.ci-linter-description To validate your GitLab CI configurations, go to 'CI/CD → Pipelines' inside your project, and click on the 'CI Lint' button. +.row.empty-state + .col-xs-12 + .svg-content + = image_tag 'illustrations/feature_moved.svg' + .col-xs-12 + .text-content.text-center + %h4= _("GitLab CI Linter has been moved") + %p.ci-linter-description + = _("To validate your GitLab CI configurations, go to 'CI/CD → Pipelines' inside your project, and click on the 'CI Lint' button.") From 3921d0c78e2cb1432df5ab48c8591c2ea6d98ee8 Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Mon, 19 Mar 2018 08:27:48 -0600 Subject: [PATCH 4/8] Removes lint scss file --- app/assets/stylesheets/pages/lint.scss | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 app/assets/stylesheets/pages/lint.scss diff --git a/app/assets/stylesheets/pages/lint.scss b/app/assets/stylesheets/pages/lint.scss deleted file mode 100644 index 9eb3a472458..00000000000 --- a/app/assets/stylesheets/pages/lint.scss +++ /dev/null @@ -1,3 +0,0 @@ -.ci-linter-description { - color: $common-gray-light; -} From b5b41d38142cb43c6aac21ce06df5b48e4f58513 Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Mon, 19 Mar 2018 12:00:32 -0600 Subject: [PATCH 5/8] Remove unused css class --- app/views/ci/lints/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/ci/lints/show.html.haml b/app/views/ci/lints/show.html.haml index 2cca0e37314..22f149d1caa 100644 --- a/app/views/ci/lints/show.html.haml +++ b/app/views/ci/lints/show.html.haml @@ -5,5 +5,5 @@ .col-xs-12 .text-content.text-center %h4= _("GitLab CI Linter has been moved") - %p.ci-linter-description + %p = _("To validate your GitLab CI configurations, go to 'CI/CD → Pipelines' inside your project, and click on the 'CI Lint' button.") From 56c95fb6a157be67c11172e16c5417bbcf168eb0 Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Wed, 21 Mar 2018 15:24:49 -0600 Subject: [PATCH 6/8] Changes ci/lints controller to use authorize before action Also includes a comment on Ci::Config regarding that's going to be override by EE --- app/controllers/projects/ci/lints_controller.rb | 6 +----- lib/gitlab/ci/config.rb | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/controllers/projects/ci/lints_controller.rb b/app/controllers/projects/ci/lints_controller.rb index 47328504cd5..a2185572a20 100644 --- a/app/controllers/projects/ci/lints_controller.rb +++ b/app/controllers/projects/ci/lints_controller.rb @@ -1,5 +1,5 @@ class Projects::Ci::LintsController < Projects::ApplicationController - before_action :ensure_user_access + before_action :authorize_create_pipeline! def show end @@ -24,8 +24,4 @@ class Projects::Ci::LintsController < Projects::ApplicationController def yaml_processor_options { project: @project, sha: project.repository.commit.sha } end - - def ensure_user_access - return access_denied! unless can?(current_user, :create_pipeline, @project) - end end diff --git a/lib/gitlab/ci/config.rb b/lib/gitlab/ci/config.rb index 1c2e86cd1cb..66ac4a40616 100644 --- a/lib/gitlab/ci/config.rb +++ b/lib/gitlab/ci/config.rb @@ -4,6 +4,7 @@ module Gitlab # Base GitLab CI Configuration facade # class Config + # EE would override this and utilize opts argument def initialize(config, opts = {}) @config = Loader.new(config).load! From 6767dd92da08b2071af0ce6958f1620b7a99edab Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Thu, 22 Mar 2018 14:22:31 -0600 Subject: [PATCH 7/8] Update documentation regarding Ci Linter --- doc/ci/quick_start/README.md | 4 ++-- doc/ci/yaml/README.md | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/ci/quick_start/README.md b/doc/ci/quick_start/README.md index e504b81eae8..f64e868d390 100644 --- a/doc/ci/quick_start/README.md +++ b/doc/ci/quick_start/README.md @@ -104,8 +104,8 @@ Jobs are used to create jobs, which are then picked by What is important is that each job is run independently from each other. -If you want to check whether your `.gitlab-ci.yml` file is valid, there is a -Lint tool under the page `/ci/lint` of your GitLab instance. You can also find +If you want to check whether the `.gitlab-ci.yml` of your project is valid, there is a +Lint tool under the page `/ci/lint` of your project namespace. You can also find a "CI Lint" button to go to this page under **CI/CD ➔ Pipelines** and **Pipelines ➔ Jobs** in your project. diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md index 7184f3367be..c2b06e53c2f 100644 --- a/doc/ci/yaml/README.md +++ b/doc/ci/yaml/README.md @@ -1526,8 +1526,9 @@ capitalization, the commit will be created but the pipeline will be skipped. ## Validate the .gitlab-ci.yml -Each instance of GitLab CI has an embedded debug tool called Lint. -You can find the link under `/ci/lint` of your gitlab instance. +Each instance of GitLab CI has an embedded debug tool called Lint, which validates the +content of your `.gitlab-ci.yml` files. You can find the Lint under the page `ci/lint` of your +project namespace (e.g, `http://gitlab-example.com/gitlab-org/project-123/ci/lint`) ## Using reserved keywords From bab176008b62dddc00db25517c427cbe252bc211 Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Mon, 26 Mar 2018 08:54:29 -0600 Subject: [PATCH 8/8] Move project ci lint under '-' scope --- config/routes/project.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/routes/project.rb b/config/routes/project.rb index 656ba6834f2..48ba8ef06f9 100644 --- a/config/routes/project.rb +++ b/config/routes/project.rb @@ -280,6 +280,10 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do post :keep end end + + namespace :ci do + resource :lint, only: [:show, :create] + end end draw :legacy_builds @@ -423,10 +427,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do resource :repository, only: [:show], controller: :repository end - namespace :ci do - resource :lint, only: [:show, :create] - end - # Since both wiki and repository routing contains wildcard characters # its preferable to keep it below all other project routes draw :wiki