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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
c8102d93
Commit
c8102d93
authored
Feb 01, 2016
by
Grzegorz Bizon
Committed by
Grzegorz Bizon
Feb 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add build eraseable feature implementation
parent
89b18120
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
90 additions
and
11 deletions
+90
-11
app/controllers/projects/builds_controller.rb
app/controllers/projects/builds_controller.rb
+4
-4
app/models/ci/build/eraseable.rb
app/models/ci/build/eraseable.rb
+18
-3
app/views/projects/builds/show.html.haml
app/views/projects/builds/show.html.haml
+5
-4
config/routes.rb
config/routes.rb
+1
-0
spec/models/ci/build/eraseable_spec.rb
spec/models/ci/build/eraseable_spec.rb
+62
-0
No files found.
app/controllers/projects/builds_controller.rb
View file @
c8102d93
...
@@ -56,10 +56,10 @@ class Projects::BuildsController < Projects::ApplicationController
...
@@ -56,10 +56,10 @@ class Projects::BuildsController < Projects::ApplicationController
render
json:
@build
.
to_json
(
only:
[
:status
,
:id
,
:sha
,
:coverage
],
methods: :sha
)
render
json:
@build
.
to_json
(
only:
[
:status
,
:id
,
:sha
,
:coverage
],
methods: :sha
)
end
end
def
destroy
def
erase
@build
.
destroy
@build
.
erase!
redirect_to
namespace_project_build
s_path
(
project
.
namespace
,
project
),
redirect_to
namespace_project_build
_path
(
project
.
namespace
,
project
,
@build
),
notice:
"Build #
#{
@build
.
id
}
has been sucessfully
remov
ed!"
notice:
"Build #
#{
@build
.
id
}
has been sucessfully
eras
ed!"
end
end
private
private
...
...
app/models/ci/build/eraseable.rb
View file @
c8102d93
...
@@ -4,11 +4,26 @@ module Ci
...
@@ -4,11 +4,26 @@ module Ci
include
ActiveSupport
::
Concern
include
ActiveSupport
::
Concern
def
erase!
def
erase!
raise
NotImplementedError
raise
StandardError
,
'Build not eraseable!'
unless
eraseable?
remove_artifacts_file!
remove_artifacts_metadata!
erase_trace!
end
end
def
erased?
def
eraseable?
raise
NotImpementedError
artifacts_file
.
exists?
||
File
.
file?
(
path_to_trace
)
end
def
erase_url
if
eraseable?
erase_namespace_project_build_path
(
project
.
namespace
,
project
,
self
)
end
end
private
def
erase_trace!
File
.
truncate
(
path_to_trace
,
0
)
if
File
.
file?
(
path_to_trace
)
end
end
end
end
end
end
...
...
app/views/projects/builds/show.html.haml
View file @
c8102d93
...
@@ -113,10 +113,11 @@
...
@@ -113,10 +113,11 @@
-
elsif
@build
.
retry_url
-
elsif
@build
.
retry_url
=
link_to
"Retry"
,
@build
.
retry_url
,
class:
'btn btn-sm btn-primary'
,
method: :post
=
link_to
"Retry"
,
@build
.
retry_url
,
class:
'btn btn-sm btn-primary'
,
method: :post
=
link_to
''
,
class:
'btn btn-sm btn-danger'
,
method: :delete
,
-
if
@build
.
eraseable?
data:
{
confirm:
'Are you sure you want to remove this?'
}
do
=
link_to
@build
.
erase_url
,
class:
'btn btn-sm btn-warning'
,
method: :put
,
=
icon
(
'remove'
)
data:
{
confirm:
'Are you sure you want to erase this build?'
}
do
Remove
=
icon
(
'eraser'
)
Erase
.clearfix
.clearfix
-
if
@build
.
duration
-
if
@build
.
duration
...
...
config/routes.rb
View file @
c8102d93
...
@@ -617,6 +617,7 @@ Rails.application.routes.draw do
...
@@ -617,6 +617,7 @@ Rails.application.routes.draw do
get
:status
get
:status
post
:cancel
post
:cancel
post
:retry
post
:retry
put
:erase
end
end
resource
:artifacts
,
only:
[]
do
resource
:artifacts
,
only:
[]
do
...
...
spec/models/ci/build/eraseable_spec.rb
0 → 100644
View file @
c8102d93
require
'spec_helper'
describe
Ci
::
Build
::
Eraseable
,
models:
true
do
context
'build is not eraseable'
do
let!
(
:build
)
{
create
(
:ci_build
)
}
describe
'#erase!'
do
it
{
expect
{
build
.
erase!
}.
to
raise_error
(
StandardError
,
/Build not eraseable!/
)}
end
describe
'#eraseable?'
do
subject
{
build
.
eraseable?
}
it
{
is_expected
.
to
eq
false
}
end
describe
'#erase_url'
do
subject
{
build
.
erase_url
}
it
{
is_expected
.
to
be_falsy
}
end
end
context
'build is eraseable'
do
let!
(
:build
)
{
create
(
:ci_build_with_trace
,
:artifacts
)
}
describe
'#erase!'
do
before
{
build
.
erase!
}
it
'should remove artifact file'
do
expect
(
build
.
artifacts_file
.
exists?
).
to
be_falsy
end
it
'should remove artifact metadata file'
do
expect
(
build
.
artifacts_metadata
.
exists?
).
to
be_falsy
end
it
'should erase build trace in trace file'
do
expect
(
File
.
zero?
(
build
.
path_to_trace
)).
to
eq
true
end
end
describe
'#eraseable?'
do
subject
{
build
.
eraseable?
}
it
{
is_expected
.
to
eq
true
}
end
describe
'#erase_url'
do
subject
{
build
.
erase_url
}
it
{
is_expected
.
to
be_truthy
}
end
context
'metadata and build trace are not available'
do
let!
(
:build
)
{
create
(
:ci_build
,
:artifacts
)
}
before
{
build
.
remove_artifacts_metadata!
}
describe
'#erase!'
do
it
'should not raise error'
do
expect
{
build
.
erase!
}.
to_not
raise_error
end
end
end
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