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
871de0f1
Commit
871de0f1
authored
Nov 23, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename artifacts_* to legacy_artifacts_*
parent
e2242cdf
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
85 additions
and
45 deletions
+85
-45
app/models/ci/build.rb
app/models/ci/build.rb
+2
-2
app/models/concerns/artifact_migratable.rb
app/models/concerns/artifact_migratable.rb
+9
-5
app/uploaders/job_artifact_uploader.rb
app/uploaders/job_artifact_uploader.rb
+5
-13
app/uploaders/legacy_artifact_uploader.rb
app/uploaders/legacy_artifact_uploader.rb
+33
-0
db/fixtures/development/14_pipelines.rb
db/fixtures/development/14_pipelines.rb
+2
-2
features/steps/project/pages.rb
features/steps/project/pages.rb
+2
-2
features/steps/shared/builds.rb
features/steps/shared/builds.rb
+2
-2
lib/backup/artifacts.rb
lib/backup/artifacts.rb
+1
-1
lib/gitlab/workhorse.rb
lib/gitlab/workhorse.rb
+1
-1
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+11
-0
spec/features/commits_spec.rb
spec/features/commits_spec.rb
+3
-3
spec/features/merge_requests/mini_pipeline_graph_spec.rb
spec/features/merge_requests/mini_pipeline_graph_spec.rb
+2
-2
spec/features/projects/jobs_spec.rb
spec/features/projects/jobs_spec.rb
+4
-4
spec/services/projects/update_pages_service_spec.rb
spec/services/projects/update_pages_service_spec.rb
+7
-7
spec/uploaders/legacy_artifact_uploader_spec.rb
spec/uploaders/legacy_artifact_uploader_spec.rb
+1
-1
No files found.
app/models/ci/build.rb
View file @
871de0f1
...
...
@@ -46,8 +46,8 @@ module Ci
scope
:manual_actions
,
->
()
{
where
(
when: :manual
,
status:
COMPLETED_STATUSES
+
[
:manual
])
}
scope
:ref_protected
,
->
{
where
(
protected:
true
)
}
mount_uploader
:
artifacts_file
,
ArtifactUploader
mount_uploader
:
artifacts_metadata
,
ArtifactUploader
mount_uploader
:
legacy_artifacts_file
,
LegacyArtifactUploader
,
mount_on: :artifacts_file
mount_uploader
:
legacy_artifacts_metadata
,
LegacyArtifactUploader
,
mount_on: :artifacts_metadata
acts_as_taggable
...
...
app/models/concerns/artifact_migratable.rb
View file @
871de0f1
...
...
@@ -3,11 +3,15 @@
# Meant to be prepended so the interface can stay the same
module
ArtifactMigratable
def
artifacts_file
job_archive
&
.
file
||
super
job_archive
&
.
file
||
legacy_artifacts_file
end
def
artifacts_file?
job_archive
&
.
file?
||
legacy_artifacts_file?
end
def
artifacts_metadata
job_metadata
&
.
file
||
super
job_metadata
&
.
file
||
legacy_artifacts_metadata
end
def
artifacts?
...
...
@@ -19,14 +23,14 @@ module ArtifactMigratable
end
def
artifacts_file_changed?
job_archive
&
.
file_changed?
||
super
job_archive
&
.
file_changed?
||
attribute_changed?
(
:artifacts_file
)
end
def
remove_artifacts_file!
if
job_archive
job_archive
.
destroy
else
super
remove_legacy_artifacts_file!
end
end
...
...
@@ -34,7 +38,7 @@ module ArtifactMigratable
if
job_metadata
job_metadata
.
destroy
else
super
remove_legacy_artifacts_metadata!
end
end
...
...
app/uploaders/job_artifact_uploader.rb
View file @
871de0f1
...
...
@@ -9,30 +9,22 @@ class JobArtifactUploader < GitlabUploader
File
.
join
(
self
.
local_artifacts_store
,
'tmp/uploads/'
)
end
def
initialize
(
artifact
,
_field
)
@artifact
=
artifact
end
def
size
return
super
if
@artifact
.
size
.
nil?
@artifact
.
size
end
return
super
if
model
.
size
.
nil?
def
store_dir
File
.
join
(
self
.
class
.
local_artifacts_store
,
default_path
)
model
.
size
end
private
def
default_path
creation_date
=
@artifact
.
created_at
.
utc
.
strftime
(
'%Y_%m_%d'
)
creation_date
=
model
.
created_at
.
utc
.
strftime
(
'%Y_%m_%d'
)
File
.
join
(
disk_hash
[
0
..
1
],
disk_hash
[
2
..
3
],
disk_hash
,
creation_date
,
@artifact
.
job_id
.
to_s
,
@artifact
.
id
.
to_s
)
creation_date
,
model
.
job_id
.
to_s
,
model
.
id
.
to_s
)
end
def
disk_hash
@disk_hash
||=
Digest
::
SHA2
.
hexdigest
(
@artifact
.
project_id
.
to_s
)
@disk_hash
||=
Digest
::
SHA2
.
hexdigest
(
model
.
project_id
.
to_s
)
end
end
app/uploaders/artifact_uploader.rb
→
app/uploaders/
legacy_
artifact_uploader.rb
View file @
871de0f1
class
ArtifactUploader
<
GitlabUploader
class
Legacy
ArtifactUploader
<
GitlabUploader
storage
:file
attr_reader
:job
,
:field
def
self
.
local_artifacts_store
def
self
.
local_store_path
Gitlab
.
config
.
artifacts
.
path
end
...
...
@@ -11,29 +9,25 @@ class ArtifactUploader < GitlabUploader
File
.
join
(
self
.
local_artifacts_store
,
'tmp/uploads/'
)
end
def
initialize
(
job
,
field
)
@job
,
@field
=
job
,
field
end
def
store_dir
default_local_path
end
def
cache_dir
File
.
join
(
self
.
class
.
local_
artifacts_store
,
'tmp/cache'
)
File
.
join
(
self
.
class
.
local_
store_path
,
'tmp/cache'
)
end
def
work_dir
File
.
join
(
self
.
class
.
local_
artifacts_store
,
'tmp/work'
)
File
.
join
(
self
.
class
.
local_
store_path
,
'tmp/work'
)
end
private
def
default_local_path
File
.
join
(
self
.
class
.
local_
artifacts_store
,
default_path
)
File
.
join
(
self
.
class
.
local_
store_path
,
default_path
)
end
def
default_path
File
.
join
(
job
.
created_at
.
utc
.
strftime
(
'%Y_%m'
),
job
.
project_id
.
to_s
,
job
.
id
.
to_s
)
File
.
join
(
model
.
created_at
.
utc
.
strftime
(
'%Y_%m'
),
model
.
project_id
.
to_s
,
model
.
id
.
to_s
)
end
end
db/fixtures/development/14_pipelines.rb
View file @
871de0f1
...
...
@@ -124,11 +124,11 @@ class Gitlab::Seeder::Pipelines
return
unless
%w[build test]
.
include?
(
build
.
stage
)
artifacts_cache_file
(
artifacts_archive_path
)
do
|
file
|
build
.
artifacts_file
=
file
build
.
job_artifacts
.
build
(
project:
build
.
project
,
file_type: :archive
,
file:
file
)
end
artifacts_cache_file
(
artifacts_metadata_path
)
do
|
file
|
build
.
artifacts_metadata
=
file
build
.
job_artifacts
.
build
(
project:
build
.
project
,
file_type: :metadata
,
file:
file
)
end
end
...
...
features/steps/project/pages.rb
View file @
871de0f1
...
...
@@ -44,8 +44,8 @@ class Spinach::Features::ProjectPages < Spinach::FeatureSteps
project:
@project
,
pipeline:
pipeline
,
ref:
'HEAD'
,
artifacts_file:
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/pages.zip'
),
artifacts_metadata:
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/pages.zip.meta'
)
legacy_
artifacts_file:
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/pages.zip'
),
legacy_
artifacts_metadata:
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/pages.zip.meta'
)
)
result
=
::
Projects
::
UpdatePagesService
.
new
(
@project
,
build
).
execute
...
...
features/steps/shared/builds.rb
View file @
871de0f1
...
...
@@ -37,13 +37,13 @@ module SharedBuilds
step
'recent build has artifacts available'
do
artifacts
=
Rails
.
root
+
'spec/fixtures/ci_build_artifacts.zip'
archive
=
fixture_file_upload
(
artifacts
,
'application/zip'
)
@build
.
update_attributes
(
artifacts_file:
archive
)
@build
.
update_attributes
(
legacy_
artifacts_file:
archive
)
end
step
'recent build has artifacts metadata available'
do
metadata
=
Rails
.
root
+
'spec/fixtures/ci_build_artifacts_metadata.gz'
gzip
=
fixture_file_upload
(
metadata
,
'application/x-gzip'
)
@build
.
update_attributes
(
artifacts_metadata:
gzip
)
@build
.
update_attributes
(
legacy_
artifacts_metadata:
gzip
)
end
step
'recent build has a build trace'
do
...
...
lib/backup/artifacts.rb
View file @
871de0f1
...
...
@@ -3,7 +3,7 @@ require 'backup/files'
module
Backup
class
Artifacts
<
Files
def
initialize
super
(
'artifacts'
,
ArtifactUploader
.
local_artifacts_store
)
super
(
'artifacts'
,
LegacyArtifactUploader
.
local_store_path
)
end
def
create_files_dir
...
...
lib/gitlab/workhorse.rb
View file @
871de0f1
...
...
@@ -58,7 +58,7 @@ module Gitlab
end
def
artifact_upload_ok
{
TempPath
:
ArtifactUploader
.
artifacts_upload_path
}
{
TempPath
:
Legacy
ArtifactUploader
.
artifacts_upload_path
}
end
def
send_git_blob
(
repository
,
blob
)
...
...
spec/factories/ci/builds.rb
View file @
871de0f1
...
...
@@ -154,6 +154,17 @@ FactoryGirl.define do
runner
factory: :ci_runner
end
trait
:legacy_artifacts
do
after
(
:create
)
do
|
build
,
_
|
build
.
update!
(
legacy_artifacts_file:
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/ci_build_artifacts.zip'
),
'application/zip'
),
legacy_artifacts_metadata:
fixture_file_upload
(
Rails
.
root
.
join
(
'spec/fixtures/ci_build_artifacts_metadata.gz'
),
'application/x-gzip'
)
)
end
end
trait
:artifacts
do
after
(
:create
)
do
|
build
|
create
(
:ci_job_artifact
,
job:
build
)
...
...
spec/features/commits_spec.rb
View file @
871de0f1
...
...
@@ -89,7 +89,7 @@ describe 'Commits' do
context
'Download artifacts'
do
before
do
build
.
update_attributes
(
artifacts_file:
artifacts_file
)
build
.
update_attributes
(
legacy_
artifacts_file:
artifacts_file
)
end
it
do
...
...
@@ -146,7 +146,7 @@ describe 'Commits' do
context
"when logged as reporter"
do
before
do
project
.
team
<<
[
user
,
:reporter
]
build
.
update_attributes
(
artifacts_file:
artifacts_file
)
build
.
update_attributes
(
legacy_
artifacts_file:
artifacts_file
)
visit
pipeline_path
(
pipeline
)
end
...
...
@@ -168,7 +168,7 @@ describe 'Commits' do
project
.
update
(
visibility_level:
Gitlab
::
VisibilityLevel
::
INTERNAL
,
public_builds:
false
)
build
.
update_attributes
(
artifacts_file:
artifacts_file
)
build
.
update_attributes
(
legacy_
artifacts_file:
artifacts_file
)
visit
pipeline_path
(
pipeline
)
end
...
...
spec/features/merge_requests/mini_pipeline_graph_spec.rb
View file @
871de0f1
...
...
@@ -28,14 +28,14 @@ feature 'Mini Pipeline Graph', :js do
let
(
:artifacts_file2
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/dk.png'
,
'image/png'
)
}
before
do
create
(
:ci_build
,
pipeline:
pipeline
,
artifacts_file:
artifacts_file1
)
create
(
:ci_build
,
pipeline:
pipeline
,
legacy_
artifacts_file:
artifacts_file1
)
create
(
:ci_build
,
pipeline:
pipeline
,
when:
'manual'
)
end
it
'avoids repeated database queries'
do
before
=
ActiveRecord
::
QueryRecorder
.
new
{
visit_merge_request
(
:json
)
}
create
(
:ci_build
,
pipeline:
pipeline
,
artifacts_file:
artifacts_file2
)
create
(
:ci_build
,
pipeline:
pipeline
,
legacy_
artifacts_file:
artifacts_file2
)
create
(
:ci_build
,
pipeline:
pipeline
,
when:
'manual'
)
after
=
ActiveRecord
::
QueryRecorder
.
new
{
visit_merge_request
(
:json
)
}
...
...
spec/features/projects/jobs_spec.rb
View file @
871de0f1
...
...
@@ -187,7 +187,7 @@ feature 'Jobs' do
context
"Download artifacts"
do
before
do
job
.
update_attributes
(
artifacts_file:
artifacts_file
)
job
.
update_attributes
(
legacy_
artifacts_file:
artifacts_file
)
visit
project_job_path
(
project
,
job
)
end
...
...
@@ -198,7 +198,7 @@ feature 'Jobs' do
context
'Artifacts expire date'
do
before
do
job
.
update_attributes
(
artifacts_file:
artifacts_file
,
job
.
update_attributes
(
legacy_
artifacts_file:
artifacts_file
,
artifacts_expire_at:
expire_at
)
visit
project_job_path
(
project
,
job
)
...
...
@@ -422,14 +422,14 @@ feature 'Jobs' do
describe
"GET /:project/jobs/:id/download"
do
before
do
job
.
update_attributes
(
artifacts_file:
artifacts_file
)
job
.
update_attributes
(
legacy_
artifacts_file:
artifacts_file
)
visit
project_job_path
(
project
,
job
)
click_link
'Download'
end
context
"Build from other project"
do
before
do
job2
.
update_attributes
(
artifacts_file:
artifacts_file
)
job2
.
update_attributes
(
legacy_
artifacts_file:
artifacts_file
)
visit
download_project_job_artifacts_path
(
project
,
job2
)
end
...
...
spec/services/projects/update_pages_service_spec.rb
View file @
871de0f1
...
...
@@ -22,8 +22,8 @@ describe Projects::UpdatePagesService do
end
before
do
build
.
update_attributes
(
artifacts_file:
file
)
build
.
update_attributes
(
artifacts_metadata:
metadata
)
build
.
update_attributes
(
legacy_
artifacts_file:
file
)
build
.
update_attributes
(
legacy_
artifacts_metadata:
metadata
)
end
describe
'pages artifacts'
do
...
...
@@ -75,12 +75,12 @@ describe Projects::UpdatePagesService do
it
'fails if sha on branch is not latest'
do
pipeline
.
update_attributes
(
sha:
'old_sha'
)
build
.
update_attributes
(
artifacts_file:
file
)
build
.
update_attributes
(
legacy_
artifacts_file:
file
)
expect
(
execute
).
not_to
eq
(
:success
)
end
it
'fails for empty file fails'
do
build
.
update_attributes
(
artifacts_file:
empty_file
)
build
.
update_attributes
(
legacy_
artifacts_file:
empty_file
)
expect
(
execute
).
not_to
eq
(
:success
)
end
end
...
...
@@ -97,7 +97,7 @@ describe Projects::UpdatePagesService do
end
it
'fails for invalid archive'
do
build
.
update_attributes
(
artifacts_file:
invalid_file
)
build
.
update_attributes
(
legacy_
artifacts_file:
invalid_file
)
expect
(
execute
).
not_to
eq
(
:success
)
end
...
...
@@ -108,8 +108,8 @@ describe Projects::UpdatePagesService do
file
=
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/pages.zip'
)
metafile
=
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/pages.zip.meta'
)
build
.
update_attributes
(
artifacts_file:
file
)
build
.
update_attributes
(
artifacts_metadata:
metafile
)
build
.
update_attributes
(
legacy_
artifacts_file:
file
)
build
.
update_attributes
(
legacy_
artifacts_metadata:
metafile
)
allow
(
build
).
to
receive
(
:artifacts_metadata_entry
)
.
and_return
(
metadata
)
...
...
spec/uploaders/artifact_uploader_spec.rb
→
spec/uploaders/
legacy_
artifact_uploader_spec.rb
View file @
871de0f1
require
'rails_helper'
describe
ArtifactUploader
do
describe
Legacy
ArtifactUploader
do
set
(
:job
)
{
create
(
:ci_build
)
}
let
(
:uploader
)
{
described_class
.
new
(
job
,
:artifacts_file
)
}
let
(
:path
)
{
Gitlab
.
config
.
artifacts
.
path
}
...
...
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