Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ci-templates
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
OmegaCEN
ci-templates
Commits
c2d103d6
Commit
c2d103d6
authored
2 years ago
by
Teake Nutma
Browse files
Options
Downloads
Patches
Plain Diff
Add dockerfile for testbadge
parent
1c8d9b03
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dockerfiles/testbadge/Dockerfile
+9
-0
9 additions, 0 deletions
dockerfiles/testbadge/Dockerfile
dockerfiles/testbadge/testbadge.py
+29
-0
29 additions, 0 deletions
dockerfiles/testbadge/testbadge.py
with
38 additions
and
0 deletions
dockerfiles/testbadge/Dockerfile
0 → 100644
+
9
−
0
View file @
c2d103d6
FROM
python:3-slim
# https://github.com/weiwei/junitparser/pull/89 is in junitparser 2.6.0.
# https://github.com/weiwei/junitparser/pull/90 is not yet merged :(.
RUN
pip
install
anybadge
"junitparser>=2.6"
COPY
testbadge.py /usr/local/bin/testbadge
CMD
["/bin/bash"]
This diff is collapsed.
Click to expand it.
dockerfiles/testbadge/testbadge.py
0 → 100755
+
29
−
0
View file @
c2d103d6
#!/usr/bin/env python3
import
argparse
from
anybadge
import
Badge
from
junitparser
import
JUnitXml
def
create_badge
(
report_path
,
badge_path
):
report
=
JUnitXml
.
fromfile
(
report_path
)
report
.
update_statistics
()
total
=
report
.
tests
-
report
.
skipped
passed
=
total
-
report
.
errors
-
report
.
failures
percentage
=
100
*
passed
/
total
color
=
'
green
'
if
passed
==
total
else
'
red
'
badge
=
Badge
(
f
'
tests
'
,
f
'
{
percentage
:
.
1
f
}
%
'
,
default_color
=
color
)
badge
.
write_badge
(
badge_path
)
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
'
Create a CI badge from a test report.
'
)
parser
.
add_argument
(
'
report
'
,
metavar
=
'
XML
'
,
type
=
str
,
help
=
'
Path of input JUnit XML report file
'
)
parser
.
add_argument
(
'
badge
'
,
metavar
=
'
SVG
'
,
type
=
str
,
help
=
'
Path of output SVG file
'
)
args
=
parser
.
parse_args
()
create_badge
(
args
.
report
,
args
.
badge
)
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment