Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Iris
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Iris
Iris
Commits
a0855325
There was a problem fetching the pipeline mini graph.
Commit
a0855325
authored
9 years ago
by
Ralf Jung
Browse files
Options
Downloads
Patches
Plain Diff
fix gitlab extractor to be more robust
parent
71788212
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
benchmark/gitlab-extract.py
+16
-7
16 additions, 7 deletions
benchmark/gitlab-extract.py
benchmark/parse_log.py
+1
-1
1 addition, 1 deletion
benchmark/parse_log.py
with
17 additions
and
8 deletions
benchmark/gitlab-extract.py
+
16
−
7
View file @
a0855325
...
@@ -4,7 +4,7 @@ import requests
...
@@ -4,7 +4,7 @@ import requests
import
parse_log
import
parse_log
def
last
(
it
):
def
last
(
it
):
r
=
first
(
it
)
# errors out if it is empty
r
=
None
for
i
in
it
:
for
i
in
it
:
r
=
i
r
=
i
return
r
return
r
...
@@ -12,7 +12,7 @@ def last(it):
...
@@ -12,7 +12,7 @@ def last(it):
def
first
(
it
):
def
first
(
it
):
for
i
in
it
:
for
i
in
it
:
return
i
return
i
r
aise
Exception
(
"
The iterator is empty
"
)
r
eturn
None
def
req
(
path
):
def
req
(
path
):
url
=
'
%s/api/v3/%s
'
%
(
args
.
server
,
path
)
url
=
'
%s/api/v3/%s
'
%
(
args
.
server
,
path
)
...
@@ -47,20 +47,29 @@ if args.commits is None:
...
@@ -47,20 +47,29 @@ if args.commits is None:
projects
=
req
(
"
projects
"
)
projects
=
req
(
"
projects
"
)
project
=
first
(
filter
(
lambda
p
:
p
[
'
path_with_namespace
'
]
==
args
.
project
,
projects
.
json
()))
project
=
first
(
filter
(
lambda
p
:
p
[
'
path_with_namespace
'
]
==
args
.
project
,
projects
.
json
()))
if
project
is
None
:
sys
.
stderr
.
write
(
"
Project not found.
\n
"
)
sys
.
exit
(
1
)
for
commit
in
parse_log
.
parse_git_commits
(
args
.
commits
):
for
commit
in
parse_log
.
parse_git_commits
(
args
.
commits
):
print
(
"
Fetching {}...
"
.
format
(
commit
))
print
(
"
Fetching {}...
"
.
format
(
commit
))
commit_data
=
req
(
"
/projects/{}/repository/commits/{}
"
.
format
(
project
[
'
id
'
],
commit
))
if
commit_data
.
status_code
!=
200
:
raise
Exception
(
"
Commit not found?
"
)
builds
=
req
(
"
/projects/{}/repository/commits/{}/builds
"
.
format
(
project
[
'
id
'
],
commit
))
builds
=
req
(
"
/projects/{}/repository/commits/{}/builds
"
.
format
(
project
[
'
id
'
],
commit
))
if
builds
.
status_code
!=
200
:
if
builds
.
status_code
!=
200
:
continue
try
:
build
=
first
(
sorted
(
builds
.
json
(),
key
=
lambda
b
:
-
int
(
b
[
'
id
'
])))
except
Exception
:
# no build
# no build
continue
continue
build
=
first
(
sorted
(
builds
.
json
(),
key
=
lambda
b
:
-
int
(
b
[
'
id
'
])))
assert
build
is
not
None
if
build
[
'
status
'
]
==
'
failed
'
:
# build failed
continue
# now fetch the build times
build_times
=
requests
.
get
(
"
{}/builds/{}/artifacts/file/build-time.txt
"
.
format
(
project
[
'
web_url
'
],
build
[
'
id
'
]))
build_times
=
requests
.
get
(
"
{}/builds/{}/artifacts/file/build-time.txt
"
.
format
(
project
[
'
web_url
'
],
build
[
'
id
'
]))
if
build_times
.
status_code
!=
200
:
if
build_times
.
status_code
!=
200
:
continue
raise
Exception
(
"
No artifact at build?
"
)
# Output in the log file format
# Output in the log file format
log_file
.
write
(
"
# {}
\n
"
.
format
(
commit
))
log_file
.
write
(
"
# {}
\n
"
.
format
(
commit
))
log_file
.
write
(
build_times
.
text
)
log_file
.
write
(
build_times
.
text
)
log_file
.
flush
()
This diff is collapsed.
Click to expand it.
benchmark/parse_log.py
+
1
−
1
View file @
a0855325
...
@@ -35,7 +35,7 @@ def parse(file, parse_times = True):
...
@@ -35,7 +35,7 @@ def parse(file, parse_times = True):
# nothing else we know about
# nothing else we know about
raise
Exception
(
"
Unexpected line: {}
"
.
format
(
line
))
raise
Exception
(
"
Unexpected line: {}
"
.
format
(
line
))
# end of file. previous commit, if any, is done now.
# end of file. previous commit, if any, is done now.
if
times
is
not
None
:
if
commit
is
not
None
:
yield
Result
(
commit
,
times
)
yield
Result
(
commit
,
times
)
def
parse_git_commits
(
commits
):
def
parse_git_commits
(
commits
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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