Commit a611eab9 authored by Scott Hampton's avatar Scott Hampton Committed by Mike Greiling

Resolve "Include tags into pipeline detail view"

parent cfe48479
...@@ -65,7 +65,7 @@ export default { ...@@ -65,7 +65,7 @@ export default {
v-if="pipeline.flags.latest" v-if="pipeline.flags.latest"
v-gl-tooltip v-gl-tooltip
class="js-pipeline-url-latest badge badge-success" class="js-pipeline-url-latest badge badge-success"
title="Latest pipeline for this branch" title="__('Latest pipeline for this branch')"
> >
latest latest
</span> </span>
...@@ -97,6 +97,14 @@ export default { ...@@ -97,6 +97,14 @@ export default {
<span v-if="pipeline.flags.stuck" class="js-pipeline-url-stuck badge badge-warning"> <span v-if="pipeline.flags.stuck" class="js-pipeline-url-stuck badge badge-warning">
stuck stuck
</span> </span>
<span
v-if="pipeline.flags.merge_request"
v-gl-tooltip
title="__('This pipeline is run in a merge request context')"
class="js-pipeline-url-mergerequest badge badge-info"
>
merge request
</span>
</div> </div>
</div> </div>
</template> </template>
...@@ -23,6 +23,7 @@ class PipelineEntity < Grape::Entity ...@@ -23,6 +23,7 @@ class PipelineEntity < Grape::Entity
expose :latest?, as: :latest expose :latest?, as: :latest
expose :stuck?, as: :stuck expose :stuck?, as: :stuck
expose :auto_devops_source?, as: :auto_devops expose :auto_devops_source?, as: :auto_devops
expose :merge_request?, as: :merge_request
expose :has_yaml_errors?, as: :yaml_errors expose :has_yaml_errors?, as: :yaml_errors
expose :can_retry?, as: :retryable expose :can_retry?, as: :retryable
expose :can_cancel?, as: :cancelable expose :can_cancel?, as: :cancelable
......
...@@ -24,6 +24,38 @@ ...@@ -24,6 +24,38 @@
- if @pipeline.queued_duration - if @pipeline.queued_duration
= "(queued for #{time_interval_in_words(@pipeline.queued_duration)})" = "(queued for #{time_interval_in_words(@pipeline.queued_duration)})"
.well-segment
.icon-container
= sprite_icon('flag')
- if @pipeline.latest?
%span.js-pipeline-url-latest.badge.badge-success.has-tooltip{ title: _("Latest pipeline for this branch") }
latest
- if @pipeline.has_yaml_errors?
%span.js-pipeline-url-yaml.badge.badge-danger.has-tooltip{ title: @pipeline.yaml_errors }
yaml invalid
- if @pipeline.failure_reason?
%span.js-pipeline-url-failure.badge.badge-danger.has-tooltip{ title: @pipeline.failure_reason }
error
- if @pipeline.auto_devops_source?
- popover_title_text = _('This pipeline makes use of a predefined CI/CD configuration enabled by <b>Auto DevOps.</b>').html_safe
- popover_content_url = help_page_path('topics/autodevops/index.md')
- popover_content_text = _('Learn more about Auto DevOps')
%a.js-pipeline-url-autodevops.badge.badge-info.autodevops-badge{ href: "#", tabindex: "0", role: "button", data: { container: "body",
toggle: "popover",
placement: "top",
html: "true",
trigger: "focus",
title: "<div class='autodevops-title'>#{popover_title_text}</div>",
content: "<a class='autodevops-link' href='#{popover_content_url}' target='_blank' rel='noopener noreferrer nofollow'>#{popover_content_text}</a>",
} }
Auto DevOps
- if @pipeline.merge_request?
%span.js-pipeline-url-mergerequest.badge.badge-info.has-tooltip{ title: "This pipeline is run in a merge request context" }
merge request
- if @pipeline.stuck?
%span.js-pipeline-url-stuck.badge.badge-warning
stuck
.well-segment.branch-info .well-segment.branch-info
.icon-container.commit-icon .icon-container.commit-icon
= custom_icon("icon_commit") = custom_icon("icon_commit")
......
---
title: Merge request pipeline tag, and adds tags to pipeline view
merge_request: 23364
author:
type: added
...@@ -3798,12 +3798,18 @@ msgstr "" ...@@ -3798,12 +3798,18 @@ msgstr ""
msgid "Latest changes" msgid "Latest changes"
msgstr "" msgstr ""
msgid "Latest pipeline for this branch"
msgstr ""
msgid "Learn more" msgid "Learn more"
msgstr "" msgstr ""
msgid "Learn more about %{issue_boards_url}, to keep track of issues in multiple lists, using labels, assignees, and milestones. If you’re missing something from issue boards, please create an issue on %{gitlab_issues_url}." msgid "Learn more about %{issue_boards_url}, to keep track of issues in multiple lists, using labels, assignees, and milestones. If you’re missing something from issue boards, please create an issue on %{gitlab_issues_url}."
msgstr "" msgstr ""
msgid "Learn more about Auto DevOps"
msgstr ""
msgid "Learn more about Kubernetes" msgid "Learn more about Kubernetes"
msgstr "" msgstr ""
...@@ -6605,6 +6611,9 @@ msgstr "" ...@@ -6605,6 +6611,9 @@ msgstr ""
msgid "This page will be removed in a future release." msgid "This page will be removed in a future release."
msgstr "" msgstr ""
msgid "This pipeline makes use of a predefined CI/CD configuration enabled by <b>Auto DevOps.</b>"
msgstr ""
msgid "This project" msgid "This project"
msgstr "" msgstr ""
......
...@@ -110,6 +110,22 @@ describe 'Merge request > User sees merge request pipelines', :js do ...@@ -110,6 +110,22 @@ describe 'Merge request > User sees merge request pipelines', :js do
end end
end end
it 'sees merge request tag for merge request pipelines' do
page.within('.ci-table') do
expect(all('.pipeline-tags')[0])
.to have_content("merge request")
expect(all('.pipeline-tags')[1])
.to have_content("merge request")
expect(all('.pipeline-tags')[2])
.not_to have_content("merge request")
expect(all('.pipeline-tags')[3])
.not_to have_content("merge request")
end
end
it 'sees the latest merge request pipeline as the head pipeline' do it 'sees the latest merge request pipeline as the head pipeline' do
page.within('.ci-widget-content') do page.within('.ci-widget-content') do
expect(page).to have_content("##{merge_request_pipeline_2.id}") expect(page).to have_content("##{merge_request_pipeline_2.id}")
...@@ -276,6 +292,22 @@ describe 'Merge request > User sees merge request pipelines', :js do ...@@ -276,6 +292,22 @@ describe 'Merge request > User sees merge request pipelines', :js do
end end
end end
it 'sees merge request tag for merge request pipelines' do
page.within('.ci-table') do
expect(all('.pipeline-tags')[0])
.to have_content("merge request")
expect(all('.pipeline-tags')[1])
.to have_content("merge request")
expect(all('.pipeline-tags')[2])
.not_to have_content("merge request")
expect(all('.pipeline-tags')[3])
.not_to have_content("merge request")
end
end
it 'sees the latest merge request pipeline as the head pipeline' do it 'sees the latest merge request pipeline as the head pipeline' do
page.within('.ci-widget-content') do page.within('.ci-widget-content') do
expect(page).to have_content("##{merge_request_pipeline_2.id}") expect(page).to have_content("##{merge_request_pipeline_2.id}")
......
...@@ -499,4 +499,154 @@ describe 'Pipeline', :js do ...@@ -499,4 +499,154 @@ describe 'Pipeline', :js do
end end
end end
end end
context 'when user sees pipeline flags in a pipeline detail page' do
let(:project) { create(:project, :repository) }
context 'when pipeline is latest' do
include_context 'pipeline builds'
let(:pipeline) do
create(:ci_pipeline,
project: project,
ref: 'master',
sha: project.commit.id,
user: user)
end
before do
visit project_pipeline_path(project, pipeline)
end
it 'contains badge that indicates it is the latest build' do
page.within(all('.well-segment')[1]) do
expect(page).to have_content 'latest'
end
end
end
context 'when pipeline has configuration errors' do
include_context 'pipeline builds'
let(:pipeline) do
create(:ci_pipeline,
:invalid,
project: project,
ref: 'master',
sha: project.commit.id,
user: user)
end
before do
visit project_pipeline_path(project, pipeline)
end
it 'contains badge that indicates errors' do
page.within(all('.well-segment')[1]) do
expect(page).to have_content 'yaml invalid'
end
end
it 'contains badge with tooltip which contains error' do
expect(pipeline).to have_yaml_errors
page.within(all('.well-segment')[1]) do
expect(page).to have_selector(
%Q{span[title="#{pipeline.yaml_errors}"]})
end
end
it 'contains badge that indicates failure reason' do
expect(page).to have_content 'error'
end
it 'contains badge with tooltip which contains failure reason' do
expect(pipeline.failure_reason?).to eq true
page.within(all('.well-segment')[1]) do
expect(page).to have_selector(
%Q{span[title="#{pipeline.present.failure_reason}"]})
end
end
end
context 'when pipeline is stuck' do
include_context 'pipeline builds'
let(:pipeline) do
create(:ci_pipeline,
project: project,
ref: 'master',
sha: project.commit.id,
user: user)
end
before do
create(:ci_build, :pending, pipeline: pipeline)
visit project_pipeline_path(project, pipeline)
end
it 'contains badge that indicates being stuck' do
page.within(all('.well-segment')[1]) do
expect(page).to have_content 'stuck'
end
end
end
context 'when pipeline uses auto devops' do
include_context 'pipeline builds'
let(:project) { create(:project, :repository, auto_devops_attributes: { enabled: true }) }
let(:pipeline) do
create(:ci_pipeline,
:auto_devops_source,
project: project,
ref: 'master',
sha: project.commit.id,
user: user)
end
before do
visit project_pipeline_path(project, pipeline)
end
it 'contains badge that indicates using auto devops' do
page.within(all('.well-segment')[1]) do
expect(page).to have_content 'Auto DevOps'
end
end
end
context 'when pipeline runs in a merge request context' do
include_context 'pipeline builds'
let(:pipeline) do
create(:ci_pipeline,
source: :merge_request,
project: merge_request.source_project,
ref: 'feature',
sha: merge_request.diff_head_sha,
user: user,
merge_request: merge_request)
end
let(:merge_request) do
create(:merge_request,
source_project: project,
source_branch: 'feature',
target_project: project,
target_branch: 'master')
end
before do
visit project_pipeline_path(project, pipeline)
end
it 'contains badge that indicates merge request pipeline' do
page.within(all('.well-segment')[1]) do
expect(page).to have_content 'merge request'
end
end
end
end
end end
...@@ -90,7 +90,7 @@ describe('Pipeline Url Component', () => { ...@@ -90,7 +90,7 @@ describe('Pipeline Url Component', () => {
expect(component.$el.querySelector('.js-pipeline-url-api').textContent).toContain('API'); expect(component.$el.querySelector('.js-pipeline-url-api').textContent).toContain('API');
}); });
it('should render latest, yaml invalid and stuck flags when provided', () => { it('should render latest, yaml invalid, merge request, and stuck flags when provided', () => {
const component = new PipelineUrlComponent({ const component = new PipelineUrlComponent({
propsData: { propsData: {
pipeline: { pipeline: {
...@@ -100,6 +100,7 @@ describe('Pipeline Url Component', () => { ...@@ -100,6 +100,7 @@ describe('Pipeline Url Component', () => {
latest: true, latest: true,
yaml_errors: true, yaml_errors: true,
stuck: true, stuck: true,
merge_request: true,
}, },
}, },
autoDevopsHelpPath: 'foo', autoDevopsHelpPath: 'foo',
...@@ -111,6 +112,10 @@ describe('Pipeline Url Component', () => { ...@@ -111,6 +112,10 @@ describe('Pipeline Url Component', () => {
'yaml invalid', 'yaml invalid',
); );
expect(component.$el.querySelector('.js-pipeline-url-mergerequest').textContent).toContain(
'merge request',
);
expect(component.$el.querySelector('.js-pipeline-url-stuck').textContent).toContain('stuck'); expect(component.$el.querySelector('.js-pipeline-url-stuck').textContent).toContain('stuck');
}); });
......
...@@ -44,7 +44,7 @@ describe PipelineEntity do ...@@ -44,7 +44,7 @@ describe PipelineEntity do
expect(subject).to include :flags expect(subject).to include :flags
expect(subject[:flags]) expect(subject[:flags])
.to include :latest, :stuck, :auto_devops, .to include :latest, :stuck, :auto_devops,
:yaml_errors, :retryable, :cancelable :yaml_errors, :retryable, :cancelable, :merge_request
end end
end end
......
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