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
319dea10
Commit
319dea10
authored
Dec 25, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add latest changes from gitlab-org/gitlab@master
parent
cdd95ddd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
3 deletions
+55
-3
app/helpers/gitlab_routing_helper.rb
app/helpers/gitlab_routing_helper.rb
+23
-0
app/serializers/build_artifact_entity.rb
app/serializers/build_artifact_entity.rb
+4
-3
changelogs/unreleased/sh-speed-up-build-artifact-entry.yml
changelogs/unreleased/sh-speed-up-build-artifact-entry.yml
+5
-0
spec/helpers/gitlab_routing_helper_spec.rb
spec/helpers/gitlab_routing_helper_spec.rb
+23
-0
No files found.
app/helpers/gitlab_routing_helper.rb
View file @
319dea10
...
...
@@ -153,6 +153,29 @@ module GitlabRoutingHelper
# Artifacts
# Rails path generators are slow because they need to do large regex comparisons
# against the arguments. We can speed this up 10x by generating the strings directly.
# /*namespace_id/:project_id/-/jobs/:job_id/artifacts/download(.:format)
def
fast_download_project_job_artifacts_path
(
project
,
job
)
expose_fast_artifacts_path
(
project
,
job
,
:download
)
end
# /*namespace_id/:project_id/-/jobs/:job_id/artifacts/keep(.:format)
def
fast_keep_project_job_artifacts_path
(
project
,
job
)
expose_fast_artifacts_path
(
project
,
job
,
:keep
)
end
# /*namespace_id/:project_id/-/jobs/:job_id/artifacts/browse(/*path)
def
fast_browse_project_job_artifacts_path
(
project
,
job
)
expose_fast_artifacts_path
(
project
,
job
,
:browse
)
end
def
expose_fast_artifacts_path
(
project
,
job
,
action
)
path
=
"
#{
project
.
full_path
}
/-/jobs/
#{
job
.
id
}
/artifacts/
#{
action
}
"
Gitlab
::
Utils
.
append_path
(
Gitlab
.
config
.
gitlab
.
relative_url_root
,
path
)
end
def
artifacts_action_path
(
path
,
project
,
build
)
action
,
path_params
=
path
.
split
(
'/'
,
2
)
args
=
[
project
,
build
,
path_params
]
...
...
app/serializers/build_artifact_entity.rb
View file @
319dea10
...
...
@@ -2,6 +2,7 @@
class
BuildArtifactEntity
<
Grape
::
Entity
include
RequestAwareEntity
include
GitlabRoutingHelper
expose
:name
do
|
job
|
job
.
name
...
...
@@ -11,15 +12,15 @@ class BuildArtifactEntity < Grape::Entity
expose
:artifacts_expire_at
,
as: :expire_at
expose
:path
do
|
job
|
download_project_job_artifacts_path
(
project
,
job
)
fast_
download_project_job_artifacts_path
(
project
,
job
)
end
expose
:keep_path
,
if:
->
(
*
)
{
job
.
has_expiring_artifacts?
}
do
|
job
|
keep_project_job_artifacts_path
(
project
,
job
)
fast_
keep_project_job_artifacts_path
(
project
,
job
)
end
expose
:browse_path
do
|
job
|
browse_project_job_artifacts_path
(
project
,
job
)
fast_
browse_project_job_artifacts_path
(
project
,
job
)
end
private
...
...
changelogs/unreleased/sh-speed-up-build-artifact-entry.yml
0 → 100644
View file @
319dea10
---
title
:
Speed up path generation with build artifacts
merge_request
:
22257
author
:
type
:
performance
spec/helpers/gitlab_routing_helper_spec.rb
View file @
319dea10
...
...
@@ -113,6 +113,29 @@ describe GitlabRoutingHelper do
end
end
context
'artifacts'
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:job
)
{
create
(
:ci_build
,
project:
project
,
name:
'test:job'
,
artifacts_expire_at:
1
.
hour
.
from_now
)
}
describe
'#fast_download_project_job_artifacts_path'
do
it
'matches the Rails download path'
do
expect
(
fast_download_project_job_artifacts_path
(
project
,
job
)).
to
eq
(
download_project_job_artifacts_path
(
project
,
job
))
end
end
describe
'#fast_keep_project_job_artifacts_path'
do
it
'matches the Rails keep path'
do
expect
(
fast_keep_project_job_artifacts_path
(
project
,
job
)).
to
eq
(
keep_project_job_artifacts_path
(
project
,
job
))
end
end
describe
'#fast_browse_project_job_artifacts_path'
do
it
'matches the Rails browse path'
do
expect
(
fast_browse_project_job_artifacts_path
(
project
,
job
)).
to
eq
(
browse_project_job_artifacts_path
(
project
,
job
))
end
end
end
context
'snippets'
do
let_it_be
(
:personal_snippet
)
{
create
(
:personal_snippet
)
}
let_it_be
(
:project_snippet
)
{
create
(
:project_snippet
)
}
...
...
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