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
2045a771
Commit
2045a771
authored
Nov 30, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename `job_archive|metadata` to `artifacts_archive|metadata`
parent
2a620e74
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
14 deletions
+17
-14
app/models/ci/build.rb
app/models/ci/build.rb
+2
-2
app/models/concerns/artifact_migratable.rb
app/models/concerns/artifact_migratable.rb
+8
-8
app/models/project_statistics.rb
app/models/project_statistics.rb
+3
-0
spec/services/ci/retry_build_service_spec.rb
spec/services/ci/retry_build_service_spec.rb
+1
-1
spec/workers/expire_build_instance_artifacts_worker_spec.rb
spec/workers/expire_build_instance_artifacts_worker_spec.rb
+3
-3
No files found.
app/models/ci/build.rb
View file @
2045a771
...
...
@@ -16,8 +16,8 @@ module Ci
has_many
:trace_sections
,
class_name:
'Ci::BuildTraceSection'
has_many
:job_artifacts
,
class_name:
'Ci::JobArtifact'
,
foreign_key: :job_id
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_one
:
job
_archive
,
->
()
{
where
(
file_type:
Ci
::
JobArtifact
.
file_types
[
:archive
])
},
class_name:
'Ci::JobArtifact'
,
foreign_key: :job_id
has_one
:
job
_metadata
,
->
()
{
where
(
file_type:
Ci
::
JobArtifact
.
file_types
[
:metadata
])
},
class_name:
'Ci::JobArtifact'
,
foreign_key: :job_id
has_one
:
artifacts
_archive
,
->
()
{
where
(
file_type:
Ci
::
JobArtifact
.
file_types
[
:archive
])
},
class_name:
'Ci::JobArtifact'
,
foreign_key: :job_id
has_one
:
artifacts
_metadata
,
->
()
{
where
(
file_type:
Ci
::
JobArtifact
.
file_types
[
:metadata
])
},
class_name:
'Ci::JobArtifact'
,
foreign_key: :job_id
# The "environment" field for builds is a String, and is the unexpanded name
def
persisted_environment
...
...
app/models/concerns/artifact_migratable.rb
View file @
2045a771
...
...
@@ -3,11 +3,11 @@
# Meant to be prepended so the interface can stay the same
module
ArtifactMigratable
def
artifacts_file
job
_archive
&
.
file
||
legacy_artifacts_file
artifacts
_archive
&
.
file
||
legacy_artifacts_file
end
def
artifacts_metadata
job
_metadata
&
.
file
||
legacy_artifacts_metadata
artifacts
_metadata
&
.
file
||
legacy_artifacts_metadata
end
def
artifacts?
...
...
@@ -19,20 +19,20 @@ module ArtifactMigratable
end
def
artifacts_file_changed?
job
_archive
&
.
file_changed?
||
attribute_changed?
(
:artifacts_file
)
artifacts
_archive
&
.
file_changed?
||
attribute_changed?
(
:artifacts_file
)
end
def
remove_artifacts_file!
if
job
_archive
job
_archive
.
destroy
if
artifacts
_archive
artifacts
_archive
.
destroy
else
remove_legacy_artifacts_file!
end
end
def
remove_artifacts_metadata!
if
job
_metadata
job
_metadata
.
destroy
if
artifacts
_metadata
artifacts
_metadata
.
destroy
else
remove_legacy_artifacts_metadata!
end
...
...
@@ -40,6 +40,6 @@ module ArtifactMigratable
def
artifacts_size
read_attribute
(
:artifacts_size
).
to_i
+
job_archive
&
.
size
.
to_i
+
job
_metadata
&
.
size
.
to_i
artifacts_archive
&
.
size
.
to_i
+
artifacts
_metadata
&
.
size
.
to_i
end
end
app/models/project_statistics.rb
View file @
2045a771
...
...
@@ -35,6 +35,9 @@ class ProjectStatistics < ActiveRecord::Base
end
def
update_build_artifacts_size
# REMARK:
# We perform dual calculation as we run SQL query: sum does not instantiate AR model.
# The Ci::Build#artifacts_size returns sum of ci_builds.artifacts_size and ci_job_artifacts.file_size
self
.
build_artifacts_size
=
project
.
builds
.
sum
(
:artifacts_size
)
+
Ci
::
JobArtifact
.
artifacts_size_for
(
self
)
...
...
spec/services/ci/retry_build_service_spec.rb
View file @
2045a771
...
...
@@ -17,7 +17,7 @@ describe Ci::RetryBuildService do
%i[id status user token coverage trace runner artifacts_expire_at
artifacts_file artifacts_metadata artifacts_size created_at
updated_at started_at finished_at queued_at erased_by
erased_at auto_canceled_by job_artifacts
job_archive job
_metadata]
.
freeze
erased_at auto_canceled_by job_artifacts
artifacts_archive artifacts
_metadata]
.
freeze
IGNORE_ACCESSORS
=
%i[type lock_version target_url base_tags trace_sections
...
...
spec/workers/expire_build_instance_artifacts_worker_spec.rb
View file @
2045a771
...
...
@@ -23,7 +23,7 @@ describe ExpireBuildInstanceArtifactsWorker do
end
it
'does remove the job artifact record'
do
expect
(
build
.
reload
.
job
_archive
).
to
be_nil
expect
(
build
.
reload
.
artifacts
_archive
).
to
be_nil
end
end
end
...
...
@@ -42,7 +42,7 @@ describe ExpireBuildInstanceArtifactsWorker do
end
it
'does not remove the job artifact record'
do
expect
(
build
.
reload
.
job
_archive
).
not_to
be_nil
expect
(
build
.
reload
.
artifacts
_archive
).
not_to
be_nil
end
end
...
...
@@ -58,7 +58,7 @@ describe ExpireBuildInstanceArtifactsWorker do
end
it
'does not remove the job artifact record'
do
expect
(
build
.
reload
.
job
_archive
).
not_to
be_nil
expect
(
build
.
reload
.
artifacts
_archive
).
not_to
be_nil
end
end
...
...
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