Commit d63a3173 authored by Balasankar 'Balu' C's avatar Balasankar 'Balu' C Committed by Mayra Cabrera

[RUN AS-IF-FOSS] [RUN ALL RSPEC] Allow pipelines to be filtered by source

parent 8e68c45c
...@@ -39,7 +39,7 @@ export default { ...@@ -39,7 +39,7 @@ export default {
return this.value.map((i) => i.type); return this.value.map((i) => i.type);
}, },
tokens() { tokens() {
const tokens = [ return [
{ {
type: this.$options.userType, type: this.$options.userType,
icon: 'user', icon: 'user',
...@@ -77,20 +77,15 @@ export default { ...@@ -77,20 +77,15 @@ export default {
token: PipelineStatusToken, token: PipelineStatusToken,
operators: OPERATOR_IS_ONLY, operators: OPERATOR_IS_ONLY,
}, },
]; {
if (gon.features.pipelineSourceFilter) {
tokens.push({
type: this.$options.sourceType, type: this.$options.sourceType,
icon: 'trigger-source', icon: 'trigger-source',
title: s__('Pipeline|Source'), title: s__('Pipeline|Source'),
unique: true, unique: true,
token: PipelineSourceToken, token: PipelineSourceToken,
operators: OPERATOR_IS_ONLY, operators: OPERATOR_IS_ONLY,
}); },
} ];
return tokens;
}, },
parsedParams() { parsedParams() {
return map(this.params, (val, key) => ({ return map(this.params, (val, key) => ({
......
...@@ -14,10 +14,6 @@ class Projects::PipelinesController < Projects::ApplicationController ...@@ -14,10 +14,6 @@ class Projects::PipelinesController < Projects::ApplicationController
before_action :authorize_update_pipeline!, only: [:retry, :cancel] before_action :authorize_update_pipeline!, only: [:retry, :cancel]
before_action :ensure_pipeline, only: [:show, :downloadable_artifacts] before_action :ensure_pipeline, only: [:show, :downloadable_artifacts]
before_action do
push_frontend_feature_flag(:pipeline_source_filter, project, type: :development, default_enabled: :yaml)
end
# Will be removed with https://gitlab.com/gitlab-org/gitlab/-/issues/225596 # Will be removed with https://gitlab.com/gitlab-org/gitlab/-/issues/225596
before_action :redirect_for_legacy_scope_filter, only: [:index], if: -> { request.format.html? } before_action :redirect_for_legacy_scope_filter, only: [:index], if: -> { request.format.html? }
...@@ -297,10 +293,7 @@ class Projects::PipelinesController < Projects::ApplicationController ...@@ -297,10 +293,7 @@ class Projects::PipelinesController < Projects::ApplicationController
end end
def index_params def index_params
permitted_params = [:scope, :username, :ref, :status] params.permit(:scope, :username, :ref, :status, :source)
permitted_params << :source if Feature.enabled?(:pipeline_source_filter, project, default_enabled: :yaml)
params.permit(*permitted_params)
end end
def enable_code_quality_walkthrough_experiment def enable_code_quality_walkthrough_experiment
......
...@@ -29,8 +29,7 @@ module Ci ...@@ -29,8 +29,7 @@ module Ci
items = by_username(items) items = by_username(items)
items = by_yaml_errors(items) items = by_yaml_errors(items)
items = by_updated_at(items) items = by_updated_at(items)
items = by_source(items)
items = by_source(items) if Feature.enabled?(:pipeline_source_filter, project, default_enabled: :yaml)
sort_items(items) sort_items(items)
end end
......
---
name: pipeline_source_filter
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/67846
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/338347
milestone: '14.2'
type: development
group: group::pipeline execution
default_enabled: false
...@@ -32,6 +32,7 @@ GET /projects/:id/pipelines ...@@ -32,6 +32,7 @@ GET /projects/:id/pipelines
| `id` | integer/string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user | | `id` | integer/string | yes | The ID or [URL-encoded path of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
| `scope` | string | no | The scope of pipelines, one of: `running`, `pending`, `finished`, `branches`, `tags` | | `scope` | string | no | The scope of pipelines, one of: `running`, `pending`, `finished`, `branches`, `tags` |
| `status` | string | no | The status of pipelines, one of: `created`, `waiting_for_resource`, `preparing`, `pending`, `running`, `success`, `failed`, `canceled`, `skipped`, `manual`, `scheduled` | | `status` | string | no | The status of pipelines, one of: `created`, `waiting_for_resource`, `preparing`, `pending`, `running`, `success`, `failed`, `canceled`, `skipped`, `manual`, `scheduled` |
| `source` | string | no | In [GitLab 14.3 and later](https://gitlab.com/gitlab-org/gitlab/-/issues/325439), how the pipeline was triggered, one of: `push`, `web`, `trigger`, `schedule`, `api`, `external`, `pipeline`, `chat`, `webide`, `merge_request_event`, `external_pull_request_event`, `parent_pipeline`, `ondemand_dast_scan`, or `ondemand_dast_validation`. |
| `ref` | string | no | The ref of pipelines | | `ref` | string | no | The ref of pipelines |
| `sha` | string | no | The SHA of pipelines | | `sha` | string | no | The SHA of pipelines |
| `yaml_errors`| boolean | no | Returns pipelines with invalid configurations | | `yaml_errors`| boolean | no | Returns pipelines with invalid configurations |
...@@ -55,6 +56,7 @@ Example of response ...@@ -55,6 +56,7 @@ Example of response
"iid": 12, "iid": 12,
"project_id": 1, "project_id": 1,
"status": "pending", "status": "pending",
"soure": "push",
"ref": "new-pipeline", "ref": "new-pipeline",
"sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a", "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
"web_url": "https://example.com/foo/bar/pipelines/47", "web_url": "https://example.com/foo/bar/pipelines/47",
...@@ -66,6 +68,7 @@ Example of response ...@@ -66,6 +68,7 @@ Example of response
"iid": 13, "iid": 13,
"project_id": 1, "project_id": 1,
"status": "pending", "status": "pending",
"soure": "web",
"ref": "new-pipeline", "ref": "new-pipeline",
"sha": "eb94b618fb5865b26e80fdd8ae531b7a63ad851a", "sha": "eb94b618fb5865b26e80fdd8ae531b7a63ad851a",
"web_url": "https://example.com/foo/bar/pipelines/48", "web_url": "https://example.com/foo/bar/pipelines/48",
......
...@@ -122,6 +122,7 @@ you can filter the pipeline list by: ...@@ -122,6 +122,7 @@ you can filter the pipeline list by:
- Branch name - Branch name
- Status ([GitLab 13.1 and later](https://gitlab.com/gitlab-org/gitlab/-/issues/217617)) - Status ([GitLab 13.1 and later](https://gitlab.com/gitlab-org/gitlab/-/issues/217617))
- Tag ([GitLab 13.1 and later](https://gitlab.com/gitlab-org/gitlab/-/issues/217617)) - Tag ([GitLab 13.1 and later](https://gitlab.com/gitlab-org/gitlab/-/issues/217617))
- Source ([GitLab 14.3 and later](https://gitlab.com/gitlab-org/gitlab/-/issues/338347))
[Starting in GitLab 14.2](https://gitlab.com/gitlab-org/gitlab/-/issues/26621), you can change the [Starting in GitLab 14.2](https://gitlab.com/gitlab-org/gitlab/-/issues/26621), you can change the
pipeline column to display the pipeline ID or the pipeline IID. pipeline column to display the pipeline ID or the pipeline IID.
......
...@@ -4,11 +4,9 @@ module API ...@@ -4,11 +4,9 @@ module API
module Entities module Entities
module Ci module Ci
class PipelineBasic < Grape::Entity class PipelineBasic < Grape::Entity
expose :id, :project_id, :sha, :ref, :status expose :id, :project_id, :sha, :ref, :status, :source
expose :created_at, :updated_at expose :created_at, :updated_at
expose :source, if: ->(pipeline, options) { ::Feature.enabled?(:pipeline_source_filter, options[:project], default_enabled: :yaml) }
expose :web_url do |pipeline, _options| expose :web_url do |pipeline, _options|
Gitlab::Routing.url_helpers.project_pipeline_url(pipeline.project, pipeline) Gitlab::Routing.url_helpers.project_pipeline_url(pipeline.project, pipeline)
end end
......
...@@ -258,22 +258,10 @@ RSpec.describe Ci::PipelinesFinder do ...@@ -258,22 +258,10 @@ RSpec.describe Ci::PipelinesFinder do
let!(:push_pipeline) { create(:ci_pipeline, project: project, source: 'push') } let!(:push_pipeline) { create(:ci_pipeline, project: project, source: 'push') }
let!(:api_pipeline) { create(:ci_pipeline, project: project, source: 'api') } let!(:api_pipeline) { create(:ci_pipeline, project: project, source: 'api') }
context 'when `pipeline_source_filter` feature flag is disabled' do
before do
stub_feature_flags(pipeline_source_filter: false)
end
it 'returns all the pipelines' do
is_expected.to contain_exactly(web_pipeline, push_pipeline, api_pipeline)
end
end
context 'when `pipeline_source_filter` feature flag is enabled' do
it 'returns only the matched pipeline' do it 'returns only the matched pipeline' do
is_expected.to eq([web_pipeline]) is_expected.to eq([web_pipeline])
end end
end end
end
describe 'ordering' do describe 'ordering' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
......
...@@ -33,8 +33,6 @@ describe('Pipelines filtered search', () => { ...@@ -33,8 +33,6 @@ describe('Pipelines filtered search', () => {
}; };
beforeEach(() => { beforeEach(() => {
window.gon = { features: { pipelineSourceFilter: true } };
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
jest.spyOn(Api, 'projectUsers').mockResolvedValue(users); jest.spyOn(Api, 'projectUsers').mockResolvedValue(users);
......
...@@ -105,8 +105,6 @@ describe('Pipelines', () => { ...@@ -105,8 +105,6 @@ describe('Pipelines', () => {
}); });
beforeEach(() => { beforeEach(() => {
window.gon = { features: { pipelineSourceFilter: true } };
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
jest.spyOn(window.history, 'pushState'); jest.spyOn(window.history, 'pushState');
......
...@@ -37,26 +37,12 @@ RSpec.describe API::Ci::Pipelines do ...@@ -37,26 +37,12 @@ RSpec.describe API::Ci::Pipelines do
end end
describe 'keys in the response' do describe 'keys in the response' do
context 'when `pipeline_source_filter` feature flag is disabled' do
before do
stub_feature_flags(pipeline_source_filter: false)
end
it 'does not includes pipeline source' do
get api("/projects/#{project.id}/pipelines", user)
expect(json_response.first.keys).to contain_exactly(*%w[id project_id sha ref status web_url created_at updated_at])
end
end
context 'when `pipeline_source_filter` feature flag is disabled' do
it 'includes pipeline source' do it 'includes pipeline source' do
get api("/projects/#{project.id}/pipelines", user) get api("/projects/#{project.id}/pipelines", user)
expect(json_response.first.keys).to contain_exactly(*%w[id project_id sha ref status web_url created_at updated_at source]) expect(json_response.first.keys).to contain_exactly(*%w[id project_id sha ref status web_url created_at updated_at source])
end end
end end
end
context 'when parameter is passed' do context 'when parameter is passed' do
%w[running pending].each do |target| %w[running pending].each do |target|
...@@ -323,22 +309,6 @@ RSpec.describe API::Ci::Pipelines do ...@@ -323,22 +309,6 @@ RSpec.describe API::Ci::Pipelines do
create(:ci_pipeline, project: project, source: :api) create(:ci_pipeline, project: project, source: :api)
end end
context 'when `pipeline_source_filter` feature flag is disabled' do
before do
stub_feature_flags(pipeline_source_filter: false)
end
it 'returns all pipelines' do
get api("/projects/#{project.id}/pipelines", user), params: { source: 'web' }
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).not_to be_empty
expect(json_response.length).to be >= 3
end
end
context 'when `pipeline_source_filter` feature flag is enabled' do
it 'returns matched pipelines' do it 'returns matched pipelines' do
get api("/projects/#{project.id}/pipelines", user), params: { source: 'web' } get api("/projects/#{project.id}/pipelines", user), params: { source: 'web' }
...@@ -358,7 +328,6 @@ RSpec.describe API::Ci::Pipelines do ...@@ -358,7 +328,6 @@ RSpec.describe API::Ci::Pipelines do
end end
end end
end end
end
context 'unauthorized user' do context 'unauthorized user' do
it 'does not return project pipelines' do it 'does not return project pipelines' 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