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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
021d3810
Commit
021d3810
authored
Jun 02, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Ci::Commit to Ci::Pipeline and rename some of the ci_commit to pipeline
parent
5accd87a
Changes
35
Hide whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
81 additions
and
81 deletions
+81
-81
app/controllers/projects/builds_controller.rb
app/controllers/projects/builds_controller.rb
+2
-2
app/controllers/projects/commit_controller.rb
app/controllers/projects/commit_controller.rb
+1
-1
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+11
-11
app/controllers/projects/pipelines_controller.rb
app/controllers/projects/pipelines_controller.rb
+3
-3
app/models/ci/build.rb
app/models/ci/build.rb
+6
-6
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+2
-2
app/models/ci/trigger_request.rb
app/models/ci/trigger_request.rb
+1
-1
app/models/commit.rb
app/models/commit.rb
+3
-3
app/models/commit_status.rb
app/models/commit_status.rb
+4
-4
app/models/merge_request.rb
app/models/merge_request.rb
+2
-2
app/models/project.rb
app/models/project.rb
+5
-5
app/services/ci/create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+2
-2
app/services/ci/create_trigger_request_service.rb
app/services/ci/create_trigger_request_service.rb
+1
-1
app/services/ci/image_for_build_service.rb
app/services/ci/image_for_build_service.rb
+1
-1
app/services/create_commit_builds_service.rb
app/services/create_commit_builds_service.rb
+1
-1
app/services/merge_requests/base_service.rb
app/services/merge_requests/base_service.rb
+4
-4
features/steps/project/commits/commits.rb
features/steps/project/commits/commits.rb
+1
-1
lib/api/commit_statuses.rb
lib/api/commit_statuses.rb
+1
-1
lib/api/merge_requests.rb
lib/api/merge_requests.rb
+1
-1
lib/ci/charts.rb
lib/ci/charts.rb
+1
-1
spec/factories/ci/commits.rb
spec/factories/ci/commits.rb
+1
-1
spec/features/pipelines_spec.rb
spec/features/pipelines_spec.rb
+1
-1
spec/helpers/ci_status_helper_spec.rb
spec/helpers/ci_status_helper_spec.rb
+2
-2
spec/helpers/merge_requests_helper_spec.rb
spec/helpers/merge_requests_helper_spec.rb
+1
-1
spec/models/ci/commit_spec.rb
spec/models/ci/commit_spec.rb
+1
-1
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+2
-2
spec/models/project_spec.rb
spec/models/project_spec.rb
+1
-1
spec/requests/api/commit_statuses_spec.rb
spec/requests/api/commit_statuses_spec.rb
+2
-2
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+2
-2
spec/requests/api/triggers_spec.rb
spec/requests/api/triggers_spec.rb
+1
-1
spec/requests/ci/api/triggers_spec.rb
spec/requests/ci/api/triggers_spec.rb
+1
-1
spec/services/create_commit_builds_service_spec.rb
spec/services/create_commit_builds_service_spec.rb
+7
-7
spec/services/merge_requests/merge_when_build_succeeds_service_spec.rb
.../merge_requests/merge_when_build_succeeds_service_spec.rb
+1
-1
spec/support/stub_gitlab_calls.rb
spec/support/stub_gitlab_calls.rb
+1
-1
spec/workers/post_receive_spec.rb
spec/workers/post_receive_spec.rb
+4
-4
No files found.
app/controllers/projects/builds_controller.rb
View file @
021d3810
...
@@ -26,9 +26,9 @@ class Projects::BuildsController < Projects::ApplicationController
...
@@ -26,9 +26,9 @@ class Projects::BuildsController < Projects::ApplicationController
end
end
def
show
def
show
@builds
=
@project
.
ci_commit
s
.
find_by_sha
(
@build
.
sha
).
builds
.
order
(
'id DESC'
)
@builds
=
@project
.
pipeline
s
.
find_by_sha
(
@build
.
sha
).
builds
.
order
(
'id DESC'
)
@builds
=
@builds
.
where
(
"id not in (?)"
,
@build
.
id
)
@builds
=
@builds
.
where
(
"id not in (?)"
,
@build
.
id
)
@
commit
=
@build
.
commit
@
pipeline
=
@build
.
pipeline
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
...
...
app/controllers/projects/commit_controller.rb
View file @
021d3810
...
@@ -100,7 +100,7 @@ class Projects::CommitController < Projects::ApplicationController
...
@@ -100,7 +100,7 @@ class Projects::CommitController < Projects::ApplicationController
end
end
def
ci_commits
def
ci_commits
@ci_commits
||=
project
.
ci_commit
s
.
where
(
sha:
commit
.
sha
)
@ci_commits
||=
project
.
pipeline
s
.
where
(
sha:
commit
.
sha
)
end
end
def
ci_builds
def
ci_builds
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
021d3810
...
@@ -119,8 +119,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -119,8 +119,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@diffs
=
@merge_request
.
compare
.
diffs
(
diff_options
)
if
@merge_request
.
compare
@diffs
=
@merge_request
.
compare
.
diffs
(
diff_options
)
if
@merge_request
.
compare
@diff_notes_disabled
=
true
@diff_notes_disabled
=
true
@
ci_commit
=
@merge_request
.
ci_commit
@
pipeline
=
@merge_request
.
pipeline
@statuses
=
@
ci_commit
.
statuses
if
@ci_commit
@statuses
=
@
pipeline
.
statuses
if
@pipeline
@note_counts
=
Note
.
where
(
commit_id:
@commits
.
map
(
&
:id
)).
@note_counts
=
Note
.
where
(
commit_id:
@commits
.
map
(
&
:id
)).
group
(
:commit_id
).
count
group
(
:commit_id
).
count
...
@@ -194,7 +194,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -194,7 +194,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request
.
update
(
merge_error:
nil
)
@merge_request
.
update
(
merge_error:
nil
)
if
params
[
:merge_when_build_succeeds
].
present?
&&
@merge_request
.
ci_commit
&&
@merge_request
.
ci_commit
.
active?
if
params
[
:merge_when_build_succeeds
].
present?
&&
@merge_request
.
pipeline
&&
@merge_request
.
pipeline
.
active?
MergeRequests
::
MergeWhenBuildSucceedsService
.
new
(
@project
,
current_user
,
merge_params
)
MergeRequests
::
MergeWhenBuildSucceedsService
.
new
(
@project
,
current_user
,
merge_params
)
.
execute
(
@merge_request
)
.
execute
(
@merge_request
)
@status
=
:merge_when_build_succeeds
@status
=
:merge_when_build_succeeds
...
@@ -225,10 +225,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -225,10 +225,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
end
def
ci_status
def
ci_status
ci_commit
=
@merge_request
.
ci_commit
pipeline
=
@merge_request
.
pipeline
if
ci_commit
if
pipeline
status
=
ci_commit
.
status
status
=
pipeline
.
status
coverage
=
ci_commit
.
try
(
:coverage
)
coverage
=
pipeline
.
try
(
:coverage
)
status
||=
"preparing"
status
||=
"preparing"
else
else
...
@@ -310,8 +310,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -310,8 +310,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request_diff
=
@merge_request
.
merge_request_diff
@merge_request_diff
=
@merge_request
.
merge_request_diff
@
ci_commit
=
@merge_request
.
ci_commit
@
pipeline
=
@merge_request
.
pipeline
@statuses
=
@ci_commit
.
statuses
if
@
ci_commit
@statuses
=
@ci_commit
.
statuses
if
@
pipeline
if
@merge_request
.
locked_long_ago?
if
@merge_request
.
locked_long_ago?
@merge_request
.
unlock_mr
@merge_request
.
unlock_mr
...
@@ -320,8 +320,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
...
@@ -320,8 +320,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
end
def
define_widget_vars
def
define_widget_vars
@
ci_commit
=
@merge_request
.
ci_commit
@
pipeline
=
@merge_request
.
pipeline
@
ci_commits
=
[
@ci_commit
].
compact
@
pipelines
=
[
@pipeline
].
compact
closes_issues
closes_issues
end
end
...
...
app/controllers/projects/pipelines_controller.rb
View file @
021d3810
...
@@ -7,7 +7,7 @@ class Projects::PipelinesController < Projects::ApplicationController
...
@@ -7,7 +7,7 @@ class Projects::PipelinesController < Projects::ApplicationController
def
index
def
index
@scope
=
params
[
:scope
]
@scope
=
params
[
:scope
]
all_pipelines
=
project
.
ci_commit
s
all_pipelines
=
project
.
pipeline
s
@pipelines_count
=
all_pipelines
.
count
@pipelines_count
=
all_pipelines
.
count
@running_or_pending_count
=
all_pipelines
.
running_or_pending
.
count
@running_or_pending_count
=
all_pipelines
.
running_or_pending
.
count
@pipelines
=
PipelinesFinder
.
new
(
project
).
execute
(
all_pipelines
,
@scope
)
@pipelines
=
PipelinesFinder
.
new
(
project
).
execute
(
all_pipelines
,
@scope
)
...
@@ -15,7 +15,7 @@ class Projects::PipelinesController < Projects::ApplicationController
...
@@ -15,7 +15,7 @@ class Projects::PipelinesController < Projects::ApplicationController
end
end
def
new
def
new
@pipeline
=
project
.
ci_commit
s
.
new
(
ref:
@project
.
default_branch
)
@pipeline
=
project
.
pipeline
s
.
new
(
ref:
@project
.
default_branch
)
end
end
def
create
def
create
...
@@ -50,7 +50,7 @@ class Projects::PipelinesController < Projects::ApplicationController
...
@@ -50,7 +50,7 @@ class Projects::PipelinesController < Projects::ApplicationController
end
end
def
pipeline
def
pipeline
@pipeline
||=
project
.
ci_commit
s
.
find_by!
(
id:
params
[
:id
])
@pipeline
||=
project
.
pipeline
s
.
find_by!
(
id:
params
[
:id
])
end
end
def
commit
def
commit
...
...
app/models/ci/build.rb
View file @
021d3810
...
@@ -45,8 +45,8 @@ module Ci
...
@@ -45,8 +45,8 @@ module Ci
new_build
.
options
=
build
.
options
new_build
.
options
=
build
.
options
new_build
.
commands
=
build
.
commands
new_build
.
commands
=
build
.
commands
new_build
.
tag_list
=
build
.
tag_list
new_build
.
tag_list
=
build
.
tag_list
new_build
.
gl_project_id
=
build
.
gl_project_id
new_build
.
project
=
build
.
project
new_build
.
commit_id
=
build
.
commit_id
new_build
.
pipeline
=
build
.
pipeline
new_build
.
name
=
build
.
name
new_build
.
name
=
build
.
name
new_build
.
allow_failure
=
build
.
allow_failure
new_build
.
allow_failure
=
build
.
allow_failure
new_build
.
stage
=
build
.
stage
new_build
.
stage
=
build
.
stage
...
@@ -66,7 +66,7 @@ module Ci
...
@@ -66,7 +66,7 @@ module Ci
# We use around_transition to create builds for next stage as soon as possible, before the `after_*` is executed
# We use around_transition to create builds for next stage as soon as possible, before the `after_*` is executed
around_transition
any
=>
[
:success
,
:failed
,
:canceled
]
do
|
build
,
block
|
around_transition
any
=>
[
:success
,
:failed
,
:canceled
]
do
|
build
,
block
|
block
.
call
block
.
call
build
.
commit
.
create_next_builds
(
build
)
if
build
.
commit
build
.
pipeline
.
create_next_builds
(
build
)
if
build
.
pipeline
end
end
after_transition
any
=>
[
:success
,
:failed
,
:canceled
]
do
|
build
|
after_transition
any
=>
[
:success
,
:failed
,
:canceled
]
do
|
build
|
...
@@ -80,7 +80,7 @@ module Ci
...
@@ -80,7 +80,7 @@ module Ci
end
end
def
retried?
def
retried?
!
self
.
commit
.
statuses
.
latest
.
include?
(
self
)
!
self
.
pipeline
.
statuses
.
latest
.
include?
(
self
)
end
end
def
retry
def
retry
...
@@ -89,7 +89,7 @@ module Ci
...
@@ -89,7 +89,7 @@ module Ci
def
depends_on_builds
def
depends_on_builds
# Get builds of the same type
# Get builds of the same type
latest_builds
=
self
.
commit
.
builds
.
latest
latest_builds
=
self
.
pipeline
.
builds
.
latest
# Return builds from previous stages
# Return builds from previous stages
latest_builds
.
where
(
'stage_idx < ?'
,
stage_idx
)
latest_builds
.
where
(
'stage_idx < ?'
,
stage_idx
)
...
@@ -114,7 +114,7 @@ module Ci
...
@@ -114,7 +114,7 @@ module Ci
def
merge_request
def
merge_request
merge_requests
=
MergeRequest
.
includes
(
:merge_request_diff
)
merge_requests
=
MergeRequest
.
includes
(
:merge_request_diff
)
.
where
(
source_branch:
ref
,
source_project_id:
commit
.
gl_project_id
)
.
where
(
source_branch:
ref
,
source_project_id:
pipeline
.
gl_project_id
)
.
reorder
(
iid: :asc
)
.
reorder
(
iid: :asc
)
merge_requests
.
find
do
|
merge_request
|
merge_requests
.
find
do
|
merge_request
|
...
...
app/models/ci/
commit
.rb
→
app/models/ci/
pipeline
.rb
View file @
021d3810
module
Ci
module
Ci
class
Commit
<
ActiveRecord
::
Base
class
Pipeline
<
ActiveRecord
::
Base
extend
Ci
::
Model
extend
Ci
::
Model
include
Statuseable
include
Statuseable
...
@@ -47,7 +47,7 @@ module Ci
...
@@ -47,7 +47,7 @@ module Ci
end
end
def
short_sha
def
short_sha
Ci
::
Commit
.
truncate_sha
(
sha
)
Ci
::
Pipeline
.
truncate_sha
(
sha
)
end
end
def
commit_data
def
commit_data
...
...
app/models/ci/trigger_request.rb
View file @
021d3810
...
@@ -3,7 +3,7 @@ module Ci
...
@@ -3,7 +3,7 @@ module Ci
extend
Ci
::
Model
extend
Ci
::
Model
belongs_to
:trigger
,
class_name:
'Ci::Trigger'
belongs_to
:trigger
,
class_name:
'Ci::Trigger'
belongs_to
:commit
,
class_name:
'Ci::
Commit
'
belongs_to
:commit
,
class_name:
'Ci::
Pipeline
'
has_many
:builds
,
class_name:
'Ci::Build'
has_many
:builds
,
class_name:
'Ci::Build'
serialize
:variables
serialize
:variables
...
...
app/models/commit.rb
View file @
021d3810
...
@@ -214,13 +214,13 @@ class Commit
...
@@ -214,13 +214,13 @@ class Commit
@raw
.
short_id
(
7
)
@raw
.
short_id
(
7
)
end
end
def
ci_commit
s
def
pipeline
s
@
ci_commits
||=
project
.
ci_commit
s
.
where
(
sha:
sha
)
@
pipeline
||=
project
.
pipeline
s
.
where
(
sha:
sha
)
end
end
def
status
def
status
return
@status
if
defined?
(
@status
)
return
@status
if
defined?
(
@status
)
@status
||=
ci_commit
s
.
status
@status
||=
pipeline
s
.
status
end
end
def
revert_branch_name
def
revert_branch_name
...
...
app/models/commit_status.rb
View file @
021d3810
...
@@ -4,10 +4,10 @@ class CommitStatus < ActiveRecord::Base
...
@@ -4,10 +4,10 @@ class CommitStatus < ActiveRecord::Base
self
.
table_name
=
'ci_builds'
self
.
table_name
=
'ci_builds'
belongs_to
:project
,
class_name:
'::Project'
,
foreign_key: :gl_project_id
belongs_to
:project
,
class_name:
'::Project'
,
foreign_key: :gl_project_id
belongs_to
:
commit
,
class_name:
'Ci::Commit'
,
touch:
true
belongs_to
:
pipeline
,
class_name:
'Ci::Pipeline'
,
foreign_key: :commit_id
,
touch:
true
belongs_to
:user
belongs_to
:user
validates
:
commit
,
presence:
true
validates
:
pipeline
,
presence:
true
validates_presence_of
:name
validates_presence_of
:name
...
@@ -44,11 +44,11 @@ class CommitStatus < ActiveRecord::Base
...
@@ -44,11 +44,11 @@ class CommitStatus < ActiveRecord::Base
end
end
after_transition
[
:pending
,
:running
]
=>
:success
do
|
commit_status
|
after_transition
[
:pending
,
:running
]
=>
:success
do
|
commit_status
|
MergeRequests
::
MergeWhenBuildSucceedsService
.
new
(
commit_status
.
commit
.
project
,
nil
).
trigger
(
commit_status
)
MergeRequests
::
MergeWhenBuildSucceedsService
.
new
(
commit_status
.
pipeline
.
project
,
nil
).
trigger
(
commit_status
)
end
end
after_transition
any
=>
:failed
do
|
commit_status
|
after_transition
any
=>
:failed
do
|
commit_status
|
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
commit_status
.
commit
.
project
,
nil
).
execute
(
commit_status
)
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
commit_status
.
pipeline
.
project
,
nil
).
execute
(
commit_status
)
end
end
end
end
...
...
app/models/merge_request.rb
View file @
021d3810
...
@@ -579,8 +579,8 @@ class MergeRequest < ActiveRecord::Base
...
@@ -579,8 +579,8 @@ class MergeRequest < ActiveRecord::Base
diverged_commits_count
>
0
diverged_commits_count
>
0
end
end
def
ci_commit
def
pipeline
@
ci_commit
||=
source_project
.
ci_commit
(
last_commit
.
id
,
source_branch
)
if
last_commit
&&
source_project
@
pipeline
||=
source_project
.
pipeline
(
last_commit
.
id
,
source_branch
)
if
last_commit
&&
source_project
end
end
def
diff_refs
def
diff_refs
...
...
app/models/project.rb
View file @
021d3810
...
@@ -119,7 +119,7 @@ class Project < ActiveRecord::Base
...
@@ -119,7 +119,7 @@ class Project < ActiveRecord::Base
has_one
:import_data
,
dependent: :destroy
,
class_name:
"ProjectImportData"
has_one
:import_data
,
dependent: :destroy
,
class_name:
"ProjectImportData"
has_many
:commit_statuses
,
dependent: :destroy
,
class_name:
'CommitStatus'
,
foreign_key: :gl_project_id
has_many
:commit_statuses
,
dependent: :destroy
,
class_name:
'CommitStatus'
,
foreign_key: :gl_project_id
has_many
:
ci_commits
,
dependent: :destroy
,
class_name:
'Ci::Commit
'
,
foreign_key: :gl_project_id
has_many
:
pipelines
,
dependent: :destroy
,
class_name:
'Ci::Pipeline
'
,
foreign_key: :gl_project_id
has_many
:builds
,
class_name:
'Ci::Build'
,
foreign_key: :gl_project_id
# the builds are created from the commit_statuses
has_many
:builds
,
class_name:
'Ci::Build'
,
foreign_key: :gl_project_id
# the builds are created from the commit_statuses
has_many
:runner_projects
,
dependent: :destroy
,
class_name:
'Ci::RunnerProject'
,
foreign_key: :gl_project_id
has_many
:runner_projects
,
dependent: :destroy
,
class_name:
'Ci::RunnerProject'
,
foreign_key: :gl_project_id
has_many
:runners
,
through: :runner_projects
,
source: :runner
,
class_name:
'Ci::Runner'
has_many
:runners
,
through: :runner_projects
,
source: :runner
,
class_name:
'Ci::Runner'
...
@@ -930,12 +930,12 @@ class Project < ActiveRecord::Base
...
@@ -930,12 +930,12 @@ class Project < ActiveRecord::Base
!
namespace
.
share_with_group_lock
!
namespace
.
share_with_group_lock
end
end
def
ci_commit
(
sha
,
ref
)
def
pipeline
(
sha
,
ref
)
ci_commit
s
.
order
(
id: :desc
).
find_by
(
sha:
sha
,
ref:
ref
)
pipeline
s
.
order
(
id: :desc
).
find_by
(
sha:
sha
,
ref:
ref
)
end
end
def
ensure_
ci_commit
(
sha
,
ref
)
def
ensure_
pipeline
(
sha
,
ref
)
ci_commit
(
sha
,
ref
)
||
ci_commit
s
.
create
(
sha:
sha
,
ref:
ref
)
pipeline
(
sha
,
ref
)
||
pipeline
s
.
create
(
sha:
sha
,
ref:
ref
)
end
end
def
enable_ci
def
enable_ci
...
...
app/services/ci/create_pipeline_service.rb
View file @
021d3810
module
Ci
module
Ci
class
CreatePipelineService
<
BaseService
class
CreatePipelineService
<
BaseService
def
execute
def
execute
pipeline
=
project
.
ci_commit
s
.
new
(
params
)
pipeline
=
project
.
pipeline
s
.
new
(
params
)
unless
ref_names
.
include?
(
params
[
:ref
])
unless
ref_names
.
include?
(
params
[
:ref
])
pipeline
.
errors
.
add
(
:base
,
'Reference not found'
)
pipeline
.
errors
.
add
(
:base
,
'Reference not found'
)
...
@@ -19,7 +19,7 @@ module Ci
...
@@ -19,7 +19,7 @@ module Ci
end
end
begin
begin
Ci
::
Commit
.
transaction
do
Ci
::
Pipeline
.
transaction
do
pipeline
.
sha
=
commit
.
id
pipeline
.
sha
=
commit
.
id
unless
pipeline
.
config_processor
unless
pipeline
.
config_processor
...
...
app/services/ci/create_trigger_request_service.rb
View file @
021d3810
...
@@ -7,7 +7,7 @@ module Ci
...
@@ -7,7 +7,7 @@ module Ci
# check if ref is tag
# check if ref is tag
tag
=
project
.
repository
.
find_tag
(
ref
).
present?
tag
=
project
.
repository
.
find_tag
(
ref
).
present?
ci_commit
=
project
.
ci_commit
s
.
create
(
sha:
commit
.
sha
,
ref:
ref
,
tag:
tag
)
ci_commit
=
project
.
pipeline
s
.
create
(
sha:
commit
.
sha
,
ref:
ref
,
tag:
tag
)
trigger_request
=
trigger
.
trigger_requests
.
create!
(
trigger_request
=
trigger
.
trigger_requests
.
create!
(
variables:
variables
,
variables:
variables
,
...
...
app/services/ci/image_for_build_service.rb
View file @
021d3810
...
@@ -3,7 +3,7 @@ module Ci
...
@@ -3,7 +3,7 @@ module Ci
def
execute
(
project
,
opts
)
def
execute
(
project
,
opts
)
sha
=
opts
[
:sha
]
||
ref_sha
(
project
,
opts
[
:ref
])
sha
=
opts
[
:sha
]
||
ref_sha
(
project
,
opts
[
:ref
])
ci_commits
=
project
.
ci_commit
s
.
where
(
sha:
sha
)
ci_commits
=
project
.
pipeline
s
.
where
(
sha:
sha
)
ci_commits
=
ci_commits
.
where
(
ref:
opts
[
:ref
])
if
opts
[
:ref
]
ci_commits
=
ci_commits
.
where
(
ref:
opts
[
:ref
])
if
opts
[
:ref
]
image_name
=
image_for_status
(
ci_commits
.
status
)
image_name
=
image_for_status
(
ci_commits
.
status
)
...
...
app/services/create_commit_builds_service.rb
View file @
021d3810
...
@@ -18,7 +18,7 @@ class CreateCommitBuildsService
...
@@ -18,7 +18,7 @@ class CreateCommitBuildsService
return
false
return
false
end
end
commit
=
Ci
::
Commit
.
new
(
project:
project
,
sha:
sha
,
ref:
ref
,
before_sha:
before_sha
,
tag:
tag
)
commit
=
Ci
::
Pipeline
.
new
(
project:
project
,
sha:
sha
,
ref:
ref
,
before_sha:
before_sha
,
tag:
tag
)
# Skip creating ci_commit when no gitlab-ci.yml is found
# Skip creating ci_commit when no gitlab-ci.yml is found
unless
commit
.
ci_yaml_file
unless
commit
.
ci_yaml_file
...
...
app/services/merge_requests/base_service.rb
View file @
021d3810
...
@@ -55,12 +55,12 @@ module MergeRequests
...
@@ -55,12 +55,12 @@ module MergeRequests
def
each_merge_request
(
commit_status
)
def
each_merge_request
(
commit_status
)
merge_request_from
(
commit_status
).
each
do
|
merge_request
|
merge_request_from
(
commit_status
).
each
do
|
merge_request
|
ci_commit
=
merge_request
.
ci_commit
pipeline
=
merge_request
.
pipeline
next
unless
ci_commit
next
unless
pipeline
next
unless
ci_commit
.
sha
==
commit_status
.
sha
next
unless
pipeline
.
sha
==
commit_status
.
sha
yield
merge_request
,
ci_commit
yield
merge_request
,
pipeline
end
end
end
end
end
end
...
...
features/steps/project/commits/commits.rb
View file @
021d3810
...
@@ -169,7 +169,7 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
...
@@ -169,7 +169,7 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
end
end
step
'repository contains ".gitlab-ci.yml" file'
do
step
'repository contains ".gitlab-ci.yml" file'
do
allow_any_instance_of
(
Ci
::
Commit
).
to
receive
(
:ci_yaml_file
).
and_return
(
String
.
new
)
allow_any_instance_of
(
Ci
::
Pipeline
).
to
receive
(
:ci_yaml_file
).
and_return
(
String
.
new
)
end
end
step
'I see commit ci info'
do
step
'I see commit ci info'
do
...
...
lib/api/commit_statuses.rb
View file @
021d3810
...
@@ -50,7 +50,7 @@ module API
...
@@ -50,7 +50,7 @@ module API
commit
=
@project
.
commit
(
params
[
:sha
])
commit
=
@project
.
commit
(
params
[
:sha
])
not_found!
'Commit'
unless
commit
not_found!
'Commit'
unless
commit
# Since the CommitStatus is attached to Ci::
Commit
(in the future Pipeline)
# Since the CommitStatus is attached to Ci::
Pipeline
(in the future Pipeline)
# We need to always have the pipeline object
# We need to always have the pipeline object
# To have a valid pipeline object that can be attached to specific MR
# To have a valid pipeline object that can be attached to specific MR
# Other CI service needs to send `ref`
# Other CI service needs to send `ref`
...
...
lib/api/merge_requests.rb
View file @
021d3810
...
@@ -238,7 +238,7 @@ module API
...
@@ -238,7 +238,7 @@ module API
should_remove_source_branch:
params
[
:should_remove_source_branch
]
should_remove_source_branch:
params
[
:should_remove_source_branch
]
}
}
if
parse_boolean
(
params
[
:merge_when_build_succeeds
])
&&
merge_request
.
ci_commit
&&
merge_request
.
ci_commit
.
active?
if
parse_boolean
(
params
[
:merge_when_build_succeeds
])
&&
merge_request
.
pipeline
&&
merge_request
.
pipeline
.
active?
::
MergeRequests
::
MergeWhenBuildSucceedsService
.
new
(
merge_request
.
target_project
,
current_user
,
merge_params
).
::
MergeRequests
::
MergeWhenBuildSucceedsService
.
new
(
merge_request
.
target_project
,
current_user
,
merge_params
).
execute
(
merge_request
)
execute
(
merge_request
)
else
else
...
...
lib/ci/charts.rb
View file @
021d3810
...
@@ -60,7 +60,7 @@ module Ci
...
@@ -60,7 +60,7 @@ module Ci
class
BuildTime
<
Chart
class
BuildTime
<
Chart
def
collect
def
collect
commits
=
project
.
ci_commit
s
.
last
(
30
)
commits
=
project
.
pipeline
s
.
last
(
30
)
commits
.
each
do
|
commit
|
commits
.
each
do
|
commit
|
@labels
<<
commit
.
short_sha
@labels
<<
commit
.
short_sha
...
...
spec/factories/ci/commits.rb
View file @
021d3810
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
#
#
FactoryGirl
.
define
do
FactoryGirl
.
define
do
factory
:ci_empty_commit
,
class:
Ci
::
Commit
do
factory
:ci_empty_commit
,
class:
Ci
::
Pipeline
do
sha
'97de212e80737a608d939f648d959671fb0a0142'
sha
'97de212e80737a608d939f648d959671fb0a0142'
project
factory: :empty_project
project
factory: :empty_project
...
...
spec/features/pipelines_spec.rb
View file @
021d3810
...
@@ -167,7 +167,7 @@ describe "Pipelines" do
...
@@ -167,7 +167,7 @@ describe "Pipelines" do
context
'with gitlab-ci.yml'
do
context
'with gitlab-ci.yml'
do
before
{
stub_ci_commit_to_return_yaml_file
}
before
{
stub_ci_commit_to_return_yaml_file
}
it
{
expect
{
click_on
'Create pipeline'
}.
to
change
{
Ci
::
Commit
.
count
}.
by
(
1
)
}
it
{
expect
{
click_on
'Create pipeline'
}.
to
change
{
Ci
::
Pipeline
.
count
}.
by
(
1
)
}
end
end
context
'without gitlab-ci.yml'
do
context
'without gitlab-ci.yml'
do
...
...
spec/helpers/ci_status_helper_spec.rb
View file @
021d3810
...
@@ -3,8 +3,8 @@ require 'spec_helper'
...
@@ -3,8 +3,8 @@ require 'spec_helper'
describe
CiStatusHelper
do
describe
CiStatusHelper
do
include
IconsHelper
include
IconsHelper
let
(
:success_commit
)
{
double
(
"Ci::
Commit
"
,
status:
'success'
)
}
let
(
:success_commit
)
{
double
(
"Ci::
Pipeline
"
,
status:
'success'
)
}
let
(
:failed_commit
)
{
double
(
"Ci::
Commit
"
,
status:
'failed'
)
}
let
(
:failed_commit
)
{
double
(
"Ci::
Pipeline
"
,
status:
'failed'
)
}
describe
'ci_icon_for_status'
do
describe
'ci_icon_for_status'
do
it
{
expect
(
helper
.
ci_icon_for_status
(
success_commit
.
status
)).
to
include
(
'fa-check'
)
}
it
{
expect
(
helper
.
ci_icon_for_status
(
success_commit
.
status
)).
to
include
(
'fa-check'
)
}
...
...
spec/helpers/merge_requests_helper_spec.rb
View file @
021d3810
...
@@ -5,7 +5,7 @@ describe MergeRequestsHelper do
...
@@ -5,7 +5,7 @@ describe MergeRequestsHelper do
let
(
:project
)
{
create
:project
}
let
(
:project
)
{
create
:project
}
let
(
:merge_request
)
{
MergeRequest
.
new
}
let
(
:merge_request
)
{
MergeRequest
.
new
}
let
(
:ci_service
)
{
CiService
.
new
}
let
(
:ci_service
)
{
CiService
.
new
}
let
(
:last_commit
)
{
Ci
::
Commit
.
new
({})
}
let
(
:last_commit
)
{
Ci
::
Pipeline
.
new
({})
}
before
do
before
do
allow
(
merge_request
).
to
receive
(
:source_project
).
and_return
(
project
)
allow
(
merge_request
).
to
receive
(
:source_project
).
and_return
(
project
)
...
...
spec/models/ci/commit_spec.rb
View file @
021d3810
require
'spec_helper'
require
'spec_helper'
describe
Ci
::
Commit
,
models:
true
do
describe
Ci
::
Pipeline
,
models:
true
do
let
(
:project
)
{
FactoryGirl
.
create
:empty_project
}
let
(
:project
)
{
FactoryGirl
.
create
:empty_project
}
let
(
:commit
)
{
FactoryGirl
.
create
:ci_commit
,
project:
project
}
let
(
:commit
)
{
FactoryGirl
.
create
:ci_commit
,
project:
project
}
...
...
spec/models/merge_request_spec.rb
View file @
021d3810
...
@@ -402,7 +402,7 @@ describe MergeRequest, models: true do
...
@@ -402,7 +402,7 @@ describe MergeRequest, models: true do
with
(
'123abc'
,
'master'
).
with
(
'123abc'
,
'master'
).
and_return
(
ci_commit
)
and_return
(
ci_commit
)
expect
(
subject
.
ci_commit
).
to
eq
(
ci_commit
)
expect
(
subject
.
pipeline
).
to
eq
(
ci_commit
)
end
end
end
end
...
@@ -410,7 +410,7 @@ describe MergeRequest, models: true do
...
@@ -410,7 +410,7 @@ describe MergeRequest, models: true do
it
'returns nil'
do
it
'returns nil'
do
allow
(
subject
).
to
receive
(
:source_project
).
and_return
(
nil
)
allow
(
subject
).
to
receive
(
:source_project
).
and_return
(
nil
)
expect
(
subject
.
ci_commit
).
to
be_nil
expect
(
subject
.
pipeline
).
to
be_nil
end
end
end
end
end
end
...
...
spec/models/project_spec.rb
View file @
021d3810
...
@@ -403,7 +403,7 @@ describe Project, models: true do
...
@@ -403,7 +403,7 @@ describe Project, models: true do
let
(
:project
)
{
create
:project
}
let
(
:project
)
{
create
:project
}
let
(
:commit
)
{
create
:ci_commit
,
project:
project
,
ref:
'master'
}
let
(
:commit
)
{
create
:ci_commit
,
project:
project
,
ref:
'master'
}
subject
{
project
.
ci_commit
(
commit
.
sha
,
'master'
)
}
subject
{
project
.
pipeline
(
commit
.
sha
,
'master'
)
}
it
{
is_expected
.
to
eq
(
commit
)
}
it
{
is_expected
.
to
eq
(
commit
)
}
...
...
spec/requests/api/commit_statuses_spec.rb
View file @
021d3810
...
@@ -16,8 +16,8 @@ describe API::CommitStatuses, api: true do
...
@@ -16,8 +16,8 @@ describe API::CommitStatuses, api: true do
let
(
:get_url
)
{
"/projects/
#{
project
.
id
}
/repository/commits/
#{
sha
}
/statuses"
}
let
(
:get_url
)
{
"/projects/
#{
project
.
id
}
/repository/commits/
#{
sha
}
/statuses"
}
context
'ci commit exists'
do
context
'ci commit exists'
do
let!
(
:master
)
{
project
.
ci_commit
s
.
create
(
sha:
commit
.
id
,
ref:
'master'
)
}
let!
(
:master
)
{
project
.
pipeline
s
.
create
(
sha:
commit
.
id
,
ref:
'master'
)
}
let!
(
:develop
)
{
project
.
ci_commit
s
.
create
(
sha:
commit
.
id
,
ref:
'develop'
)
}
let!
(
:develop
)
{
project
.
pipeline
s
.
create
(
sha:
commit
.
id
,
ref:
'develop'
)
}
it_behaves_like
'a paginated resources'
do
it_behaves_like
'a paginated resources'
do
let
(
:request
)
{
get
api
(
get_url
,
reporter
)
}
let
(
:request
)
{
get
api
(
get_url
,
reporter
)
}
...
...
spec/requests/api/merge_requests_spec.rb
View file @
021d3810
...
@@ -388,7 +388,7 @@ describe API::API, api: true do
...
@@ -388,7 +388,7 @@ describe API::API, api: true do
end
end
describe
"PUT /projects/:id/merge_requests/:merge_request_id/merge"
do
describe
"PUT /projects/:id/merge_requests/:merge_request_id/merge"
do
let
(
:
ci_commit
)
{
create
(
:ci_commit_without_jobs
)
}
let
(
:
pipeline
)
{
create
(
:ci_commit_without_jobs
)
}
it
"should return merge_request in case of success"
do
it
"should return merge_request in case of success"
do
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/merge"
,
user
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/merge"
,
user
)
...
@@ -429,7 +429,7 @@ describe API::API, api: true do
...
@@ -429,7 +429,7 @@ describe API::API, api: true do
end
end
it
"enables merge when build succeeds if the ci is active"
do
it
"enables merge when build succeeds if the ci is active"
do
allow_any_instance_of
(
MergeRequest
).
to
receive
(
:
ci_commit
).
and_return
(
ci_commit
)
allow_any_instance_of
(
MergeRequest
).
to
receive
(
:
pipeline
).
and_return
(
pipeline
)
allow
(
ci_commit
).
to
receive
(
:active?
).
and_return
(
true
)
allow
(
ci_commit
).
to
receive
(
:active?
).
and_return
(
true
)
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/merge"
,
user
),
merge_when_build_succeeds:
true
put
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/merge"
,
user
),
merge_when_build_succeeds:
true
...
...
spec/requests/api/triggers_spec.rb
View file @
021d3810
...
@@ -44,7 +44,7 @@ describe API::API do
...
@@ -44,7 +44,7 @@ describe API::API do
end
end
context
'Have a commit'
do
context
'Have a commit'
do
let
(
:commit
)
{
project
.
ci_commit
s
.
last
}
let
(
:commit
)
{
project
.
pipeline
s
.
last
}
it
'should create builds'
do
it
'should create builds'
do
post
api
(
"/projects/
#{
project
.
id
}
/trigger/builds"
),
options
.
merge
(
ref:
'master'
)
post
api
(
"/projects/
#{
project
.
id
}
/trigger/builds"
),
options
.
merge
(
ref:
'master'
)
...
...
spec/requests/ci/api/triggers_spec.rb
View file @
021d3810
...
@@ -36,7 +36,7 @@ describe Ci::API::API do
...
@@ -36,7 +36,7 @@ describe Ci::API::API do
end
end
context
'Have a commit'
do
context
'Have a commit'
do
let
(
:commit
)
{
project
.
ci_commit
s
.
last
}
let
(
:commit
)
{
project
.
pipeline
s
.
last
}
it
'should create builds'
do
it
'should create builds'
do
post
ci_api
(
"/projects/
#{
project
.
ci_id
}
/refs/master/trigger"
),
options
post
ci_api
(
"/projects/
#{
project
.
ci_id
}
/refs/master/trigger"
),
options
...
...
spec/services/create_commit_builds_service_spec.rb
View file @
021d3810
...
@@ -20,10 +20,10 @@ describe CreateCommitBuildsService, services: true do
...
@@ -20,10 +20,10 @@ describe CreateCommitBuildsService, services: true do
)
)
end
end
it
{
expect
(
commit
).
to
be_kind_of
(
Ci
::
Commit
)
}
it
{
expect
(
commit
).
to
be_kind_of
(
Ci
::
Pipeline
)
}
it
{
expect
(
commit
).
to
be_valid
}
it
{
expect
(
commit
).
to
be_valid
}
it
{
expect
(
commit
).
to
be_persisted
}
it
{
expect
(
commit
).
to
be_persisted
}
it
{
expect
(
commit
).
to
eq
(
project
.
ci_commit
s
.
last
)
}
it
{
expect
(
commit
).
to
eq
(
project
.
pipeline
s
.
last
)
}
it
{
expect
(
commit
.
builds
.
first
).
to
be_kind_of
(
Ci
::
Build
)
}
it
{
expect
(
commit
.
builds
.
first
).
to
be_kind_of
(
Ci
::
Build
)
}
end
end
...
@@ -61,12 +61,12 @@ describe CreateCommitBuildsService, services: true do
...
@@ -61,12 +61,12 @@ describe CreateCommitBuildsService, services: true do
commits:
[{
message:
'Message'
}]
commits:
[{
message:
'Message'
}]
)
)
expect
(
result
).
to
be_falsey
expect
(
result
).
to
be_falsey
expect
(
Ci
::
Commit
.
count
).
to
eq
(
0
)
expect
(
Ci
::
Pipeline
.
count
).
to
eq
(
0
)
end
end
it
'fails commits if yaml is invalid'
do
it
'fails commits if yaml is invalid'
do
message
=
'message'
message
=
'message'
allow_any_instance_of
(
Ci
::
Commit
).
to
receive
(
:git_commit_message
)
{
message
}
allow_any_instance_of
(
Ci
::
Pipeline
).
to
receive
(
:git_commit_message
)
{
message
}
stub_ci_commit_yaml_file
(
'invalid: file: file'
)
stub_ci_commit_yaml_file
(
'invalid: file: file'
)
commits
=
[{
message:
message
}]
commits
=
[{
message:
message
}]
commit
=
service
.
execute
(
project
,
user
,
commit
=
service
.
execute
(
project
,
user
,
...
@@ -85,7 +85,7 @@ describe CreateCommitBuildsService, services: true do
...
@@ -85,7 +85,7 @@ describe CreateCommitBuildsService, services: true do
let
(
:message
)
{
"some message[ci skip]"
}
let
(
:message
)
{
"some message[ci skip]"
}
before
do
before
do
allow_any_instance_of
(
Ci
::
Commit
).
to
receive
(
:git_commit_message
)
{
message
}
allow_any_instance_of
(
Ci
::
Pipeline
).
to
receive
(
:git_commit_message
)
{
message
}
end
end
it
"skips builds creation if there is [ci skip] tag in commit message"
do
it
"skips builds creation if there is [ci skip] tag in commit message"
do
...
@@ -102,7 +102,7 @@ describe CreateCommitBuildsService, services: true do
...
@@ -102,7 +102,7 @@ describe CreateCommitBuildsService, services: true do
end
end
it
"does not skips builds creation if there is no [ci skip] tag in commit message"
do
it
"does not skips builds creation if there is no [ci skip] tag in commit message"
do
allow_any_instance_of
(
Ci
::
Commit
).
to
receive
(
:git_commit_message
)
{
"some message"
}
allow_any_instance_of
(
Ci
::
Pipeline
).
to
receive
(
:git_commit_message
)
{
"some message"
}
commits
=
[{
message:
"some message"
}]
commits
=
[{
message:
"some message"
}]
commit
=
service
.
execute
(
project
,
user
,
commit
=
service
.
execute
(
project
,
user
,
...
@@ -133,7 +133,7 @@ describe CreateCommitBuildsService, services: true do
...
@@ -133,7 +133,7 @@ describe CreateCommitBuildsService, services: true do
end
end
it
"skips build creation if there are already builds"
do
it
"skips build creation if there are already builds"
do
allow_any_instance_of
(
Ci
::
Commit
).
to
receive
(
:ci_yaml_file
)
{
gitlab_ci_yaml
}
allow_any_instance_of
(
Ci
::
Pipeline
).
to
receive
(
:ci_yaml_file
)
{
gitlab_ci_yaml
}
commits
=
[{
message:
"message"
}]
commits
=
[{
message:
"message"
}]
commit
=
service
.
execute
(
project
,
user
,
commit
=
service
.
execute
(
project
,
user
,
...
...
spec/services/merge_requests/merge_when_build_succeeds_service_spec.rb
View file @
021d3810
...
@@ -116,7 +116,7 @@ describe MergeRequests::MergeWhenBuildSucceedsService do
...
@@ -116,7 +116,7 @@ describe MergeRequests::MergeWhenBuildSucceedsService do
before
do
before
do
# This behavior of MergeRequest: we instantiate a new object
# This behavior of MergeRequest: we instantiate a new object
allow_any_instance_of
(
MergeRequest
).
to
receive
(
:ci_commit
).
and_wrap_original
do
allow_any_instance_of
(
MergeRequest
).
to
receive
(
:ci_commit
).
and_wrap_original
do
Ci
::
Commit
.
find
(
ci_commit
.
id
)
Ci
::
Pipeline
.
find
(
ci_commit
.
id
)
end
end
# We create test after the build
# We create test after the build
...
...
spec/support/stub_gitlab_calls.rb
View file @
021d3810
...
@@ -18,7 +18,7 @@ module StubGitlabCalls
...
@@ -18,7 +18,7 @@ module StubGitlabCalls
end
end
def
stub_ci_commit_yaml_file
(
ci_yaml
)
def
stub_ci_commit_yaml_file
(
ci_yaml
)
allow_any_instance_of
(
Ci
::
Commit
).
to
receive
(
:ci_yaml_file
)
{
ci_yaml
}
allow_any_instance_of
(
Ci
::
Pipeline
).
to
receive
(
:ci_yaml_file
)
{
ci_yaml
}
end
end
def
stub_ci_builds_disabled
def
stub_ci_builds_disabled
...
...
spec/workers/post_receive_spec.rb
View file @
021d3810
...
@@ -52,16 +52,16 @@ describe PostReceive do
...
@@ -52,16 +52,16 @@ describe PostReceive do
context
"gitlab-ci.yml"
do
context
"gitlab-ci.yml"
do
subject
{
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
}
subject
{
PostReceive
.
new
.
perform
(
pwd
(
project
),
key_id
,
base64_changes
)
}
context
"creates a Ci::
Commit
for every change"
do
context
"creates a Ci::
Pipeline
for every change"
do
before
{
stub_ci_commit_to_return_yaml_file
}
before
{
stub_ci_commit_to_return_yaml_file
}
it
{
expect
{
subject
}.
to
change
{
Ci
::
Commit
.
count
}.
by
(
2
)
}
it
{
expect
{
subject
}.
to
change
{
Ci
::
Pipeline
.
count
}.
by
(
2
)
}
end
end
context
"does not create a Ci::
Commit
"
do
context
"does not create a Ci::
Pipeline
"
do
before
{
stub_ci_commit_yaml_file
(
nil
)
}
before
{
stub_ci_commit_yaml_file
(
nil
)
}
it
{
expect
{
subject
}.
not_to
change
{
Ci
::
Commit
.
count
}
}
it
{
expect
{
subject
}.
not_to
change
{
Ci
::
Pipeline
.
count
}
}
end
end
end
end
end
end
...
...
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