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
83fe818f
Commit
83fe818f
authored
Jun 15, 2021
by
Marius Bobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add runner_ids to runner matchers
Add runner_ids to runner matchers
parent
6bcc37b3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
8 deletions
+28
-8
app/models/ci/runner.rb
app/models/ci/runner.rb
+9
-8
ee/spec/lib/ee/gitlab/ci/matching/runner_matcher_spec.rb
ee/spec/lib/ee/gitlab/ci/matching/runner_matcher_spec.rb
+1
-0
lib/gitlab/ci/matching/runner_matcher.rb
lib/gitlab/ci/matching/runner_matcher.rb
+1
-0
spec/lib/gitlab/ci/matching/runner_matcher_spec.rb
spec/lib/gitlab/ci/matching/runner_matcher_spec.rb
+3
-0
spec/models/ci/runner_spec.rb
spec/models/ci/runner_spec.rb
+14
-0
No files found.
app/models/ci/runner.rb
View file @
83fe818f
...
...
@@ -214,15 +214,15 @@ module Ci
Arel
.
sql
(
"(
#{
arel_tag_names_array
.
to_sql
}
)"
)
]
# we use distinct to de-duplicate data
distinct
.
pluck
(
*
unique_params
).
map
do
|
values
|
group
(
*
unique_params
).
pluck
(
'array_agg(ci_runners.id)'
,
*
unique_params
).
map
do
|
values
|
Gitlab
::
Ci
::
Matching
::
RunnerMatcher
.
new
({
runner_type:
values
[
0
],
public_projects_minutes_cost_factor:
values
[
1
],
private_projects_minutes_cost_factor:
values
[
2
],
run_untagged:
values
[
3
],
access_level:
values
[
4
],
tag_list:
values
[
5
]
runner_ids:
values
[
0
],
runner_type:
values
[
1
],
public_projects_minutes_cost_factor:
values
[
2
],
private_projects_minutes_cost_factor:
values
[
3
],
run_untagged:
values
[
4
],
access_level:
values
[
5
],
tag_list:
values
[
6
]
})
end
end
...
...
@@ -230,6 +230,7 @@ module Ci
def
runner_matcher
strong_memoize
(
:runner_matcher
)
do
Gitlab
::
Ci
::
Matching
::
RunnerMatcher
.
new
({
runner_ids:
[
id
],
runner_type:
runner_type
,
public_projects_minutes_cost_factor:
public_projects_minutes_cost_factor
,
private_projects_minutes_cost_factor:
private_projects_minutes_cost_factor
,
...
...
ee/spec/lib/ee/gitlab/ci/matching/runner_matcher_spec.rb
View file @
83fe818f
...
...
@@ -5,6 +5,7 @@ require 'spec_helper'
RSpec
.
describe
Gitlab
::
Ci
::
Matching
::
RunnerMatcher
do
let
(
:dummy_attributes
)
do
{
runner_ids:
[
1
],
runner_type:
'instance_type'
,
public_projects_minutes_cost_factor:
0.0
,
private_projects_minutes_cost_factor:
1.0
,
...
...
lib/gitlab/ci/matching/runner_matcher.rb
View file @
83fe818f
...
...
@@ -18,6 +18,7 @@ module Gitlab
#
class
RunnerMatcher
ATTRIBUTES
=
%i[
runner_ids
runner_type
public_projects_minutes_cost_factor
private_projects_minutes_cost_factor
...
...
spec/lib/gitlab/ci/matching/runner_matcher_spec.rb
View file @
83fe818f
...
...
@@ -5,6 +5,7 @@ require 'spec_helper'
RSpec
.
describe
Gitlab
::
Ci
::
Matching
::
RunnerMatcher
do
let
(
:dummy_attributes
)
do
{
runner_ids:
[
1
],
runner_type:
'instance_type'
,
public_projects_minutes_cost_factor:
0
,
private_projects_minutes_cost_factor:
1
,
...
...
@@ -26,6 +27,8 @@ RSpec.describe Gitlab::Ci::Matching::RunnerMatcher do
context
'with attributes'
do
let
(
:attributes
)
{
dummy_attributes
}
it
{
expect
(
matcher
.
runner_ids
).
to
eq
([
1
])
}
it
{
expect
(
matcher
.
runner_type
).
to
eq
(
'instance_type'
)
}
it
{
expect
(
matcher
.
public_projects_minutes_cost_factor
).
to
eq
(
0
)
}
...
...
spec/models/ci/runner_spec.rb
View file @
83fe818f
...
...
@@ -1086,6 +1086,18 @@ RSpec.describe Ci::Runner do
expect
(
matchers
.
map
(
&
:tag_list
)).
to
match_array
([
%w[tag1 tag2]
,
%w[tag3 tag4]
])
end
end
context
'with runner_ids'
do
before
do
create_list
(
:ci_runner
,
2
)
end
it
'includes runner_ids'
do
expect
(
matchers
.
size
).
to
eq
(
1
)
expect
(
matchers
.
first
.
runner_ids
).
to
match_array
(
described_class
.
all
.
pluck
(
:id
))
end
end
end
describe
'#runner_matcher'
do
...
...
@@ -1095,6 +1107,8 @@ RSpec.describe Ci::Runner do
subject
(
:matcher
)
{
runner
.
runner_matcher
}
it
{
expect
(
matcher
.
runner_ids
).
to
eq
([
runner
.
id
])
}
it
{
expect
(
matcher
.
runner_type
).
to
eq
(
runner
.
runner_type
)
}
it
{
expect
(
matcher
.
public_projects_minutes_cost_factor
).
to
eq
(
runner
.
public_projects_minutes_cost_factor
)
}
...
...
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