Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
Managetests
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gruppo Web
Managetests
Commits
a71c4d75
Commit
a71c4d75
authored
Nov 06, 2016
by
Pietro Albini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the build log available to the users
parent
c7bf39c5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
7 deletions
+42
-7
managetests/branches.py
managetests/branches.py
+33
-7
managetests/frontend/__init__.py
managetests/frontend/__init__.py
+9
-0
No files found.
managetests/branches.py
View file @
a71c4d75
...
@@ -99,6 +99,11 @@ class Branch:
...
@@ -99,6 +99,11 @@ class Branch:
return
True
return
True
def
has_build_log
(
self
):
"""Check if the branch has a build log"""
path
=
self
.
manager
.
root
/
"branches"
/
self
.
name
/
"build.log"
return
path
.
exists
()
def
load_config
(
self
):
def
load_config
(
self
):
"""Load the configuration of this branch"""
"""Load the configuration of this branch"""
file
=
self
.
manager
.
root
/
"branches"
/
self
.
name
/
"config.json"
file
=
self
.
manager
.
root
/
"branches"
/
self
.
name
/
"config.json"
...
@@ -136,7 +141,17 @@ class Branch:
...
@@ -136,7 +141,17 @@ class Branch:
part
=
part
.
replace
(
"{{%s}}"
%
key
,
value
)
part
=
part
.
replace
(
"{{%s}}"
%
key
,
value
)
command
.
append
(
part
)
command
.
append
(
part
)
return
[
command
],
{
"env"
:
env
,
"cwd"
:
str
(
home
)}
kwargs
=
{
"env"
:
env
,
"cwd"
:
str
(
home
)}
if
build
:
log_path
=
base
/
"build.log"
# Log standard output and error
kwargs
[
"stdin"
]
=
subprocess
.
DEVNULL
kwargs
[
"stdout"
]
=
log_path
.
open
(
"a"
)
kwargs
[
"stderr"
]
=
subprocess
.
STDOUT
return
[
command
],
kwargs
def
deploy
(
self
):
def
deploy
(
self
):
"""Deploy the branch"""
"""Deploy the branch"""
...
@@ -146,7 +161,7 @@ class Branch:
...
@@ -146,7 +161,7 @@ class Branch:
if
self
.
present
:
if
self
.
present
:
return
return
print
(
"[i] Started a build of
'%s'
"
%
self
.
name
)
print
(
"[i] Started a build of
the '%s' branch
"
%
self
.
name
)
# Start from a fresh branch dir
# Start from a fresh branch dir
branch
=
self
.
manager
.
root
/
"branches"
/
self
.
name
branch
=
self
.
manager
.
root
/
"branches"
/
self
.
name
...
@@ -156,6 +171,15 @@ class Branch:
...
@@ -156,6 +171,15 @@ class Branch:
git_dir
=
str
(
self
.
manager
.
root
/
"git"
)
git_dir
=
str
(
self
.
manager
.
root
/
"git"
)
build_dir
=
branch
/
"build"
build_dir
=
branch
/
"build"
log_file
=
branch
/
"build.log"
# Clear the log file
log_file
.
open
(
"w"
).
close
()
def
log
(
msg
):
"""Utility function to log a message to the build log"""
with
log_file
.
open
(
"a"
)
as
f
:
f
.
write
(
msg
)
# Create subdirectories
# Create subdirectories
build_dir
.
mkdir
()
build_dir
.
mkdir
()
...
@@ -165,16 +189,18 @@ class Branch:
...
@@ -165,16 +189,18 @@ class Branch:
f
.
write
(
"%s
\
n
"
%
BRANCH_DIR_VERSION
)
f
.
write
(
"%s
\
n
"
%
BRANCH_DIR_VERSION
)
# Update the bare git repository and checkout the branch
# Update the bare git repository and checkout the branch
subprocess
.
call
([
"git"
,
"--git-dir"
,
git_dir
,
"fetch"
,
"origin"
])
subprocess
.
call
([
"git"
,
"--git-dir"
,
git_dir
,
"fetch"
,
"origin"
],
stdout
=
log_file
.
open
(
"a"
),
stderr
=
subprocess
.
STDOUT
)
subprocess
.
call
([
subprocess
.
call
([
"git"
,
"--git-dir"
,
git_dir
,
"--work-tree"
,
str
(
build_dir
),
"git"
,
"--git-dir"
,
git_dir
,
"--work-tree"
,
str
(
build_dir
),
"checkout"
,
"-f"
,
self
.
name
,
"checkout"
,
"-f"
,
self
.
name
,
])
]
,
stdout
=
log_file
.
open
(
"a"
),
stderr
=
subprocess
.
STDOUT
)
# Copy and load the configuration file
# Copy and load the configuration file
if
not
(
build_dir
/
"managetests.json"
).
exists
():
if
not
(
build_dir
/
"managetests.json"
).
exists
():
print
(
"[!] No managetests.json found in the branch!"
)
log
(
"[!] No managetests.json found in the branch!"
)
print
(
"[!] Aborting!"
)
log
(
"[!] Aborting!"
)
return
False
return
False
shutil
.
copy
(
shutil
.
copy
(
...
@@ -203,7 +229,7 @@ class Branch:
...
@@ -203,7 +229,7 @@ class Branch:
},
build
=
True
)
},
build
=
True
)
if
total
==
0
:
if
total
==
0
:
print
(
"[!] Warning: no artifact was installed!"
)
log
(
"[!] Warning: no artifact was installed!"
)
# Delete the build directory
# Delete the build directory
shutil
.
rmtree
(
str
(
build_dir
))
shutil
.
rmtree
(
str
(
build_dir
))
...
...
managetests/frontend/__init__.py
View file @
a71c4d75
...
@@ -63,6 +63,15 @@ def create_app(manager, processor):
...
@@ -63,6 +63,15 @@ def create_app(manager, processor):
return
flask
.
render_template
(
"index.html"
,
branches
=
branches
)
return
flask
.
render_template
(
"index.html"
,
branches
=
branches
)
@
app
.
route
(
"/+logs/<branch>/build.log"
)
def
build_log
(
branch
):
path
=
manager
.
root
/
"branches"
/
branch
/
"build.log"
if
not
path
.
exists
():
flask
.
abort
(
404
)
return
flask
.
send_file
(
str
(
path
),
mimetype
=
"text/plain"
)
@
app
.
route
(
"/+hook/<token>"
,
methods
=
[
"POST"
])
@
app
.
route
(
"/+hook/<token>"
,
methods
=
[
"POST"
])
def
hook
(
token
):
def
hook
(
token
):
if
token
!=
manager
.
config
[
"hooks-token"
]:
if
token
!=
manager
.
config
[
"hooks-token"
]:
...
...
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