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
Kazuhiko Shiozaki
gitlab-ce
Commits
64bfd9d7
Commit
64bfd9d7
authored
Dec 10, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove ci_ prefix from all ci related things
parent
8cdd54cc
Changes
33
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
269 additions
and
267 deletions
+269
-267
app/controllers/admin/runner_projects_controller.rb
app/controllers/admin/runner_projects_controller.rb
+2
-2
app/controllers/projects/builds_controller.rb
app/controllers/projects/builds_controller.rb
+3
-3
app/controllers/projects/runner_projects_controller.rb
app/controllers/projects/runner_projects_controller.rb
+1
-1
app/controllers/projects/runners_controller.rb
app/controllers/projects/runners_controller.rb
+3
-3
app/controllers/projects/triggers_controller.rb
app/controllers/projects/triggers_controller.rb
+4
-4
app/controllers/projects/variables_controller.rb
app/controllers/projects/variables_controller.rb
+1
-1
app/helpers/ci_status_helper.rb
app/helpers/ci_status_helper.rb
+1
-1
app/models/ci/build.rb
app/models/ci/build.rb
+1
-1
app/models/ci/runner.rb
app/models/ci/runner.rb
+1
-1
app/models/project.rb
app/models/project.rb
+8
-8
app/models/user.rb
app/models/user.rb
+1
-1
app/services/ci/create_commit_service.rb
app/services/ci/create_commit_service.rb
+0
-28
app/services/create_commit_builds_service.rb
app/services/create_commit_builds_service.rb
+29
-0
app/services/git_push_service.rb
app/services/git_push_service.rb
+1
-0
app/services/git_tag_push_service.rb
app/services/git_tag_push_service.rb
+1
-0
app/views/admin/runners/show.html.haml
app/views/admin/runners/show.html.haml
+1
-1
app/views/layouts/nav/_project.html.haml
app/views/layouts/nav/_project.html.haml
+1
-1
app/views/projects/graphs/ci/_overall.haml
app/views/projects/graphs/ci/_overall.haml
+4
-4
app/views/projects/runners/_runner.html.haml
app/views/projects/runners/_runner.html.haml
+2
-2
app/views/projects/variables/show.html.haml
app/views/projects/variables/show.html.haml
+2
-2
lib/ci/api/runners.rb
lib/ci/api/runners.rb
+1
-1
lib/ci/charts.rb
lib/ci/charts.rb
+2
-2
spec/features/builds_spec.rb
spec/features/builds_spec.rb
+1
-1
spec/features/runners_spec.rb
spec/features/runners_spec.rb
+5
-5
spec/features/triggers_spec.rb
spec/features/triggers_spec.rb
+3
-3
spec/features/variables_spec.rb
spec/features/variables_spec.rb
+1
-1
spec/models/build_spec.rb
spec/models/build_spec.rb
+4
-4
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+3
-3
spec/models/project_spec.rb
spec/models/project_spec.rb
+8
-8
spec/requests/ci/api/builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+2
-2
spec/requests/ci/api/runners_spec.rb
spec/requests/ci/api/runners_spec.rb
+1
-1
spec/services/ci/create_commit_service_spec.rb
spec/services/ci/create_commit_service_spec.rb
+0
-172
spec/services/create_commit_builds_service_spec.rb
spec/services/create_commit_builds_service_spec.rb
+171
-0
No files found.
app/controllers/admin/runner_projects_controller.rb
View file @
64bfd9d7
...
...
@@ -2,8 +2,8 @@ class Admin::RunnerProjectsController < Admin::ApplicationController
before_action
:project
,
only:
[
:create
]
def
index
@runner_projects
=
project
.
ci_
runner_projects
.
all
@runner_project
=
project
.
ci_
runner_projects
.
new
@runner_projects
=
project
.
runner_projects
.
all
@runner_project
=
project
.
runner_projects
.
new
end
def
create
...
...
app/controllers/projects/builds_controller.rb
View file @
64bfd9d7
...
...
@@ -8,7 +8,7 @@ class Projects::BuildsController < Projects::ApplicationController
def
index
@scope
=
params
[
:scope
]
@all_builds
=
project
.
ci_
builds
@all_builds
=
project
.
builds
@builds
=
@all_builds
.
order
(
'created_at DESC'
)
@builds
=
case
@scope
...
...
@@ -23,7 +23,7 @@ class Projects::BuildsController < Projects::ApplicationController
end
def
cancel_all
@project
.
ci_
builds
.
running_or_pending
.
each
(
&
:cancel
)
@project
.
builds
.
running_or_pending
.
each
(
&
:cancel
)
redirect_to
namespace_project_builds_path
(
project
.
namespace
,
project
)
end
...
...
@@ -76,7 +76,7 @@ class Projects::BuildsController < Projects::ApplicationController
private
def
build
@build
||=
project
.
ci_
builds
.
unscoped
.
find_by!
(
id:
params
[
:id
])
@build
||=
project
.
builds
.
unscoped
.
find_by!
(
id:
params
[
:id
])
end
def
artifacts_file
...
...
app/controllers/projects/runner_projects_controller.rb
View file @
64bfd9d7
...
...
@@ -18,7 +18,7 @@ class Projects::RunnerProjectsController < Projects::ApplicationController
end
def
destroy
runner_project
=
project
.
ci_
runner_projects
.
find
(
params
[
:id
])
runner_project
=
project
.
runner_projects
.
find
(
params
[
:id
])
runner_project
.
destroy
redirect_to
runners_path
(
project
)
...
...
app/controllers/projects/runners_controller.rb
View file @
64bfd9d7
...
...
@@ -5,9 +5,9 @@ class Projects::RunnersController < Projects::ApplicationController
layout
'project_settings'
def
index
@runners
=
project
.
ci_
runners
.
ordered
@runners
=
project
.
runners
.
ordered
@specific_runners
=
current_user
.
ci_authorized_runners
.
where
.
not
(
id:
project
.
ci_
runners
).
where
.
not
(
id:
project
.
runners
).
ordered
.
page
(
params
[
:page
]).
per
(
20
)
@shared_runners
=
Ci
::
Runner
.
shared
.
active
@shared_runners_count
=
@shared_runners
.
count
(
:all
)
...
...
@@ -60,7 +60,7 @@ class Projects::RunnersController < Projects::ApplicationController
protected
def
set_runner
@runner
||=
project
.
ci_
runners
.
find
(
params
[
:id
])
@runner
||=
project
.
runners
.
find
(
params
[
:id
])
end
def
runner_params
...
...
app/controllers/projects/triggers_controller.rb
View file @
64bfd9d7
...
...
@@ -4,18 +4,18 @@ class Projects::TriggersController < Projects::ApplicationController
layout
'project_settings'
def
index
@triggers
=
project
.
ci_
triggers
@triggers
=
project
.
triggers
@trigger
=
Ci
::
Trigger
.
new
end
def
create
@trigger
=
project
.
ci_
triggers
.
new
@trigger
=
project
.
triggers
.
new
@trigger
.
save
if
@trigger
.
valid?
redirect_to
namespace_project_triggers_path
(
@project
.
namespace
,
@project
)
else
@triggers
=
project
.
ci_
triggers
.
select
(
&
:persisted?
)
@triggers
=
project
.
triggers
.
select
(
&
:persisted?
)
render
:index
end
end
...
...
@@ -29,6 +29,6 @@ class Projects::TriggersController < Projects::ApplicationController
private
def
trigger
@trigger
||=
project
.
ci_
triggers
.
find
(
params
[
:id
])
@trigger
||=
project
.
triggers
.
find
(
params
[
:id
])
end
end
app/controllers/projects/variables_controller.rb
View file @
64bfd9d7
...
...
@@ -17,6 +17,6 @@ class Projects::VariablesController < Projects::ApplicationController
private
def
project_params
params
.
require
(
:project
).
permit
({
ci_
variables_attributes:
[
:id
,
:key
,
:value
,
:_destroy
]
})
params
.
require
(
:project
).
permit
({
variables_attributes:
[
:id
,
:key
,
:value
,
:_destroy
]
})
end
end
app/helpers/ci_status_helper.rb
View file @
64bfd9d7
...
...
@@ -65,7 +65,7 @@ module CiStatusHelper
end
def
no_runners_for_project?
(
project
)
project
.
ci_
runners
.
blank?
&&
project
.
runners
.
blank?
&&
Ci
::
Runner
.
shared
.
blank?
end
end
app/models/ci/build.rb
View file @
64bfd9d7
...
...
@@ -287,7 +287,7 @@ module Ci
end
def
project_variables
project
.
ci_
variables
.
map
do
|
variable
|
project
.
variables
.
map
do
|
variable
|
{
key:
variable
.
key
,
value:
variable
.
value
,
public:
false
}
end
end
...
...
app/models/ci/runner.rb
View file @
64bfd9d7
...
...
@@ -52,7 +52,7 @@ module Ci
def
assign_to
(
project
,
current_user
=
nil
)
self
.
is_shared
=
false
if
shared?
self
.
save
project
.
ci_
runner_projects
.
create!
(
runner_id:
self
.
id
)
project
.
runner_projects
.
create!
(
runner_id:
self
.
id
)
end
def
display_name
...
...
app/models/project.rb
View file @
64bfd9d7
...
...
@@ -128,15 +128,15 @@ class Project < ActiveRecord::Base
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
:ci_commits
,
dependent: :destroy
,
class_name:
'Ci::Commit'
,
foreign_key: :gl_project_id
has_many
:ci_statuses
,
dependent: :destroy
,
class_name:
'CommitStatus'
,
foreign_key: :gl_project_id
has_many
:ci_builds
,
class_name:
'Ci::Build'
,
foreign_key: :gl_project_id
# the builds are created from the ci_statuses
has_many
:ci_runner_projects
,
dependent: :destroy
,
class_name:
'Ci::RunnerProject'
,
foreign_key: :gl_project_id
has_many
:ci_runners
,
through: :ci_runner_projects
,
source: :runner
,
class_name:
'Ci::Runner'
has_many
:ci_variables
,
dependent: :destroy
,
class_name:
'Ci::Variable'
,
foreign_key: :gl_project_id
has_many
:ci_triggers
,
dependent: :destroy
,
class_name:
'Ci::Trigger'
,
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
: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
:variables
,
dependent: :destroy
,
class_name:
'Ci::Variable'
,
foreign_key: :gl_project_id
has_many
:triggers
,
dependent: :destroy
,
class_name:
'Ci::Trigger'
,
foreign_key: :gl_project_id
accepts_nested_attributes_for
:
ci_
variables
,
allow_destroy:
true
accepts_nested_attributes_for
:variables
,
allow_destroy:
true
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
delegate
:members
,
to: :team
,
prefix:
true
...
...
@@ -822,7 +822,7 @@ class Project < ActiveRecord::Base
end
def
any_runners?
(
&
block
)
if
ci_
runners
.
active
.
any?
(
&
block
)
if
runners
.
active
.
any?
(
&
block
)
return
true
end
...
...
app/models/user.rb
View file @
64bfd9d7
...
...
@@ -134,7 +134,7 @@ class User < ActiveRecord::Base
has_many
:assigned_merge_requests
,
dependent: :destroy
,
foreign_key: :assignee_id
,
class_name:
"MergeRequest"
has_many
:oauth_applications
,
class_name:
'Doorkeeper::Application'
,
as: :owner
,
dependent: :destroy
has_one
:abuse_report
,
dependent: :destroy
has_many
:
ci_builds
,
dependent: :nullify
,
class_name:
'Ci::Build'
has_many
:
builds
,
dependent: :nullify
,
class_name:
'Ci::Build'
#
...
...
app/services/ci/create_commit_service.rb
deleted
100644 → 0
View file @
8cdd54cc
module
Ci
class
CreateCommitService
def
execute
(
project
,
user
,
params
)
sha
=
params
[
:checkout_sha
]
||
params
[
:after
]
origin_ref
=
params
[
:ref
]
unless
origin_ref
&&
sha
.
present?
return
false
end
ref
=
origin_ref
.
gsub
(
/\Arefs\/(tags|heads)\//
,
''
)
# Skip branch removal
if
sha
==
Ci
::
Git
::
BLANK_SHA
return
false
end
tag
=
origin_ref
.
start_with?
(
'refs/tags/'
)
commit
=
project
.
ensure_ci_commit
(
sha
)
unless
commit
.
skip_ci?
commit
.
update_committed!
commit
.
create_builds
(
ref
,
tag
,
user
)
end
commit
end
end
end
app/services/create_commit_builds_service.rb
0 → 100644
View file @
64bfd9d7
class
CreateCommitBuildsService
def
execute
(
project
,
user
,
params
)
return
false
unless
project
.
builds_enabled?
sha
=
params
[
:checkout_sha
]
||
params
[
:after
]
origin_ref
=
params
[
:ref
]
unless
origin_ref
&&
sha
.
present?
return
false
end
ref
=
origin_ref
.
gsub
(
/\Arefs\/(tags|heads)\//
,
''
)
# Skip branch removal
if
sha
==
Ci
::
Git
::
BLANK_SHA
return
false
end
tag
=
origin_ref
.
start_with?
(
'refs/tags/'
)
commit
=
project
.
ensure_ci_commit
(
sha
)
unless
commit
.
skip_ci?
commit
.
update_committed!
commit
.
create_builds
(
ref
,
tag
,
user
)
end
commit
end
end
app/services/git_push_service.rb
View file @
64bfd9d7
...
...
@@ -61,6 +61,7 @@ class GitPushService
EventCreateService
.
new
.
push
(
project
,
user
,
@push_data
)
project
.
execute_hooks
(
@push_data
.
dup
,
:push_hooks
)
project
.
execute_services
(
@push_data
.
dup
,
:push_hooks
)
CreateCommitBuildsService
.
new
.
execute
(
project
,
@user
,
@push_data
)
ProjectCacheWorker
.
perform_async
(
project
.
id
)
end
...
...
app/services/git_tag_push_service.rb
View file @
64bfd9d7
...
...
@@ -10,6 +10,7 @@ class GitTagPushService
EventCreateService
.
new
.
push
(
project
,
user
,
@push_data
)
project
.
execute_hooks
(
@push_data
.
dup
,
:tag_push_hooks
)
project
.
execute_services
(
@push_data
.
dup
,
:tag_push_hooks
)
CreateCommitBuildsService
.
new
.
execute
(
project
,
@user
,
@push_data
)
ProjectCacheWorker
.
perform_async
(
project
.
id
)
true
...
...
app/views/admin/runners/show.html.haml
View file @
64bfd9d7
...
...
@@ -82,7 +82,7 @@
=
project
.
name_with_namespace
%td
.pull-right
=
form_for
[
:admin
,
project
.
namespace
,
project
,
project
.
ci_
runner_projects
.
new
]
do
|
f
|
=
form_for
[
:admin
,
project
.
namespace
,
project
,
project
.
runner_projects
.
new
]
do
|
f
|
=
f
.
hidden_field
:runner_id
,
value:
@runner
.
id
=
f
.
submit
'Enable'
,
class:
'btn btn-xs'
=
paginate
@projects
...
...
app/views/layouts/nav/_project.html.haml
View file @
64bfd9d7
...
...
@@ -44,7 +44,7 @@
=
icon
(
'cubes fw'
)
%span
Builds
%span
.count.builds_counter
=
@project
.
ci_
builds
.
running_or_pending
.
count
(
:all
)
%span
.count.builds_counter
=
@project
.
builds
.
running_or_pending
.
count
(
:all
)
-
if
project_nav_tab?
:graphs
=
nav_link
(
controller:
%w(graphs)
)
do
...
...
app/views/projects/graphs/ci/_overall.haml
View file @
64bfd9d7
...
...
@@ -2,17 +2,17 @@
%ul
%li
Total:
%strong
=
pluralize
@project
.
ci_
builds
.
count
(
:all
),
'build'
%strong
=
pluralize
@project
.
builds
.
count
(
:all
),
'build'
%li
Successful:
%strong
=
pluralize
@project
.
ci_
builds
.
success
.
count
(
:all
),
'build'
%strong
=
pluralize
@project
.
builds
.
success
.
count
(
:all
),
'build'
%li
Failed:
%strong
=
pluralize
@project
.
ci_
builds
.
failed
.
count
(
:all
),
'build'
%strong
=
pluralize
@project
.
builds
.
failed
.
count
(
:all
),
'build'
%li
Success ratio:
%strong
#{
success_ratio
(
@project
.
ci_builds
.
success
,
@project
.
ci_
builds
.
failed
)
}
%
#{
success_ratio
(
@project
.
builds
.
success
,
@project
.
builds
.
failed
)
}
%
%li
Commits covered:
%strong
...
...
app/views/projects/runners/_runner.html.haml
View file @
64bfd9d7
...
...
@@ -15,10 +15,10 @@
-
if
runner
.
belongs_to_one_project?
=
link_to
'Remove runner'
,
runner_path
(
runner
),
data:
{
confirm:
"Are you sure?"
},
method: :delete
,
class:
'btn btn-danger btn-sm'
-
else
-
runner_project
=
@project
.
ci_
runner_projects
.
find_by
(
runner_id:
runner
)
-
runner_project
=
@project
.
runner_projects
.
find_by
(
runner_id:
runner
)
=
link_to
'Disable for this project'
,
namespace_project_runner_project_path
(
@project
.
namespace
,
@project
,
runner_project
),
data:
{
confirm:
"Are you sure?"
},
method: :delete
,
class:
'btn btn-danger btn-sm'
-
elsif
runner
.
specific?
=
form_for
[
@project
.
namespace
,
@project
,
@project
.
ci_
runner_projects
.
new
]
do
|
f
|
=
form_for
[
@project
.
namespace
,
@project
,
@project
.
runner_projects
.
new
]
do
|
f
|
=
f
.
hidden_field
:runner_id
,
value:
runner
.
id
=
f
.
submit
'Enable for this project'
,
class:
'btn btn-sm'
.pull-right
...
...
app/views/projects/variables/show.html.haml
View file @
64bfd9d7
...
...
@@ -19,7 +19,7 @@
-
@project
.
errors
.
full_messages
.
each
do
|
msg
|
%li
=
msg
=
f
.
fields_for
:
ci_
variables
do
|
variable_form
|
=
f
.
fields_for
:variables
do
|
variable_form
|
.form-group
=
variable_form
.
label
:key
,
'Key'
,
class:
'control-label'
.col-sm-10
...
...
@@ -34,7 +34,7 @@
%hr
%p
.clearfix
=
f
.
link_to_add
"Add a variable"
,
:
ci_
variables
,
class:
'btn btn-success pull-right'
=
f
.
link_to_add
"Add a variable"
,
:variables
,
class:
'btn btn-success pull-right'
.form-actions
=
f
.
submit
'Save changes'
,
class:
'btn btn-save'
,
return_to:
request
.
original_url
lib/ci/api/runners.rb
View file @
64bfd9d7
...
...
@@ -38,7 +38,7 @@ module Ci
)
elsif
project
=
Project
.
find_by
(
runners_token:
params
[
:token
])
# Create a specific runner for project.
project
.
ci_
runners
.
create
(
project
.
runners
.
create
(
description:
params
[
:description
],
tag_list:
params
[
:tag_list
]
)
...
...
lib/ci/charts.rb
View file @
64bfd9d7
...
...
@@ -16,10 +16,10 @@ module Ci
def
push
(
from
,
to
,
format
)
@labels
<<
from
.
strftime
(
format
)
@total
<<
project
.
ci_
builds
.
@total
<<
project
.
builds
.
where
(
"? >
#{
Ci
::
Build
.
table_name
}
.created_at AND
#{
Ci
::
Build
.
table_name
}
.created_at > ?"
,
to
,
from
).
count
(
:all
)
@success
<<
project
.
ci_
builds
.
@success
<<
project
.
builds
.
where
(
"? >
#{
Ci
::
Build
.
table_name
}
.created_at AND
#{
Ci
::
Build
.
table_name
}
.created_at > ?"
,
to
,
from
).
success
.
count
(
:all
)
end
...
...
spec/features/builds_spec.rb
View file @
64bfd9d7
...
...
@@ -37,7 +37,7 @@ describe "Builds" do
context
"All builds"
do
before
do
@project
.
ci_
builds
.
running_or_pending
.
each
(
&
:success
)
@project
.
builds
.
running_or_pending
.
each
(
&
:success
)
visit
namespace_project_builds_path
(
@project
.
namespace
,
@project
,
scope: :all
)
end
...
...
spec/features/runners_spec.rb
View file @
64bfd9d7
...
...
@@ -21,9 +21,9 @@ describe "Runners" do
@specific_runner
=
FactoryGirl
.
create
:ci_specific_runner
@specific_runner2
=
FactoryGirl
.
create
:ci_specific_runner
@specific_runner3
=
FactoryGirl
.
create
:ci_specific_runner
@project
.
ci_
runners
<<
@specific_runner
@project2
.
ci_
runners
<<
@specific_runner2
@project3
.
ci_
runners
<<
@specific_runner3
@project
.
runners
<<
@specific_runner
@project2
.
runners
<<
@specific_runner2
@project3
.
runners
<<
@specific_runner3
visit
runners_path
(
@project
)
end
...
...
@@ -48,7 +48,7 @@ describe "Runners" do
end
it
"disables specific runner for project"
do
@project2
.
ci_
runners
<<
@specific_runner
@project2
.
runners
<<
@specific_runner
visit
runners_path
(
@project
)
within
".activated-specific-runners"
do
...
...
@@ -85,7 +85,7 @@ describe "Runners" do
@project
=
FactoryGirl
.
create
:empty_project
@project
.
team
<<
[
user
,
:master
]
@specific_runner
=
FactoryGirl
.
create
:ci_specific_runner
@project
.
ci_
runners
<<
@specific_runner
@project
.
runners
<<
@specific_runner
end
it
"shows runner information"
do
...
...
spec/features/triggers_spec.rb
View file @
64bfd9d7
...
...
@@ -13,16 +13,16 @@ describe 'Triggers' do
context
'create a trigger'
do
before
do
click_on
'Add Trigger'
expect
(
@project
.
ci_
triggers
.
count
).
to
eq
(
1
)
expect
(
@project
.
triggers
.
count
).
to
eq
(
1
)
end
it
'contains trigger token'
do
expect
(
page
).
to
have_content
(
@project
.
ci_
triggers
.
first
.
token
)
expect
(
page
).
to
have_content
(
@project
.
triggers
.
first
.
token
)
end
it
'revokes the trigger'
do
click_on
'Revoke'
expect
(
@project
.
ci_
triggers
.
count
).
to
eq
(
0
)
expect
(
@project
.
triggers
.
count
).
to
eq
(
0
)
end
end
end
spec/features/variables_spec.rb
View file @
64bfd9d7
...
...
@@ -18,7 +18,7 @@ describe "Variables" do
click_on
"Save changes"
expect
(
page
).
to
have_content
(
"Variables were successfully updated."
)
expect
(
@project
.
ci_
variables
.
count
).
to
eq
(
1
)
expect
(
@project
.
variables
.
count
).
to
eq
(
1
)
end
end
end
spec/models/build_spec.rb
View file @
64bfd9d7
...
...
@@ -232,7 +232,7 @@ describe Ci::Build, models: true do
end
before
do
build
.
project
.
ci_
variables
<<
Ci
::
Variable
.
new
(
key:
'SECRET_KEY'
,
value:
'secret_value'
)
build
.
project
.
variables
<<
Ci
::
Variable
.
new
(
key:
'SECRET_KEY'
,
value:
'secret_value'
)
end
it
{
is_expected
.
to
eq
(
predefined_variables
+
yaml_variables
+
secure_variables
)
}
...
...
@@ -264,7 +264,7 @@ describe Ci::Build, models: true do
describe
:can_be_served?
do
let
(
:runner
)
{
FactoryGirl
.
create
:ci_specific_runner
}
before
{
build
.
project
.
ci_
runners
<<
runner
}
before
{
build
.
project
.
runners
<<
runner
}
context
'runner without tags'
do
it
'can handle builds without tags'
do
...
...
@@ -307,7 +307,7 @@ describe Ci::Build, models: true do
let
(
:runner
)
{
FactoryGirl
.
create
:ci_specific_runner
}
before
do
build
.
project
.
ci_
runners
<<
runner
build
.
project
.
runners
<<
runner
runner
.
update_attributes
(
contacted_at:
1
.
second
.
ago
)
end
...
...
@@ -344,7 +344,7 @@ describe Ci::Build, models: true do
let
(
:runner
)
{
FactoryGirl
.
create
:ci_specific_runner
,
contacted_at:
1
.
second
.
ago
}
before
do
build
.
project
.
ci_
runners
<<
runner
build
.
project
.
runners
<<
runner
runner
.
save
end
...
...
spec/models/ci/runner_spec.rb
View file @
64bfd9d7
...
...
@@ -118,8 +118,8 @@ describe Ci::Runner, models: true do
runner
=
FactoryGirl
.
create
(
:ci_specific_runner
)
project
=
FactoryGirl
.
create
(
:empty_project
)
project1
=
FactoryGirl
.
create
(
:empty_project
)
project
.
ci_
runners
<<
runner
project1
.
ci_
runners
<<
runner
project
.
runners
<<
runner
project1
.
runners
<<
runner
expect
(
runner
.
belongs_to_one_project?
).
to
be_falsey
end
...
...
@@ -127,7 +127,7 @@ describe Ci::Runner, models: true do
it
"returns true"
do
runner
=
FactoryGirl
.
create
(
:ci_specific_runner
)
project
=
FactoryGirl
.
create
(
:empty_project
)
project
.
ci_
runners
<<
runner
project
.
runners
<<
runner
expect
(
runner
.
belongs_to_one_project?
).
to
be_truthy
end
...
...
spec/models/project_spec.rb
View file @
64bfd9d7
...
...
@@ -54,13 +54,13 @@ describe Project, models: true do
it
{
is_expected
.
to
have_one
(
:slack_service
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_one
(
:pushover_service
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_one
(
:asana_service
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:ci_commits
)
}
it
{
is_expected
.
to
have_many
(
:commit_statuses
)
}
it
{
is_expected
.
to
have_many
(
:ci_builds
)
}
it
{
is_expected
.
to
have_many
(
:ci_runner_projects
)
}
it
{
is_expected
.
to
have_many
(
:ci_runners
)
}
it
{
is_expected
.
to
have_many
(
:ci_variables
)
}
it
{
is_expected
.
to
have_many
(
:ci_triggers
)
}
it
{
is_expected
.
to
have_many
(
:ci_commits
)
}
it
{
is_expected
.
to
have_many
(
:builds
)
}
it
{
is_expected
.
to
have_many
(
:runner_projects
)
}
it
{
is_expected
.
to
have_many
(
:runners
)
}
it
{
is_expected
.
to
have_many
(
:variables
)
}
it
{
is_expected
.
to
have_many
(
:triggers
)
}
end
describe
'modules'
do
...
...
@@ -519,7 +519,7 @@ describe Project, models: true do
end
it
'there is a specific runner'
do
project
.
ci_
runners
<<
specific_runner
project
.
runners
<<
specific_runner
expect
(
project
.
any_runners?
).
to
be_truthy
end
...
...
@@ -529,7 +529,7 @@ describe Project, models: true do
end
it
'checks the presence of specific runner'
do
project
.
ci_
runners
<<
specific_runner
project
.
runners
<<
specific_runner
expect
(
project
.
any_runners?
{
|
runner
|
runner
==
specific_runner
}).
to
be_truthy
end
end
...
...
spec/requests/ci/api/builds_spec.rb
View file @
64bfd9d7
...
...
@@ -68,7 +68,7 @@ describe Ci::API::API do
it
"returns variables"
do
commit
=
FactoryGirl
.
create
(
:ci_commit
,
project:
project
)
commit
.
create_builds
(
'master'
,
false
,
nil
)
project
.
ci_
variables
<<
Ci
::
Variable
.
new
(
key:
"SECRET_KEY"
,
value:
"secret_value"
)
project
.
variables
<<
Ci
::
Variable
.
new
(
key:
"SECRET_KEY"
,
value:
"secret_value"
)
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
...
...
@@ -87,7 +87,7 @@ describe Ci::API::API do
trigger_request
=
FactoryGirl
.
create
(
:ci_trigger_request_with_variables
,
commit:
commit
,
trigger:
trigger
)
commit
.
create_builds
(
'master'
,
false
,
nil
,
trigger_request
)
project
.
ci_
variables
<<
Ci
::
Variable
.
new
(
key:
"SECRET_KEY"
,
value:
"secret_value"
)
project
.
variables
<<
Ci
::
Variable
.
new
(
key:
"SECRET_KEY"
,
value:
"secret_value"
)
post
ci_api
(
"/builds/register"
),
token:
runner
.
token
,
info:
{
platform: :darwin
}
...
...
spec/requests/ci/api/runners_spec.rb
View file @
64bfd9d7
...
...
@@ -34,7 +34,7 @@ describe Ci::API::API do
before
{
post
ci_api
(
"/runners/register"
),
token:
project
.
token
}
it
{
expect
(
response
.
status
).
to
eq
(
201
)
}
it
{
expect
(
project
.
ci_
runners
.
size
).
to
eq
(
1
)
}
it
{
expect
(
project
.
runners
.
size
).
to
eq
(
1
)
}
end
it
"should return 403 error if token is invalid"
do
...
...
spec/services/ci/create_commit_service_spec.rb
deleted
100644 → 0
View file @
8cdd54cc
require
'spec_helper'
module
Ci
describe
CreateCommitService
,
services:
true
do
let
(
:service
)
{
CreateCommitService
.
new
}
let
(
:project
)
{
FactoryGirl
.
create
(
:empty_project
)
}
let
(
:user
)
{
nil
}
before
do
stub_ci_commit_to_return_yaml_file
end
describe
:execute
do
context
'valid params'
do
let
(
:commit
)
do
service
.
execute
(
project
,
user
,
ref:
'refs/heads/master'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
[
{
message:
"Message"
}
]
)
end
it
{
expect
(
commit
).
to
be_kind_of
(
Commit
)
}
it
{
expect
(
commit
).
to
be_valid
}
it
{
expect
(
commit
).
to
be_persisted
}
it
{
expect
(
commit
).
to
eq
(
project
.
ci_commits
.
last
)
}
it
{
expect
(
commit
.
builds
.
first
).
to
be_kind_of
(
Build
)
}
end
context
"skip tag if there is no build for it"
do
it
"creates commit if there is appropriate job"
do
result
=
service
.
execute
(
project
,
user
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
[
{
message:
"Message"
}
]
)
expect
(
result
).
to
be_persisted
end
it
"creates commit if there is no appropriate job but deploy job has right ref setting"
do
config
=
YAML
.
dump
({
deploy:
{
deploy:
"ls"
,
only:
[
"0_1"
]
}
})
stub_ci_commit_yaml_file
(
config
)
result
=
service
.
execute
(
project
,
user
,
ref:
'refs/heads/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
[
{
message:
"Message"
}
]
)
expect
(
result
).
to
be_persisted
end
end
it
'skips commits without .gitlab-ci.yml'
do
stub_ci_commit_yaml_file
(
nil
)
result
=
service
.
execute
(
project
,
user
,
ref:
'refs/heads/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
[
{
message:
'Message'
}
]
)
expect
(
result
).
to
be_persisted
expect
(
result
.
builds
.
any?
).
to
be_falsey
expect
(
result
.
status
).
to
eq
(
'skipped'
)
expect
(
result
.
yaml_errors
).
to
be_nil
end
it
'skips commits if yaml is invalid'
do
message
=
'message'
allow_any_instance_of
(
Ci
::
Commit
).
to
receive
(
:git_commit_message
)
{
message
}
stub_ci_commit_yaml_file
(
'invalid: file: file'
)
commits
=
[{
message:
message
}]
commit
=
service
.
execute
(
project
,
user
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
)
expect
(
commit
.
builds
.
any?
).
to
be
false
expect
(
commit
.
status
).
to
eq
(
'failed'
)
expect
(
commit
.
yaml_errors
).
to_not
be_nil
end
describe
:ci_skip?
do
let
(
:message
)
{
"some message[ci skip]"
}
before
do
allow_any_instance_of
(
Ci
::
Commit
).
to
receive
(
:git_commit_message
)
{
message
}
end
it
"skips builds creation if there is [ci skip] tag in commit message"
do
commits
=
[{
message:
message
}]
commit
=
service
.
execute
(
project
,
user
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
)
expect
(
commit
.
builds
.
any?
).
to
be
false
expect
(
commit
.
status
).
to
eq
(
"skipped"
)
end
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"
}
commits
=
[{
message:
"some message"
}]
commit
=
service
.
execute
(
project
,
user
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
)
expect
(
commit
.
builds
.
first
.
name
).
to
eq
(
"staging"
)
end
it
"skips builds creation if there is [ci skip] tag in commit message and yaml is invalid"
do
stub_ci_commit_yaml_file
(
'invalid: file: fiile'
)
commits
=
[{
message:
message
}]
commit
=
service
.
execute
(
project
,
user
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
)
expect
(
commit
.
builds
.
any?
).
to
be
false
expect
(
commit
.
status
).
to
eq
(
"skipped"
)
expect
(
commit
.
yaml_errors
).
to
be_nil
end
end
it
"skips build creation if there are already builds"
do
allow_any_instance_of
(
Ci
::
Commit
).
to
receive
(
:ci_yaml_file
)
{
gitlab_ci_yaml
}
commits
=
[{
message:
"message"
}]
commit
=
service
.
execute
(
project
,
user
,
ref:
'refs/heads/master'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
)
expect
(
commit
.
builds
.
count
(
:all
)).
to
eq
(
2
)
commit
=
service
.
execute
(
project
,
user
,
ref:
'refs/heads/master'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
)
expect
(
commit
.
builds
.
count
(
:all
)).
to
eq
(
2
)
end
it
"creates commit with failed status if yaml is invalid"
do
stub_ci_commit_yaml_file
(
'invalid: file'
)
commits
=
[{
message:
"some message"
}]
commit
=
service
.
execute
(
project
,
user
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
)
expect
(
commit
.
status
).
to
eq
(
"failed"
)
expect
(
commit
.
builds
.
any?
).
to
be
false
end
end
end
end
spec/services/create_commit_builds_service_spec.rb
0 → 100644
View file @
64bfd9d7
require
'spec_helper'
describe
CreateCommitBuildsService
,
services:
true
do
let
(
:service
)
{
CreateCommitBuildsService
.
new
}
let
(
:project
)
{
FactoryGirl
.
create
(
:empty_project
)
}
let
(
:user
)
{
nil
}
before
do
stub_ci_commit_to_return_yaml_file
end
describe
:execute
do
context
'valid params'
do
let
(
:commit
)
do
service
.
execute
(
project
,
user
,
ref:
'refs/heads/master'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
[{
message:
"Message"
}]
)
end
it
{
expect
(
commit
).
to
be_kind_of
(
Commit
)
}
it
{
expect
(
commit
).
to
be_valid
}
it
{
expect
(
commit
).
to
be_persisted
}
it
{
expect
(
commit
).
to
eq
(
project
.
ci_commits
.
last
)
}
it
{
expect
(
commit
.
builds
.
first
).
to
be_kind_of
(
Build
)
}
end
context
"skip tag if there is no build for it"
do
it
"creates commit if there is appropriate job"
do
result
=
service
.
execute
(
project
,
user
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
[{
message:
"Message"
}]
)
expect
(
result
).
to
be_persisted
end
it
"creates commit if there is no appropriate job but deploy job has right ref setting"
do
config
=
YAML
.
dump
({
deploy:
{
deploy:
"ls"
,
only:
[
"0_1"
]
}
})
stub_ci_commit_yaml_file
(
config
)
result
=
service
.
execute
(
project
,
user
,
ref:
'refs/heads/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
[{
message:
"Message"
}]
)
expect
(
result
).
to
be_persisted
end
end
it
'skips commits without .gitlab-ci.yml'
do
stub_ci_commit_yaml_file
(
nil
)
result
=
service
.
execute
(
project
,
user
,
ref:
'refs/heads/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
[{
message:
'Message'
}]
)
expect
(
result
).
to
be_persisted
expect
(
result
.
builds
.
any?
).
to
be_falsey
expect
(
result
.
status
).
to
eq
(
'skipped'
)
expect
(
result
.
yaml_errors
).
to
be_nil
end
it
'skips commits if yaml is invalid'
do
message
=
'message'
allow_any_instance_of
(
Ci
::
Commit
).
to
receive
(
:git_commit_message
)
{
message
}
stub_ci_commit_yaml_file
(
'invalid: file: file'
)
commits
=
[{
message:
message
}]
commit
=
service
.
execute
(
project
,
user
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
)
expect
(
commit
.
builds
.
any?
).
to
be
false
expect
(
commit
.
status
).
to
eq
(
'failed'
)
expect
(
commit
.
yaml_errors
).
to_not
be_nil
end
describe
:ci_skip?
do
let
(
:message
)
{
"some message[ci skip]"
}
before
do
allow_any_instance_of
(
Ci
::
Commit
).
to
receive
(
:git_commit_message
)
{
message
}
end
it
"skips builds creation if there is [ci skip] tag in commit message"
do
commits
=
[{
message:
message
}]
commit
=
service
.
execute
(
project
,
user
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
)
expect
(
commit
.
builds
.
any?
).
to
be
false
expect
(
commit
.
status
).
to
eq
(
"skipped"
)
end
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"
}
commits
=
[{
message:
"some message"
}]
commit
=
service
.
execute
(
project
,
user
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
)
expect
(
commit
.
builds
.
first
.
name
).
to
eq
(
"staging"
)
end
it
"skips builds creation if there is [ci skip] tag in commit message and yaml is invalid"
do
stub_ci_commit_yaml_file
(
'invalid: file: fiile'
)
commits
=
[{
message:
message
}]
commit
=
service
.
execute
(
project
,
user
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
)
expect
(
commit
.
builds
.
any?
).
to
be
false
expect
(
commit
.
status
).
to
eq
(
"skipped"
)
expect
(
commit
.
yaml_errors
).
to
be_nil
end
end
it
"skips build creation if there are already builds"
do
allow_any_instance_of
(
Ci
::
Commit
).
to
receive
(
:ci_yaml_file
)
{
gitlab_ci_yaml
}
commits
=
[{
message:
"message"
}]
commit
=
service
.
execute
(
project
,
user
,
ref:
'refs/heads/master'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
)
expect
(
commit
.
builds
.
count
(
:all
)).
to
eq
(
2
)
commit
=
service
.
execute
(
project
,
user
,
ref:
'refs/heads/master'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
)
expect
(
commit
.
builds
.
count
(
:all
)).
to
eq
(
2
)
end
it
"creates commit with failed status if yaml is invalid"
do
stub_ci_commit_yaml_file
(
'invalid: file'
)
commits
=
[{
message:
"some message"
}]
commit
=
service
.
execute
(
project
,
user
,
ref:
'refs/tags/0_1'
,
before:
'00000000'
,
after:
'31das312'
,
commits:
commits
)
expect
(
commit
.
status
).
to
eq
(
"failed"
)
expect
(
commit
.
builds
.
any?
).
to
be
false
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