Commit 2fdf928a authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'ci-setup-info' into 'master'

Add links to CI setup documentation from project settings and builds pages

For #14483 
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>

See merge request !3384
parents 43e49f52 179bae99
...@@ -4,6 +4,7 @@ v 8.7.0 (unreleased) ...@@ -4,6 +4,7 @@ v 8.7.0 (unreleased)
- Preserve time notes/comments have been updated at when moving issue - Preserve time notes/comments have been updated at when moving issue
- Make HTTP(s) label consistent on clone bar (Stan Hu) - Make HTTP(s) label consistent on clone bar (Stan Hu)
- Fix avatar stretching by providing a cropping feature - Fix avatar stretching by providing a cropping feature
- Add links to CI setup documentation from project settings and builds pages
v 8.6.2 (unreleased) v 8.6.2 (unreleased)
- Comments on confidential issues don't show up in activity feed to non-members - Comments on confidential issues don't show up in activity feed to non-members
......
...@@ -467,6 +467,18 @@ class Repository ...@@ -467,6 +467,18 @@ class Repository
end end
end end
def gitlab_ci_yml
return nil if !exists? || empty?
@gitlab_ci_yml ||= tree(:head).blobs.find do |file|
file.name == '.gitlab-ci.yml'
end
rescue Rugged::ReferenceError
# For unknow reason spinach scenario "Scenario: I change project path"
# lead to "Reference 'HEAD' not found" exception from Repository#empty?
nil
end
def head_commit def head_commit
@head_commit ||= commit(self.root_ref) @head_commit ||= commit(self.root_ref)
end end
......
%fieldset.builds-feature %fieldset.builds-feature
%legend %legend
Builds: Builds:
- unless @repository.gitlab_ci_yml
.form-group
.col-sm-offset-2.col-sm-10
%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'
%hr
.form-group .form-group
.col-sm-offset-2.col-sm-10 .col-sm-offset-2.col-sm-10
%p Get recent application code using the following command: %p Get recent application code using the following command:
......
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
= link_to 'Cancel running', cancel_all_namespace_project_builds_path(@project.namespace, @project), = link_to 'Cancel running', cancel_all_namespace_project_builds_path(@project.namespace, @project),
data: { confirm: 'Are you sure?' }, class: 'btn btn-danger', method: :post data: { confirm: 'Are you sure?' }, class: 'btn btn-danger', method: :post
- unless @repository.gitlab_ci_yml
= link_to 'Get started with Builds', help_page_path('ci/quick_start', 'README'), class: 'btn btn-info'
= link_to ci_lint_path, class: 'btn btn-default' do = link_to ci_lint_path, class: 'btn btn-default' do
= icon('wrench') = icon('wrench')
%span CI Lint %span CI Lint
......
...@@ -2,6 +2,7 @@ require 'spec_helper' ...@@ -2,6 +2,7 @@ require 'spec_helper'
describe Repository, models: true do describe Repository, models: true do
include RepoHelpers include RepoHelpers
TestBlob = Struct.new(:name)
let(:repository) { create(:project).repository } let(:repository) { create(:project).repository }
let(:user) { create(:user) } let(:user) { create(:user) }
...@@ -131,7 +132,6 @@ describe Repository, models: true do ...@@ -131,7 +132,6 @@ describe Repository, models: true do
describe "#license" do describe "#license" do
before do before do
repository.send(:cache).expire(:license) repository.send(:cache).expire(:license)
TestBlob = Struct.new(:name)
end end
it 'test selection preference' do it 'test selection preference' do
...@@ -148,6 +148,25 @@ describe Repository, models: true do ...@@ -148,6 +148,25 @@ describe Repository, models: true do
end end
end end
describe "#gitlab_ci_yml" do
it 'returns valid file' do
files = [TestBlob.new('file'), TestBlob.new('.gitlab-ci.yml'), TestBlob.new('copying')]
expect(repository.tree).to receive(:blobs).and_return(files)
expect(repository.gitlab_ci_yml.name).to eq('.gitlab-ci.yml')
end
it 'returns nil if not exists' do
expect(repository.tree).to receive(:blobs).and_return([])
expect(repository.gitlab_ci_yml).to be_nil
end
it 'returns nil for empty repository' do
expect(repository).to receive(:empty?).and_return(true)
expect(repository.gitlab_ci_yml).to be_nil
end
end
describe :add_branch do describe :add_branch do
context 'when pre hooks were successful' do context 'when pre hooks were successful' do
it 'should run without errors' do it 'should run without errors' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment