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
Hide 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
...
@@ -25,6 +25,14 @@ module Ci
# rubocop:enable Cop/ActiveRecordSerialize
# rubocop:enable Cop/ActiveRecordSerialize
state_machine
:status
do
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
event
:manual
do
transition
all
=>
:manual
transition
all
=>
:manual
end
end
...
@@ -38,6 +46,12 @@ module Ci
...
@@ -38,6 +46,12 @@ module Ci
raise
NotImplementedError
raise
NotImplementedError
end
end
def
schedule_downstream_pipeline!
raise
InvalidBridgeTypeError
unless
downstream_project
::
Ci
::
CreateCrossProjectPipelineWorker
.
perform_async
(
self
.
id
)
end
def
inherit_status_from_downstream!
(
pipeline
)
def
inherit_status_from_downstream!
(
pipeline
)
case
pipeline
.
status
case
pipeline
.
status
when
'success'
when
'success'
...
...
app/models/commit_status_enums.rb
View file @
7add0464
...
@@ -17,7 +17,12 @@ module CommitStatusEnums
...
@@ -17,7 +17,12 @@ module CommitStatusEnums
archived_failure:
9
,
archived_failure:
9
,
unmet_prerequisites:
10
,
unmet_prerequisites:
10
,
scheduler_failure:
11
,
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
end
end
...
...
app/presenters/commit_status_presenter.rb
View file @
7add0464
...
@@ -13,7 +13,12 @@ class CommitStatusPresenter < Gitlab::View::Presenter::Delegated
...
@@ -13,7 +13,12 @@ class CommitStatusPresenter < Gitlab::View::Presenter::Delegated
archived_failure:
'The job is archived and cannot be run'
,
archived_failure:
'The job is archived and cannot be run'
,
unmet_prerequisites:
'The job failed to complete prerequisite tasks'
,
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'
,
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
}.
freeze
private_constant
:CALLOUT_FAILURE_MESSAGES
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 @@
...
@@ -531,6 +531,12 @@
:latency_sensitive:
:latency_sensitive:
:resource_boundary: :unknown
:resource_boundary: :unknown
:weight:
3
: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
-
:name: pipeline_default:ci_pipeline_bridge_status
:feature_category: :continuous_integration
:feature_category: :continuous_integration
:has_external_dependencies:
: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
...
@@ -9,14 +9,6 @@ module EE
belongs_to
:upstream_pipeline
,
class_name:
"::Ci::Pipeline"
belongs_to
:upstream_pipeline
,
class_name:
"::Ci::Pipeline"
state_machine
:status
do
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
|
after_transition
any
=>
:pending
do
|
bridge
|
next
unless
bridge
.
upstream_project
next
unless
bridge
.
upstream_project
...
@@ -27,12 +19,6 @@ module EE
...
@@ -27,12 +19,6 @@ module EE
end
end
end
end
def
schedule_downstream_pipeline!
raise
InvalidBridgeTypeError
unless
downstream_project
::
Ci
::
CreateCrossProjectPipelineWorker
.
perform_async
(
self
.
id
)
end
def
subscribe_to_upstream!
def
subscribe_to_upstream!
raise
InvalidBridgeTypeError
unless
upstream_project
raise
InvalidBridgeTypeError
unless
upstream_project
...
...
ee/app/models/ee/commit_status_enums.rb
View file @
7add0464
...
@@ -10,13 +10,8 @@ module EE
...
@@ -10,13 +10,8 @@ module EE
override
:failure_reasons
override
:failure_reasons
def
failure_reasons
def
failure_reasons
super
.
merge
(
protected_environment_failure:
1_000
,
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
,
upstream_bridge_project_not_found:
1_004
,
insufficient_upstream_permissions:
1_005
,
insufficient_upstream_permissions:
1_005
)
bridge_pipeline_is_child_pipeline:
1_006
,
downstream_pipeline_creation_failed:
1_007
)
end
end
end
end
end
end
...
...
ee/app/presenters/ee/commit_status_presenter.rb
View file @
7add0464
...
@@ -6,13 +6,8 @@ module EE
...
@@ -6,13 +6,8 @@ module EE
prepended
do
prepended
do
EE_CALLOUT_FAILURE_MESSAGES
=
const_get
(
:CALLOUT_FAILURE_MESSAGES
,
false
).
merge
(
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.'
,
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.'
,
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.'
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.'
).
freeze
).
freeze
EE
::
CommitStatusPresenter
.
private_constant
:EE_CALLOUT_FAILURE_MESSAGES
EE
::
CommitStatusPresenter
.
private_constant
:EE_CALLOUT_FAILURE_MESSAGES
...
...
ee/app/workers/all_queues.yml
View file @
7add0464
...
@@ -339,12 +339,6 @@
...
@@ -339,12 +339,6 @@
:latency_sensitive:
:latency_sensitive:
:resource_boundary: :unknown
:resource_boundary: :unknown
:weight:
1
: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
-
:name: pipeline_default:store_security_reports
:feature_category: :continuous_integration
:feature_category: :continuous_integration
:has_external_dependencies:
:has_external_dependencies:
...
...
ee/lib/ee/gitlab/ci/status/build/failed.rb
View file @
7add0464
...
@@ -11,13 +11,8 @@ module EE
...
@@ -11,13 +11,8 @@ module EE
prepended
do
prepended
do
EE_REASONS
=
const_get
(
:REASONS
,
false
).
merge
(
EE_REASONS
=
const_get
(
:REASONS
,
false
).
merge
(
protected_environment_failure:
'protected environment failure'
,
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'
,
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'
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'
).
freeze
).
freeze
EE
::
Gitlab
::
Ci
::
Status
::
Build
::
Failed
.
private_constant
:EE_REASONS
EE
::
Gitlab
::
Ci
::
Status
::
Build
::
Failed
.
private_constant
:EE_REASONS
end
end
...
...
lib/gitlab/ci/status/build/failed.rb
View file @
7add0464
...
@@ -18,7 +18,12 @@ module Gitlab
...
@@ -18,7 +18,12 @@ module Gitlab
archived_failure:
'archived failure'
,
archived_failure:
'archived failure'
,
unmet_prerequisites:
'unmet prerequisites'
,
unmet_prerequisites:
'unmet prerequisites'
,
scheduler_failure:
'scheduler failure'
,
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
}.
freeze
private_constant
:REASONS
private_constant
:REASONS
...
...
spec/models/ci/bridge_spec.rb
View file @
7add0464
...
@@ -53,6 +53,16 @@ describe Ci::Bridge do
...
@@ -53,6 +53,16 @@ describe Ci::Bridge do
end
end
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
describe
'#inherit_status_from_downstream!'
do
let
(
:downstream_pipeline
)
{
build
(
:ci_pipeline
,
status:
downstream_status
)
}
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
...
@@ -342,7 +342,9 @@ describe Ci::CreateCrossProjectPipelineService, '#execute' do
let
(
:service
)
{
described_class
.
new
(
upstream_project
,
upstream_project
.
owner
)
}
let
(
:service
)
{
described_class
.
new
(
upstream_project
,
upstream_project
.
owner
)
}
context
'that include the bridge job'
do
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
)
}
expect
{
service
.
execute
(
bridge
)
}
.
to
change
(
downstream_project
.
ci_pipelines
,
:count
).
by
(
1
)
.
to
change
(
downstream_project
.
ci_pipelines
,
:count
).
by
(
1
)
end
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