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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
500e5227
Commit
500e5227
authored
Feb 13, 2017
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP SystemCheck library for executing checks from a rake task
parent
19ee16a0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
111 additions
and
0 deletions
+111
-0
lib/system_check.rb
lib/system_check.rb
+12
-0
lib/system_check/base_check.rb
lib/system_check/base_check.rb
+42
-0
lib/system_check/base_executor.rb
lib/system_check/base_executor.rb
+18
-0
lib/system_check/simple_executor.rb
lib/system_check/simple_executor.rb
+34
-0
lib/tasks/gitlab/check.rake
lib/tasks/gitlab/check.rake
+5
-0
No files found.
lib/system_check.rb
0 → 100644
View file @
500e5227
module
SystemCheck
def
self
.
run
(
component
,
checks
=
{},
executor_klass
=
SimpleExecutor
)
unless
executor_klass
.
is_a?
BaseExecutor
raise
ArgumentError
,
'Invalid executor'
end
executor
=
executor_klass
.
new
(
component
)
executor
.
checks
=
checks
.
map
do
|
check
|
raise
ArgumentError
unless
check
.
is_a?
BaseCheck
end
end
end
lib/system_check/base_check.rb
0 → 100644
View file @
500e5227
module
SystemCheck
class
BaseCheck
def
check?
raise
NotImplementedError
end
def
show_error
raise
NotImplementedError
end
def
skip?
false
end
def
skip_message
end
protected
def
try_fixing_it
(
*
steps
)
steps
=
steps
.
shift
if
steps
.
first
.
is_a?
(
Array
)
puts
' Try fixing it:'
.
color
(
:blue
)
steps
.
each
do
|
step
|
puts
"
#{
step
}
"
end
end
def
fix_and_rerun
puts
' Please fix the error above and rerun the checks.'
.
color
(
:red
)
end
def
for_more_information
(
*
sources
)
sources
=
sources
.
shift
if
sources
.
first
.
is_a?
(
Array
)
puts
' For more information see:'
.
color
(
:blue
)
sources
.
each
do
|
source
|
puts
' #{source}'
end
end
end
end
lib/system_check/base_executor.rb
0 → 100644
View file @
500e5227
module
SystemCheck
class
BaseExecutor
attr_reader
:checks
attr_reader
:component
def
initialize
(
component
)
raise
ArgumentError
unless
component
.
is_a?
String
@component
=
component
@checks
=
Set
.
new
end
def
<<
(
check
)
raise
ArgumentError
unless
check
.
is_a?
BaseCheck
@checks
<<
check
end
end
end
lib/system_check/simple_executor.rb
0 → 100644
View file @
500e5227
module
SystemCheck
class
SimpleExecutor
<
BaseExecutor
def
execute
start_checking
(
component
)
@checks
.
each
do
|
check
|
print
"
#{
check
.
name
}
"
if
check
.
skip?
puts
"skipped
#{
'('
+
skip_message
+
')'
if
skip_message
}
"
.
color
(
:magenta
)
elsif
check
.
check?
puts
'yes'
.
color
(
:green
)
else
puts
'no'
.
color
(
:red
)
check
.
show_error
end
end
finished_checking
(
component
)
end
private
def
start_checking
(
component
)
puts
"Checking
#{
component
.
color
(
:yellow
)
}
..."
puts
''
end
def
finished_checking
(
component
)
puts
''
puts
"Checking
#{
component
.
color
(
:yellow
)
}
...
#{
"Finished"
.
color
(
:green
)
}
"
puts
''
end
end
end
lib/tasks/gitlab/check.rake
View file @
500e5227
...
@@ -848,10 +848,12 @@ namespace :gitlab do
...
@@ -848,10 +848,12 @@ namespace :gitlab do
# Helper methods
# Helper methods
##########################
##########################
# @deprecated Please use SystemChecks
def
fix_and_rerun
def
fix_and_rerun
puts
" Please fix the error above and rerun the checks."
.
color
(
:red
)
puts
" Please fix the error above and rerun the checks."
.
color
(
:red
)
end
end
# @deprecated Please use SystemChecks
def
for_more_information
(
*
sources
)
def
for_more_information
(
*
sources
)
sources
=
sources
.
shift
if
sources
.
first
.
is_a?
(
Array
)
sources
=
sources
.
shift
if
sources
.
first
.
is_a?
(
Array
)
...
@@ -861,6 +863,7 @@ namespace :gitlab do
...
@@ -861,6 +863,7 @@ namespace :gitlab do
end
end
end
end
# @deprecated Please use SystemChecks
def
finished_checking
(
component
)
def
finished_checking
(
component
)
puts
""
puts
""
puts
"Checking
#{
component
.
color
(
:yellow
)
}
...
#{
"Finished"
.
color
(
:green
)
}
"
puts
"Checking
#{
component
.
color
(
:yellow
)
}
...
#{
"Finished"
.
color
(
:green
)
}
"
...
@@ -883,11 +886,13 @@ namespace :gitlab do
...
@@ -883,11 +886,13 @@ namespace :gitlab do
Gitlab
.
config
.
gitlab
.
user
Gitlab
.
config
.
gitlab
.
user
end
end
# @deprecated Please use SystemChecks
def
start_checking
(
component
)
def
start_checking
(
component
)
puts
"Checking
#{
component
.
color
(
:yellow
)
}
..."
puts
"Checking
#{
component
.
color
(
:yellow
)
}
..."
puts
""
puts
""
end
end
# @deprecated Please use SystemChecks
def
try_fixing_it
(
*
steps
)
def
try_fixing_it
(
*
steps
)
steps
=
steps
.
shift
if
steps
.
first
.
is_a?
(
Array
)
steps
=
steps
.
shift
if
steps
.
first
.
is_a?
(
Array
)
...
...
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