Commit d4ca3717 authored by Fabio Pitino's avatar Fabio Pitino

Merge branch '281878-fix-not-skipped-manual-and-delayed-DAG-jobs' into 'master'

Fix not skipped manual and delayed DAG jobs

See merge request gitlab-org/gitlab!50765
parents 07ce676b 73e996ab
......@@ -26,6 +26,27 @@ module Ci
end
def valid_statuses_for_build(build)
if ::Feature.enabled?(:skip_dag_manual_and_delayed_jobs, default_enabled: :yaml)
current_valid_statuses_for_build(build)
else
legacy_valid_statuses_for_build(build)
end
end
def current_valid_statuses_for_build(build)
case build.when
when 'on_success', 'manual', 'delayed'
build.scheduling_type_dag? ? %w[success] : %w[success skipped]
when 'on_failure'
%w[failed]
when 'always'
%w[success failed skipped]
else
[]
end
end
def legacy_valid_statuses_for_build(build)
case build.when
when 'on_success'
build.scheduling_type_dag? ? %w[success] : %w[success skipped]
......
---
name: skip_dag_manual_and_delayed_jobs
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/50765
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/297240
milestone: '13.8'
type: development
group: group::pipeline authoring
default_enabled: false
config:
build:
stage: build
script: exit 1
test:
stage: test
script: exit 0
deploy:
stage: deploy
script: exit 0
when: delayed
start_in: 5 seconds
needs: [test]
init:
expect:
pipeline: pending
stages:
build: pending
test: created
deploy: created
jobs:
build: pending
test: created
deploy: created
transitions:
- event: drop
jobs: [build]
expect:
pipeline: failed
stages:
build: failed
test: skipped
deploy: skipped
jobs:
build: failed
test: skipped
deploy: skipped
config:
build:
stage: build
script: exit 1
test:
stage: test
script: exit 0
deploy:
stage: deploy
script: exit 0
when: manual
needs: [test]
init:
expect:
pipeline: pending
stages:
build: pending
test: created
deploy: created
jobs:
build: pending
test: created
deploy: created
transitions:
- event: drop
jobs: [build]
expect:
pipeline: failed
stages:
build: failed
test: skipped
deploy: skipped
jobs:
build: failed
test: skipped
deploy: skipped
......@@ -124,24 +124,46 @@ RSpec.describe Ci::ProcessBuildService, '#execute' do
end
context 'when build is scheduled with DAG' do
using RSpec::Parameterized::TableSyntax
let(:pipeline) { create(:ci_pipeline, ref: 'master', project: project) }
let!(:build) { create(:ci_build, :created, when: :on_success, pipeline: pipeline, scheduling_type: :dag) }
let!(:build) { create(:ci_build, :created, when: build_when, pipeline: pipeline, scheduling_type: :dag) }
let!(:other_build) { create(:ci_build, :created, when: :on_success, pipeline: pipeline) }
let!(:build_on_other_build) { create(:ci_build_need, build: build, name: other_build.name) }
context 'when current status is success' do
let(:current_status) { 'success' }
where(:build_when, :current_status, :after_status) do
:on_success | 'success' | 'pending'
:on_success | 'skipped' | 'skipped'
:manual | 'success' | 'manual'
:manual | 'skipped' | 'skipped'
:delayed | 'success' | 'manual'
:delayed | 'skipped' | 'skipped'
end
it 'enqueues the build' do
expect { subject }.to change { build.status }.to('pending')
with_them do
it 'proceeds the build' do
expect { subject }.to change { build.status }.to(after_status)
end
end
context 'when current status is skipped' do
let(:current_status) { 'skipped' }
context 'when FF skip_dag_manual_and_delayed_jobs is disabled' do
before do
stub_feature_flags(skip_dag_manual_and_delayed_jobs: false)
end
it 'skips the build' do
expect { subject }.to change { build.status }.to('skipped')
where(:build_when, :current_status, :after_status) do
:on_success | 'success' | 'pending'
:on_success | 'skipped' | 'skipped'
:manual | 'success' | 'manual'
:manual | 'skipped' | 'manual'
:delayed | 'success' | 'manual'
:delayed | 'skipped' | 'manual'
end
with_them do
it 'proceeds the build' do
expect { subject }.to change { build.status }.to(after_status)
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