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
Jérome Perrin
gitlab-ce
Commits
af15b6f0
Commit
af15b6f0
authored
May 03, 2018
by
Dylan Griffith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Project#group_runners_enabled as it was doing nothing
parent
bf790c26
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
14 deletions
+28
-14
app/models/project.rb
app/models/project.rb
+6
-1
app/models/project_ci_cd_setting.rb
app/models/project_ci_cd_setting.rb
+1
-1
app/services/ci/register_job_service.rb
app/services/ci/register_job_service.rb
+4
-1
spec/services/ci/register_job_service_spec.rb
spec/services/ci/register_job_service_spec.rb
+17
-11
No files found.
app/models/project.rb
View file @
af15b6f0
...
@@ -234,7 +234,7 @@ class Project < ActiveRecord::Base
...
@@ -234,7 +234,7 @@ class Project < ActiveRecord::Base
has_many
:custom_attributes
,
class_name:
'ProjectCustomAttribute'
has_many
:custom_attributes
,
class_name:
'ProjectCustomAttribute'
has_many
:project_badges
,
class_name:
'ProjectBadge'
has_many
:project_badges
,
class_name:
'ProjectBadge'
has_one
:ci_cd_settings
,
class_name:
'ProjectCiCdSetting'
has_one
:ci_cd_settings
,
class_name:
'ProjectCiCdSetting'
,
inverse_of: :project
,
autosave:
true
accepts_nested_attributes_for
:variables
,
allow_destroy:
true
accepts_nested_attributes_for
:variables
,
allow_destroy:
true
accepts_nested_attributes_for
:project_feature
,
update_only:
true
accepts_nested_attributes_for
:project_feature
,
update_only:
true
...
@@ -331,6 +331,11 @@ class Project < ActiveRecord::Base
...
@@ -331,6 +331,11 @@ class Project < ActiveRecord::Base
scope
:with_issues_available_for_user
,
->
(
current_user
)
{
with_feature_available_for_user
(
:issues
,
current_user
)
}
scope
:with_issues_available_for_user
,
->
(
current_user
)
{
with_feature_available_for_user
(
:issues
,
current_user
)
}
scope
:with_merge_requests_enabled
,
->
{
with_feature_enabled
(
:merge_requests
)
}
scope
:with_merge_requests_enabled
,
->
{
with_feature_enabled
(
:merge_requests
)
}
scope
:with_group_runners_enabled
,
->
do
joins
(
:ci_cd_settings
)
.
where
(
project_ci_cd_settings:
{
group_runners_enabled:
true
})
end
enum
auto_cancel_pending_pipelines:
{
disabled:
0
,
enabled:
1
}
enum
auto_cancel_pending_pipelines:
{
disabled:
0
,
enabled:
1
}
chronic_duration_attr
:build_timeout_human_readable
,
:build_timeout
,
default:
3600
chronic_duration_attr
:build_timeout_human_readable
,
:build_timeout
,
default:
3600
...
...
app/models/project_ci_cd_setting.rb
View file @
af15b6f0
class
ProjectCiCdSetting
<
ActiveRecord
::
Base
class
ProjectCiCdSetting
<
ActiveRecord
::
Base
belongs_to
:project
belongs_to
:project
,
inverse_of: :ci_cd_settings
# The version of the schema that first introduced this model/table.
# The version of the schema that first introduced this model/table.
MINIMUM_SCHEMA_VERSION
=
20180403035759
MINIMUM_SCHEMA_VERSION
=
20180403035759
...
...
app/services/ci/register_job_service.rb
View file @
af15b6f0
...
@@ -91,7 +91,10 @@ module Ci
...
@@ -91,7 +91,10 @@ module Ci
def
builds_for_group_runner
def
builds_for_group_runner
hierarchy_groups
=
Gitlab
::
GroupHierarchy
.
new
(
runner
.
groups
).
base_and_descendants
hierarchy_groups
=
Gitlab
::
GroupHierarchy
.
new
(
runner
.
groups
).
base_and_descendants
projects
=
Project
.
where
(
namespace_id:
hierarchy_groups
)
projects
=
Project
.
where
(
namespace_id:
hierarchy_groups
)
new_builds
.
where
(
project:
projects
.
without_deleted
.
with_builds_enabled
).
order
(
'created_at ASC'
)
.
with_group_runners_enabled
.
with_builds_enabled
.
without_deleted
new_builds
.
where
(
project:
projects
).
order
(
'created_at ASC'
)
end
end
def
running_builds_for_shared_runners
def
running_builds_for_shared_runners
...
...
spec/services/ci/register_job_service_spec.rb
View file @
af15b6f0
...
@@ -2,13 +2,13 @@ require 'spec_helper'
...
@@ -2,13 +2,13 @@ require 'spec_helper'
module
Ci
module
Ci
describe
RegisterJobService
do
describe
RegisterJobService
do
let!
(
:project
)
{
create
:project
,
shared_runners_enabled:
false
}
set
(
:group
)
{
create
(
:group
)
}
let!
(
:group
)
{
create
:group
}
set
(
:project
)
{
create
(
:project
,
group:
group
,
shared_runners_enabled:
false
,
group_runners_enabled:
false
)
}
let!
(
:pipeline
)
{
create
:ci_pipeline
,
project:
project
}
set
(
:pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
let!
(
:
pending_job
)
{
create
:ci_build
,
pipeline:
pipeline
}
let!
(
:
shared_runner
)
{
create
(
:ci_runner
,
is_shared:
true
)
}
let!
(
:s
hared_runner
)
{
create
:ci_runner
,
is_shared:
true
}
let!
(
:s
pecific_runner
)
{
create
(
:ci_runner
,
is_shared:
false
)
}
let!
(
:
specific_runner
)
{
create
:ci_runner
,
is_shared:
false
}
let!
(
:
group_runner
)
{
create
(
:ci_runner
,
groups:
[
group
],
runner_type: :group_type
)
}
let!
(
:
group_runner
)
{
create
:ci_runner
,
groups:
[
group
],
runner_type: :group_type
}
let!
(
:
pending_job
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
before
do
before
do
specific_runner
.
assign_to
(
project
)
specific_runner
.
assign_to
(
project
)
...
@@ -152,7 +152,7 @@ module Ci
...
@@ -152,7 +152,7 @@ module Ci
context
'disallow when builds are disabled'
do
context
'disallow when builds are disabled'
do
before
do
before
do
project
.
update
(
shared_runners_enabled:
true
)
project
.
update
(
shared_runners_enabled:
true
,
group_runners_enabled:
true
)
project
.
project_feature
.
update_attribute
(
:builds_access_level
,
ProjectFeature
::
DISABLED
)
project
.
project_feature
.
update_attribute
(
:builds_access_level
,
ProjectFeature
::
DISABLED
)
end
end
...
@@ -162,7 +162,13 @@ module Ci
...
@@ -162,7 +162,13 @@ module Ci
it
{
expect
(
build
).
to
be_nil
}
it
{
expect
(
build
).
to
be_nil
}
end
end
context
'and uses specific runner'
do
context
'and uses group runner'
do
let
(
:build
)
{
execute
(
group_runner
)
}
it
{
expect
(
build
).
to
be_nil
}
end
context
'and uses project runner'
do
let
(
:build
)
{
execute
(
specific_runner
)
}
let
(
:build
)
{
execute
(
specific_runner
)
}
it
{
expect
(
build
).
to
be_nil
}
it
{
expect
(
build
).
to
be_nil
}
...
@@ -171,7 +177,7 @@ module Ci
...
@@ -171,7 +177,7 @@ module Ci
context
'allow group runners'
do
context
'allow group runners'
do
before
do
before
do
project
.
update!
(
group_runners_enabled:
true
,
group:
group
)
project
.
update!
(
group_runners_enabled:
true
)
end
end
context
'for multiple builds'
do
context
'for multiple builds'
do
...
@@ -230,7 +236,7 @@ module Ci
...
@@ -230,7 +236,7 @@ module Ci
context
'disallow group runners'
do
context
'disallow group runners'
do
before
do
before
do
project
.
update
(
group_runners_enabled:
false
)
project
.
update
!
(
group_runners_enabled:
false
)
end
end
context
'group runner'
do
context
'group runner'
do
...
...
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