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
f6b10751
Commit
f6b10751
authored
Sep 18, 2019
by
James Fargher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cache gitly path requests for pipeline rules
parent
7fbafab1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
3 deletions
+38
-3
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+12
-0
lib/gitlab/ci/build/rules/rule/clause/exists.rb
lib/gitlab/ci/build/rules/rule/clause/exists.rb
+2
-3
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+24
-0
No files found.
app/models/ci/pipeline.rb
View file @
f6b10751
...
@@ -771,6 +771,18 @@ module Ci
...
@@ -771,6 +771,18 @@ module Ci
end
end
end
end
def
all_worktree_paths
strong_memoize
(
:all_worktree_paths
)
do
project
.
repository
.
ls_files
(
sha
)
end
end
def
top_level_worktree_paths
strong_memoize
(
:top_level_worktree_paths
)
do
project
.
repository
.
tree
(
sha
).
blobs
.
map
(
&
:path
)
end
end
def
default_branch?
def
default_branch?
ref
==
project
.
default_branch
ref
==
project
.
default_branch
end
end
...
...
lib/gitlab/ci/build/rules/rule/clause/exists.rb
View file @
f6b10751
...
@@ -4,7 +4,6 @@ module Gitlab
...
@@ -4,7 +4,6 @@ module Gitlab
module
Ci
module
Ci
module
Build
module
Build
class
Rules::Rule::Clause::Exists
<
Rules
::
Rule
::
Clause
class
Rules::Rule::Clause::Exists
<
Rules
::
Rule
::
Clause
# The maximum number of patterned glob comparisons that will be
# The maximum number of patterned glob comparisons that will be
# performed before the rule assumes that it has a match
# performed before the rule assumes that it has a match
MAX_PATTERN_COMPARISONS
=
10_000
MAX_PATTERN_COMPARISONS
=
10_000
...
@@ -26,9 +25,9 @@ module Gitlab
...
@@ -26,9 +25,9 @@ module Gitlab
def
worktree_paths
(
pipeline
)
def
worktree_paths
(
pipeline
)
if
@top_level_only
if
@top_level_only
pipeline
.
project
.
repository
.
tree
(
pipeline
.
sha
).
blobs
.
map
(
&
:path
)
pipeline
.
top_level_worktree_paths
else
else
pipeline
.
project
.
repository
.
ls_files
(
pipeline
.
sha
)
pipeline
.
all_worktree_paths
end
end
end
end
...
...
spec/models/ci/pipeline_spec.rb
View file @
f6b10751
...
@@ -1755,6 +1755,30 @@ describe Ci::Pipeline, :mailer do
...
@@ -1755,6 +1755,30 @@ describe Ci::Pipeline, :mailer do
end
end
end
end
describe
'#all_worktree_paths'
do
let
(
:files
)
{
{
'main.go'
=>
''
,
'mocks/mocks.go'
=>
''
}
}
let
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
files
)
}
let
(
:pipeline
)
{
build
(
:ci_pipeline
,
project:
project
,
sha:
project
.
repository
.
head_commit
.
sha
)
}
it
'returns all file paths cached'
do
expect
(
project
.
repository
).
to
receive
(
:ls_files
).
with
(
pipeline
.
sha
).
once
.
and_call_original
expect
(
pipeline
.
all_worktree_paths
).
to
eq
(
files
.
keys
)
expect
(
pipeline
.
all_worktree_paths
).
to
eq
(
files
.
keys
)
end
end
describe
'#top_level_worktree_paths'
do
let
(
:files
)
{
{
'main.go'
=>
''
,
'mocks/mocks.go'
=>
''
}
}
let
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
files
)
}
let
(
:pipeline
)
{
build
(
:ci_pipeline
,
project:
project
,
sha:
project
.
repository
.
head_commit
.
sha
)
}
it
'returns top-level file paths cached'
do
expect
(
project
.
repository
).
to
receive
(
:tree
).
with
(
pipeline
.
sha
).
once
.
and_call_original
expect
(
pipeline
.
top_level_worktree_paths
).
to
eq
([
'main.go'
])
expect
(
pipeline
.
top_level_worktree_paths
).
to
eq
([
'main.go'
])
end
end
describe
'#has_kubernetes_active?'
do
describe
'#has_kubernetes_active?'
do
context
'when kubernetes is active'
do
context
'when kubernetes is active'
do
context
'when user configured kubernetes from CI/CD > Clusters'
do
context
'when user configured kubernetes from CI/CD > Clusters'
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