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
75bd4f8c
Commit
75bd4f8c
authored
Apr 26, 2021
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab master
parents
2bbeaf70
4d1545a6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
47 deletions
+49
-47
lib/gitlab/artifacts/migration_helper.rb
lib/gitlab/artifacts/migration_helper.rb
+0
-33
lib/gitlab/ci/artifacts/migration_helper.rb
lib/gitlab/ci/artifacts/migration_helper.rb
+35
-0
lib/tasks/gitlab/artifacts/migrate.rake
lib/tasks/gitlab/artifacts/migrate.rake
+2
-2
spec/frontend/branches/components/__snapshots__/divergence_graph_spec.js.snap
...es/components/__snapshots__/divergence_graph_spec.js.snap
+2
-2
spec/frontend/branches/components/divergence_graph_spec.js
spec/frontend/branches/components/divergence_graph_spec.js
+6
-6
spec/frontend/branches/divergence_graph_spec.js
spec/frontend/branches/divergence_graph_spec.js
+4
-4
No files found.
lib/gitlab/artifacts/migration_helper.rb
deleted
100644 → 0
View file @
2bbeaf70
# frozen_string_literal: true
module
Gitlab
module
Artifacts
class
MigrationHelper
def
migrate_to_remote_storage
(
&
block
)
artifacts
=
::
Ci
::
JobArtifact
.
with_files_stored_locally
migrate
(
artifacts
,
ObjectStorage
::
Store
::
REMOTE
,
&
block
)
end
def
migrate_to_local_storage
(
&
block
)
artifacts
=
::
Ci
::
JobArtifact
.
with_files_stored_remotely
migrate
(
artifacts
,
ObjectStorage
::
Store
::
LOCAL
,
&
block
)
end
private
def
batch_size
ENV
.
fetch
(
'MIGRATION_BATCH_SIZE'
,
10
).
to_i
end
def
migrate
(
artifacts
,
store
,
&
block
)
artifacts
.
find_each
(
batch_size:
batch_size
)
do
|
artifact
|
# rubocop:disable CodeReuse/ActiveRecord
artifact
.
file
.
migrate!
(
store
)
yield
artifact
if
block
rescue
StandardError
=>
e
raise
StandardError
.
new
(
"Failed to transfer artifact of type
#{
artifact
.
file_type
}
and ID
#{
artifact
.
id
}
with error:
#{
e
.
message
}
"
)
end
end
end
end
end
lib/gitlab/ci/artifacts/migration_helper.rb
0 → 100644
View file @
75bd4f8c
# frozen_string_literal: true
module
Gitlab
module
Ci
module
Artifacts
class
MigrationHelper
def
migrate_to_remote_storage
(
&
block
)
artifacts
=
::
Ci
::
JobArtifact
.
with_files_stored_locally
migrate
(
artifacts
,
ObjectStorage
::
Store
::
REMOTE
,
&
block
)
end
def
migrate_to_local_storage
(
&
block
)
artifacts
=
::
Ci
::
JobArtifact
.
with_files_stored_remotely
migrate
(
artifacts
,
ObjectStorage
::
Store
::
LOCAL
,
&
block
)
end
private
def
batch_size
ENV
.
fetch
(
'MIGRATION_BATCH_SIZE'
,
10
).
to_i
end
def
migrate
(
artifacts
,
store
,
&
block
)
artifacts
.
find_each
(
batch_size:
batch_size
)
do
|
artifact
|
# rubocop:disable CodeReuse/ActiveRecord
artifact
.
file
.
migrate!
(
store
)
yield
artifact
if
block
rescue
StandardError
=>
e
raise
StandardError
.
new
(
"Failed to transfer artifact of type
#{
artifact
.
file_type
}
and ID
#{
artifact
.
id
}
with error:
#{
e
.
message
}
"
)
end
end
end
end
end
end
lib/tasks/gitlab/artifacts/migrate.rake
View file @
75bd4f8c
...
...
@@ -10,7 +10,7 @@ namespace :gitlab do
logger
=
Logger
.
new
(
STDOUT
)
logger
.
info
(
'Starting transfer of artifacts to remote storage'
)
helper
=
Gitlab
::
Artifacts
::
MigrationHelper
.
new
helper
=
Gitlab
::
Ci
::
Artifacts
::
MigrationHelper
.
new
begin
helper
.
migrate_to_remote_storage
do
|
artifact
|
...
...
@@ -25,7 +25,7 @@ namespace :gitlab do
logger
=
Logger
.
new
(
STDOUT
)
logger
.
info
(
'Starting transfer of artifacts to local storage'
)
helper
=
Gitlab
::
Artifacts
::
MigrationHelper
.
new
helper
=
Gitlab
::
Ci
::
Artifacts
::
MigrationHelper
.
new
begin
helper
.
migrate_to_local_storage
do
|
artifact
|
...
...
spec/frontend/branches/components/__snapshots__/divergence_graph_spec.js.snap
View file @
75bd4f8c
...
...
@@ -3,7 +3,7 @@
exports[`Branch divergence graph component renders ahead and behind count 1`] = `
<div
class="divergence-graph px-2 d-none d-md-block"
title="10 commits behind ma
ster
, 10 commits ahead"
title="10 commits behind ma
in
, 10 commits ahead"
>
<graph-bar-stub
count="10"
...
...
@@ -26,7 +26,7 @@ exports[`Branch divergence graph component renders ahead and behind count 1`] =
exports[`Branch divergence graph component renders distance count 1`] = `
<div
class="divergence-graph px-2 d-none d-md-block"
title="More than 900 commits different with ma
ster
"
title="More than 900 commits different with ma
in
"
>
<graph-bar-stub
count="900"
...
...
spec/frontend/branches/components/divergence_graph_spec.js
View file @
75bd4f8c
...
...
@@ -15,7 +15,7 @@ describe('Branch divergence graph component', () => {
it
(
'
renders ahead and behind count
'
,
()
=>
{
factory
({
defaultBranch
:
'
ma
ster
'
,
defaultBranch
:
'
ma
in
'
,
aheadCount
:
10
,
behindCount
:
10
,
maxCommits
:
100
,
...
...
@@ -27,18 +27,18 @@ describe('Branch divergence graph component', () => {
it
(
'
sets title for ahead and behind count
'
,
()
=>
{
factory
({
defaultBranch
:
'
ma
ster
'
,
defaultBranch
:
'
ma
in
'
,
aheadCount
:
10
,
behindCount
:
10
,
maxCommits
:
100
,
});
expect
(
vm
.
attributes
(
'
title
'
)).
toBe
(
'
10 commits behind ma
ster
, 10 commits ahead
'
);
expect
(
vm
.
attributes
(
'
title
'
)).
toBe
(
'
10 commits behind ma
in
, 10 commits ahead
'
);
});
it
(
'
renders distance count
'
,
()
=>
{
factory
({
defaultBranch
:
'
ma
ster
'
,
defaultBranch
:
'
ma
in
'
,
aheadCount
:
0
,
behindCount
:
0
,
distance
:
900
,
...
...
@@ -55,13 +55,13 @@ describe('Branch divergence graph component', () => {
${
1100
}
|
${
'
999+
'
}
`
(
'
sets title for $distance as $titleText
'
,
({
distance
,
titleText
})
=>
{
factory
({
defaultBranch
:
'
ma
ster
'
,
defaultBranch
:
'
ma
in
'
,
aheadCount
:
0
,
behindCount
:
0
,
distance
,
maxCommits
:
100
,
});
expect
(
vm
.
attributes
(
'
title
'
)).
toBe
(
`More than
${
titleText
}
commits different with ma
ster
`
);
expect
(
vm
.
attributes
(
'
title
'
)).
toBe
(
`More than
${
titleText
}
commits different with ma
in
`
);
});
});
spec/frontend/branches/divergence_graph_spec.js
View file @
75bd4f8c
...
...
@@ -9,14 +9,14 @@ describe('Divergence graph', () => {
mock
=
new
MockAdapter
(
axios
);
mock
.
onGet
(
'
/-/diverging_counts
'
).
reply
(
200
,
{
ma
ster
:
{
ahead
:
1
,
behind
:
1
},
ma
in
:
{
ahead
:
1
,
behind
:
1
},
'
test/hello-world
'
:
{
ahead
:
1
,
behind
:
1
},
});
jest
.
spyOn
(
axios
,
'
get
'
);
document
.
body
.
innerHTML
=
`
<div class="js-branch-item" data-name="ma
ster
"><div class="js-branch-divergence-graph"></div></div>
<div class="js-branch-item" data-name="ma
in
"><div class="js-branch-divergence-graph"></div></div>
<div class="js-branch-item" data-name="test/hello-world"><div class="js-branch-divergence-graph"></div></div>
`
;
});
...
...
@@ -28,7 +28,7 @@ describe('Divergence graph', () => {
it
(
'
calls axios get with list of branch names
'
,
()
=>
init
(
'
/-/diverging_counts
'
).
then
(()
=>
{
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
'
/-/diverging_counts
'
,
{
params
:
{
names
:
[
'
ma
ster
'
,
'
test/hello-world
'
]
},
params
:
{
names
:
[
'
ma
in
'
,
'
test/hello-world
'
]
},
});
}));
...
...
@@ -46,7 +46,7 @@ describe('Divergence graph', () => {
it
(
'
creates Vue components
'
,
()
=>
init
(
'
/-/diverging_counts
'
).
then
(()
=>
{
expect
(
document
.
querySelector
(
'
[data-name="ma
ster
"]
'
).
innerHTML
).
not
.
toEqual
(
''
);
expect
(
document
.
querySelector
(
'
[data-name="ma
in
"]
'
).
innerHTML
).
not
.
toEqual
(
''
);
expect
(
document
.
querySelector
(
'
[data-name="test/hello-world"]
'
).
innerHTML
).
not
.
toEqual
(
''
);
}));
});
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