Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7add0464
Commit
7add0464
authored
Feb 10, 2020
by
Fabio Pitino
Committed by
Shinya Maeda
Feb 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port Ci::Bridge to Core
Move most of the model and specs
parent
dd5500f1
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
54 additions
and
42 deletions
+54
-42
app/models/ci/bridge.rb
app/models/ci/bridge.rb
+14
-0
app/models/commit_status_enums.rb
app/models/commit_status_enums.rb
+6
-1
app/presenters/commit_status_presenter.rb
app/presenters/commit_status_presenter.rb
+6
-1
app/services/ci/create_cross_project_pipeline_service.rb
app/services/ci/create_cross_project_pipeline_service.rb
+0
-0
app/workers/all_queues.yml
app/workers/all_queues.yml
+6
-0
app/workers/ci/create_cross_project_pipeline_worker.rb
app/workers/ci/create_cross_project_pipeline_worker.rb
+0
-0
ee/app/models/ee/ci/bridge.rb
ee/app/models/ee/ci/bridge.rb
+0
-14
ee/app/models/ee/commit_status_enums.rb
ee/app/models/ee/commit_status_enums.rb
+1
-6
ee/app/presenters/ee/commit_status_presenter.rb
ee/app/presenters/ee/commit_status_presenter.rb
+1
-6
ee/app/workers/all_queues.yml
ee/app/workers/all_queues.yml
+0
-6
ee/lib/ee/gitlab/ci/status/build/failed.rb
ee/lib/ee/gitlab/ci/status/build/failed.rb
+1
-6
lib/gitlab/ci/status/build/failed.rb
lib/gitlab/ci/status/build/failed.rb
+6
-1
spec/models/ci/bridge_spec.rb
spec/models/ci/bridge_spec.rb
+10
-0
spec/services/ci/create_cross_project_pipeline_service_spec.rb
...services/ci/create_cross_project_pipeline_service_spec.rb
+3
-1
spec/workers/ci/create_cross_project_pipeline_worker_spec.rb
spec/workers/ci/create_cross_project_pipeline_worker_spec.rb
+0
-0
No files found.
app/models/ci/bridge.rb
View file @
7add0464
...
...
@@ -25,6 +25,14 @@ module Ci
# rubocop:enable Cop/ActiveRecordSerialize
state_machine
:status
do
after_transition
created: :pending
do
|
bridge
|
next
unless
bridge
.
downstream_project
bridge
.
run_after_commit
do
bridge
.
schedule_downstream_pipeline!
end
end
event
:manual
do
transition
all
=>
:manual
end
...
...
@@ -38,6 +46,12 @@ module Ci
raise
NotImplementedError
end
def
schedule_downstream_pipeline!
raise
InvalidBridgeTypeError
unless
downstream_project
::
Ci
::
CreateCrossProjectPipelineWorker
.
perform_async
(
self
.
id
)
end
def
inherit_status_from_downstream!
(
pipeline
)
case
pipeline
.
status
when
'success'
...
...
app/models/commit_status_enums.rb
View file @
7add0464
...
...
@@ -17,7 +17,12 @@ module CommitStatusEnums
archived_failure:
9
,
unmet_prerequisites:
10
,
scheduler_failure:
11
,
data_integrity_failure:
12
data_integrity_failure:
12
,
insufficient_bridge_permissions:
1_001
,
downstream_bridge_project_not_found:
1_002
,
invalid_bridge_trigger:
1_003
,
bridge_pipeline_is_child_pipeline:
1_006
,
downstream_pipeline_creation_failed:
1_007
}
end
end
...
...
app/presenters/commit_status_presenter.rb
View file @
7add0464
...
...
@@ -13,7 +13,12 @@ class CommitStatusPresenter < Gitlab::View::Presenter::Delegated
archived_failure:
'The job is archived and cannot be run'
,
unmet_prerequisites:
'The job failed to complete prerequisite tasks'
,
scheduler_failure:
'The scheduler failed to assign job to the runner, please try again or contact system administrator'
,
data_integrity_failure:
'There has been a structural integrity problem detected, please contact system administrator'
data_integrity_failure:
'There has been a structural integrity problem detected, please contact system administrator'
,
invalid_bridge_trigger:
'This job could not be executed because downstream pipeline trigger definition is invalid'
,
downstream_bridge_project_not_found:
'This job could not be executed because downstream bridge project could not be found'
,
insufficient_bridge_permissions:
'This job could not be executed because of insufficient permissions to create a downstream pipeline'
,
bridge_pipeline_is_child_pipeline:
'This job belongs to a child pipeline and cannot create further child pipelines'
,
downstream_pipeline_creation_failed:
'The downstream pipeline could not be created'
}.
freeze
private_constant
:CALLOUT_FAILURE_MESSAGES
...
...
ee/
app/services/ci/create_cross_project_pipeline_service.rb
→
app/services/ci/create_cross_project_pipeline_service.rb
View file @
7add0464
File moved
app/workers/all_queues.yml
View file @
7add0464
...
...
@@ -531,6 +531,12 @@
:latency_sensitive:
:resource_boundary: :unknown
:weight:
3
-
:name: pipeline_default:ci_create_cross_project_pipeline
:feature_category: :continuous_integration
:has_external_dependencies:
:latency_sensitive:
:resource_boundary: :cpu
:weight:
3
-
:name: pipeline_default:ci_pipeline_bridge_status
:feature_category: :continuous_integration
:has_external_dependencies:
...
...
ee/
app/workers/ci/create_cross_project_pipeline_worker.rb
→
app/workers/ci/create_cross_project_pipeline_worker.rb
View file @
7add0464
File moved
ee/app/models/ee/ci/bridge.rb
View file @
7add0464
...
...
@@ -9,14 +9,6 @@ module EE
belongs_to
:upstream_pipeline
,
class_name:
"::Ci::Pipeline"
state_machine
:status
do
after_transition
created: :pending
do
|
bridge
|
next
unless
bridge
.
downstream_project
bridge
.
run_after_commit
do
bridge
.
schedule_downstream_pipeline!
end
end
after_transition
any
=>
:pending
do
|
bridge
|
next
unless
bridge
.
upstream_project
...
...
@@ -27,12 +19,6 @@ module EE
end
end
def
schedule_downstream_pipeline!
raise
InvalidBridgeTypeError
unless
downstream_project
::
Ci
::
CreateCrossProjectPipelineWorker
.
perform_async
(
self
.
id
)
end
def
subscribe_to_upstream!
raise
InvalidBridgeTypeError
unless
upstream_project
...
...
ee/app/models/ee/commit_status_enums.rb
View file @
7add0464
...
...
@@ -10,13 +10,8 @@ module EE
override
:failure_reasons
def
failure_reasons
super
.
merge
(
protected_environment_failure:
1_000
,
insufficient_bridge_permissions:
1_001
,
downstream_bridge_project_not_found:
1_002
,
invalid_bridge_trigger:
1_003
,
upstream_bridge_project_not_found:
1_004
,
insufficient_upstream_permissions:
1_005
,
bridge_pipeline_is_child_pipeline:
1_006
,
downstream_pipeline_creation_failed:
1_007
)
insufficient_upstream_permissions:
1_005
)
end
end
end
...
...
ee/app/presenters/ee/commit_status_presenter.rb
View file @
7add0464
...
...
@@ -6,13 +6,8 @@ module EE
prepended
do
EE_CALLOUT_FAILURE_MESSAGES
=
const_get
(
:CALLOUT_FAILURE_MESSAGES
,
false
).
merge
(
protected_environment_failure:
'The environment this job is deploying to is protected. Only users with permission may successfully run this job.'
,
insufficient_bridge_permissions:
'This job could not be executed because of insufficient permissions to create a downstream pipeline.'
,
insufficient_upstream_permissions:
'This job could not be executed because of insufficient permissions to track the upstream project.'
,
downstream_bridge_project_not_found:
'This job could not be executed because downstream bridge project could not be found.'
,
upstream_bridge_project_not_found:
'This job could not be executed because upstream bridge project could not be found.'
,
invalid_bridge_trigger:
'This job could not be executed because downstream pipeline trigger definition is invalid.'
,
bridge_pipeline_is_child_pipeline:
'This job belongs to a child pipeline and cannot create further child pipelines.'
,
downstream_pipeline_creation_failed:
'The downstream pipeline could not be created.'
upstream_bridge_project_not_found:
'This job could not be executed because upstream bridge project could not be found.'
).
freeze
EE
::
CommitStatusPresenter
.
private_constant
:EE_CALLOUT_FAILURE_MESSAGES
...
...
ee/app/workers/all_queues.yml
View file @
7add0464
...
...
@@ -339,12 +339,6 @@
:latency_sensitive:
:resource_boundary: :unknown
:weight:
1
-
:name: pipeline_default:ci_create_cross_project_pipeline
:feature_category: :continuous_integration
:has_external_dependencies:
:latency_sensitive:
:resource_boundary: :cpu
:weight:
3
-
:name: pipeline_default:store_security_reports
:feature_category: :continuous_integration
:has_external_dependencies:
...
...
ee/lib/ee/gitlab/ci/status/build/failed.rb
View file @
7add0464
...
...
@@ -11,13 +11,8 @@ module EE
prepended
do
EE_REASONS
=
const_get
(
:REASONS
,
false
).
merge
(
protected_environment_failure:
'protected environment failure'
,
invalid_bridge_trigger:
'downstream pipeline trigger definition is invalid'
,
downstream_bridge_project_not_found:
'downstream project could not be found'
,
upstream_bridge_project_not_found:
'upstream project could not be found'
,
insufficient_bridge_permissions:
'no permissions to trigger downstream pipeline'
,
insufficient_upstream_permissions:
'no permissions to read upstream project'
,
bridge_pipeline_is_child_pipeline:
'creation of child pipeline not allowed from another child pipeline'
,
downstream_pipeline_creation_failed:
'downstream pipeline can not be created'
insufficient_upstream_permissions:
'no permissions to read upstream project'
).
freeze
EE
::
Gitlab
::
Ci
::
Status
::
Build
::
Failed
.
private_constant
:EE_REASONS
end
...
...
lib/gitlab/ci/status/build/failed.rb
View file @
7add0464
...
...
@@ -18,7 +18,12 @@ module Gitlab
archived_failure:
'archived failure'
,
unmet_prerequisites:
'unmet prerequisites'
,
scheduler_failure:
'scheduler failure'
,
data_integrity_failure:
'data integrity failure'
data_integrity_failure:
'data integrity failure'
,
invalid_bridge_trigger:
'downstream pipeline trigger definition is invalid'
,
downstream_bridge_project_not_found:
'downstream project could not be found'
,
insufficient_bridge_permissions:
'no permissions to trigger downstream pipeline'
,
bridge_pipeline_is_child_pipeline:
'creation of child pipeline not allowed from another child pipeline'
,
downstream_pipeline_creation_failed:
'downstream pipeline can not be created'
}.
freeze
private_constant
:REASONS
...
...
spec/models/ci/bridge_spec.rb
View file @
7add0464
...
...
@@ -53,6 +53,16 @@ describe Ci::Bridge do
end
end
describe
'state machine transitions'
do
context
'when bridge points towards downstream'
do
it
'schedules downstream pipeline creation'
do
expect
(
bridge
).
to
receive
(
:schedule_downstream_pipeline!
)
bridge
.
enqueue!
end
end
end
describe
'#inherit_status_from_downstream!'
do
let
(
:downstream_pipeline
)
{
build
(
:ci_pipeline
,
status:
downstream_status
)
}
...
...
ee/
spec/services/ci/create_cross_project_pipeline_service_spec.rb
→
spec/services/ci/create_cross_project_pipeline_service_spec.rb
View file @
7add0464
...
...
@@ -342,7 +342,9 @@ describe Ci::CreateCrossProjectPipelineService, '#execute' do
let
(
:service
)
{
described_class
.
new
(
upstream_project
,
upstream_project
.
owner
)
}
context
'that include the bridge job'
do
it
'creates the downstream pipeline'
do
# TODO: this is skipped because `trigger` keyword does not exist yet.
# enabling it in the next MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/24393
xit
'creates the downstream pipeline'
do
expect
{
service
.
execute
(
bridge
)
}
.
to
change
(
downstream_project
.
ci_pipelines
,
:count
).
by
(
1
)
end
...
...
ee/
spec/workers/ci/create_cross_project_pipeline_worker_spec.rb
→
spec/workers/ci/create_cross_project_pipeline_worker_spec.rb
View file @
7add0464
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment