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
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
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
Simcha van Collem
Iris
Commits
18f2e6b0
Commit
18f2e6b0
authored
9 years ago
by
Ralf Jung
Browse files
Options
Downloads
Patches
Plain Diff
the extractor script can now iterate over commits, and get the build artifact
parent
115c4a17
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
benchmark/gitlab-extract.py
+29
-11
29 additions, 11 deletions
benchmark/gitlab-extract.py
with
29 additions
and
11 deletions
benchmark/gitlab-extract.py
+
29
−
11
View file @
18f2e6b0
#!/usr/bin/env python3
import
argparse
,
pprint
import
argparse
,
pprint
,
subprocess
,
sys
import
requests
def
first
(
it
):
...
...
@@ -9,27 +9,45 @@ def first(it):
def
req
(
path
):
url
=
'
%s/api/v3/%s
'
%
(
args
.
server
,
path
)
return
requests
.
get
(
url
,
headers
=
{
'
PRIVATE-TOKEN
'
:
args
.
private_token
})
.
json
()
return
requests
.
get
(
url
,
headers
=
{
'
PRIVATE-TOKEN
'
:
args
.
private_token
})
# read command-line arguments
parser
=
argparse
.
ArgumentParser
(
description
=
'
Update and build a bunch of stuff
'
)
parser
.
add_argument
(
"
-t
"
,
"
--private-token
"
,
dest
=
"
private_token
"
,
required
=
True
,
help
=
"
The private token used to authenticate access
"
)
help
=
"
The private token used to authenticate access
.
"
)
parser
.
add_argument
(
"
-s
"
,
"
--server
"
,
dest
=
"
server
"
,
default
=
"
https://gitlab.mpi-sws.org/
"
,
help
=
"
The GitLab server to contact
"
)
help
=
"
The GitLab server to contact
.
"
)
parser
.
add_argument
(
"
-p
"
,
"
--project
"
,
dest
=
"
project
"
,
default
=
"
FP / iris-coq
"
,
help
=
"
The name of the project on GitLab
"
)
help
=
"
The name of the project on GitLab.
"
)
parser
.
add_argument
(
"
-f
"
,
"
--file
"
,
dest
=
"
file
"
,
required
=
True
,
help
=
"
Filename to store the load in.
"
)
parser
.
add_argument
(
"
-c
"
,
"
--commits
"
,
dest
=
"
commits
"
,
help
=
"
The commits to fetch. Default is everything since the most recent entry in the log file.
"
)
args
=
parser
.
parse_args
()
pp
=
pprint
.
PrettyPrinter
(
indent
=
4
)
log_file
=
sys
.
stdout
if
args
.
file
==
"
-
"
else
open
(
args
.
file
,
"
a
"
)
projects
=
req
(
"
projects
"
)
project
=
first
(
filter
(
lambda
p
:
p
[
'
name_with_namespace
'
]
==
args
.
project
,
projects
))
project
=
first
(
filter
(
lambda
p
:
p
[
'
name_with_namespace
'
]
==
args
.
project
,
projects
.
json
()
))
commit
=
"
7e49776c0b3565364823665ab11ee91ed95ade63
"
build
=
first
(
sorted
(
req
(
"
/projects/{}/repository/commits/{}/builds
"
.
format
(
project
[
'
id
'
],
commit
)),
key
=
lambda
b
:
-
int
(
b
[
'
id
'
])))
print
(
"
The build ID is {}
"
.
format
(
build
[
'
id
'
]))
print
(
requests
.
get
(
"
{}/{}/builds/{}/artifacts/file/build-time.txt
"
.
format
(
args
.
server
,
args
.
project
.
replace
(
'
'
,
''
),
build
[
'
id
'
])).
text
)
commits
=
subprocess
.
check_output
([
"
git
"
,
"
rev-list
"
,
args
.
commits
]).
decode
(
"
utf-8
"
)
for
commit
in
reversed
(
commits
.
strip
().
split
(
'
\n
'
)):
builds
=
req
(
"
/projects/{}/repository/commits/{}/builds
"
.
format
(
project
[
'
id
'
],
commit
))
if
builds
.
status_code
!=
200
:
continue
try
:
build
=
first
(
sorted
(
builds
.
json
(),
key
=
lambda
b
:
-
int
(
b
[
'
id
'
])))
except
Exception
:
# no build
continue
build_times
=
requests
.
get
(
"
{}/{}/builds/{}/artifacts/file/build-time.txt
"
.
format
(
args
.
server
,
args
.
project
.
replace
(
'
'
,
''
),
build
[
'
id
'
]))
if
build_times
.
status_code
!=
200
:
continue
# Output in the log file format
log_file
.
write
(
"
# {}
\n
"
.
format
(
commit
))
log_file
.
write
(
build_times
.
text
)
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