Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
spbro
OpenXG-RAN
Commits
3fee93c7
Commit
3fee93c7
authored
Apr 12, 2021
by
hardy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
from poc to python class
parent
dbb0bca5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
240 additions
and
52 deletions
+240
-52
ci-scripts/Jenkinsfile-git-dashboard
ci-scripts/Jenkinsfile-git-dashboard
+3
-3
ci-scripts/data_extraction_from_gitlab.py
ci-scripts/data_extraction_from_gitlab.py
+0
-49
ci-scripts/ran_dashboard.py
ci-scripts/ran_dashboard.py
+237
-0
No files found.
ci-scripts/Jenkinsfile-git-dashboard
View file @
3fee93c7
...
...
@@ -31,11 +31,11 @@ pipeline {
label
pythonExecutor
}
stages
{
stage
(
"
Fetch Data
"
)
{
stage
(
"
gDashboard
"
)
{
steps
{
script
{
//retrieve MR data from gitlab
sh
returnStdout:
true
,
script:
'python3 ci-scripts/
data_extraction_from_gitlab
.py'
//retrieve MR data from gitlab
and export to gSheet
sh
returnStdout:
true
,
script:
'python3 ci-scripts/
ran_dashboard
.py'
}
}
}
...
...
ci-scripts/data_extraction_from_gitlab.py
deleted
100644 → 0
View file @
dbb0bca5
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 31 21:57:37 2021
@author: hardy
"""
import
subprocess
import
shlex
import
json
import
datetime
cmd
=
"""curl --silent "https://gitlab.eurecom.fr/api/v4/projects/oai%2Fopenairinterface5g/merge_requests?state=opened&per_page=100" """
process
=
subprocess
.
Popen
(
shlex
.
split
(
cmd
),
stdout
=
subprocess
.
PIPE
)
output
=
process
.
stdout
.
readline
()
tmp
=
output
.
decode
(
"utf-8"
)
d
=
json
.
loads
(
tmp
)
f
=
open
(
"/tmp/gitlab_dashboard.txt"
,
"w"
)
f
.
write
(
"MR;Created_at;Author;Title;CAN START;IN PROGRESS;COMPLETED;OK MERGE;Merge conflicts
\n
"
)
for
x
in
range
(
len
(
d
)):
date_time_str
=
d
[
x
][
'created_at'
]
date_time_obj
=
datetime
.
datetime
.
strptime
(
date_time_str
,
'%Y-%m-%dT%H:%M:%S.%fZ'
)
milestone1
=
milestone2
=
milestone3
=
milestone4
=
""
if
d
[
x
][
'milestone'
]
==
"REVIEW_CAN_START"
:
milestone1
=
"X"
elif
d
[
x
][
'milestone'
]
==
"REVIEW_IN_PROGRESS"
:
milestone2
=
"X"
elif
d
[
x
][
'milestone'
]
==
"REVIEW_COMPLETED_AND_APPROVED"
:
milestone3
=
"X"
elif
d
[
x
][
'milestone'
]
==
"OK_TO_BE_MERGED"
:
milestone4
=
"X"
else
:
pass
if
d
[
x
][
'has_conflicts'
]
==
True
:
conflicts
=
"YES"
else
:
conflicts
=
""
f
.
write
(
str
(
d
[
x
][
'iid'
])
+
';'
+
str
(
date_time_obj
.
date
())
+
';'
+
str
(
d
[
x
][
'author'
][
'name'
])
+
';'
+
str
(
d
[
x
][
'title'
])
+
";"
\
+
milestone1
+
";"
+
milestone2
+
";"
+
milestone3
+
";"
+
milestone4
+
";"
+
conflicts
+
"
\n
"
)
f
.
close
()
ci-scripts/ran_dashboard.py
0 → 100644
View file @
3fee93c7
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements. See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1 (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# * http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# * contact@openairinterface.org
# */
#---------------------------------------------------------------------
# Merge Requests Dashboard for RAN on googleSheet
#
# Required Python Version
# Python 3.x
#
#---------------------------------------------------------------------
#-----------------------------------------------------------
# Import
#-----------------------------------------------------------
#import google spreadsheet API
import
gspread
from
oauth2client.service_account
import
ServiceAccountCredentials
import
subprocess
import
shlex
#lexical analysis
import
json
#json structures
import
datetime
#now() and date formating
from
datetime
import
datetime
#-----------------------------------------------------------
# Class Declaration
#-----------------------------------------------------------
class
gDashboard
:
def
__init__
(
self
,
creds_file
,
spreadsheet
,
worksheet
):
#"creds.json", 'OAI RAN Dashboard', 'MR Status'
self
.
scope
=
[
"https://spreadsheets.google.com/feeds"
,
'https://www.googleapis.com/auth/spreadsheets'
,
"https://www.googleapis.com/auth/drive.file"
,
"https://www.googleapis.com/auth/drive"
]
self
.
creds
=
ServiceAccountCredentials
.
from_json_keyfile_name
(
creds_file
,
self
.
scope
)
self
.
client
=
gspread
.
authorize
(
self
.
creds
)
#spreadsheet
self
.
ss
=
self
.
client
.
open
(
spreadsheet
)
#worksheet
self
.
sheet
=
self
.
ss
.
worksheet
(
worksheet
)
self
.
ss
.
del_worksheet
(
self
.
sheet
)
#start by deleting the old sheet
self
.
sheet
=
self
.
ss
.
add_worksheet
(
title
=
worksheet
,
rows
=
"100"
,
cols
=
"20"
)
#create a new one
self
.
d
=
{}
#data dictionary
def
fetchData
(
self
,
cmd
):
#cmd="""curl --silent "https://gitlab.eurecom.fr/api/v4/projects/oai%2Fopenairinterface5g/merge_requests?state=opened&per_page=100" """
process
=
subprocess
.
Popen
(
shlex
.
split
(
cmd
),
stdout
=
subprocess
.
PIPE
)
output
=
process
.
stdout
.
readline
()
tmp
=
output
.
decode
(
"utf-8"
)
self
.
d
=
json
.
loads
(
tmp
)
def
gBuild
(
self
):
#line 1 : get update date
now
=
datetime
.
now
()
# dd/mm/YY H:M:S
dt_string
=
"Update : "
+
now
.
strftime
(
"%d/%m/%Y %H:%M"
)
row
=
[
dt_string
]
self
.
sheet
.
insert_row
(
row
,
index
=
1
,
value_input_option
=
'RAW'
)
#line 2 is empty
#line 3 is column names
i
=
3
row
=
[
"MR"
,
"Created_at"
,
"Author"
,
"Title"
,
"Assignee"
,
"Reviewer"
,
"CAN START"
,
"IN PROGRESS"
,
"COMPLETED"
,
"OK MERGE"
,
"Merge conflicts"
]
self
.
sheet
.
insert_row
(
row
,
index
=
i
,
value_input_option
=
'RAW'
)
#line 4 onward, build data lines
for
x
in
range
(
len
(
self
.
d
)):
i
=
i
+
1
date_time_str
=
self
.
d
[
x
][
'created_at'
]
date_time_obj
=
datetime
.
strptime
(
date_time_str
,
'%Y-%m-%dT%H:%M:%S.%fZ'
)
milestone1
=
milestone2
=
milestone3
=
milestone4
=
""
if
self
.
d
[
x
][
'milestone'
][
'title'
]
==
"REVIEW_CAN_START"
:
milestone1
=
"X"
elif
self
.
d
[
x
][
'milestone'
][
'title'
]
==
"REVIEW_IN_PROGRESS"
:
milestone2
=
"X"
elif
self
.
d
[
x
][
'milestone'
][
'title'
]
==
"REVIEW_COMPLETED_AND_APPROVED"
:
milestone3
=
"X"
elif
self
.
d
[
x
][
'milestone'
][
'title'
]
==
"OK_TO_BE_MERGED"
:
milestone4
=
"X"
else
:
pass
#check if empty or not
if
self
.
d
[
x
][
'assignee'
]
!=
None
:
assignee
=
str
(
self
.
d
[
x
][
'assignee'
][
'name'
])
else
:
assignee
=
""
#check if empty or not
if
len
(
self
.
d
[
x
][
'reviewers'
])
!=
0
:
reviewer
=
str
(
self
.
d
[
x
][
'reviewers'
][
0
][
'name'
])
else
:
reviewer
=
""
if
self
.
d
[
x
][
'has_conflicts'
]
==
True
:
conflicts
=
"YES"
else
:
conflicts
=
""
#build final row
row
=
[
str
(
self
.
d
[
x
][
'iid'
]),
str
(
date_time_obj
.
date
()),
str
(
self
.
d
[
x
][
'author'
][
'name'
]),
str
(
self
.
d
[
x
][
'title'
]),
\
assignee
,
reviewer
,
\
milestone1
,
milestone2
,
milestone3
,
milestone4
,
conflicts
]
#write it to worksheet
self
.
sheet
.
insert_row
(
row
,
index
=
i
,
value_input_option
=
'RAW'
)
def
gFormat
(
self
,
sourceSheetName
,
destinationSheetName
):
# "Formating" , "MR Status"
#copy formating template
sourceSheetId
=
self
.
ss
.
worksheet
(
sourceSheetName
).
_properties
[
'sheetId'
]
destinationSheetId
=
self
.
ss
.
worksheet
(
destinationSheetName
).
_properties
[
'sheetId'
]
body
=
{
"requests"
:
[
{
"copyPaste"
:
{
"source"
:
{
"sheetId"
:
sourceSheetId
,
"startRowIndex"
:
0
,
"endRowIndex"
:
40
,
"startColumnIndex"
:
0
,
"endColumnIndex"
:
20
},
"destination"
:
{
"sheetId"
:
destinationSheetId
,
"startRowIndex"
:
0
,
"endRowIndex"
:
40
,
"startColumnIndex"
:
0
,
"endColumnIndex"
:
20
},
"pasteType"
:
"PASTE_FORMAT"
}
}
]
}
self
.
ss
.
batch_update
(
body
)
#resize columns fit to data, except col 0
sheetId
=
self
.
ss
.
worksheet
(
destinationSheetName
).
_properties
[
'sheetId'
]
body
=
{
"requests"
:
[
{
'autoResizeDimensions'
:
{
'dimensions'
:
{
'sheetId'
:
sheetId
,
'dimension'
:
'COLUMNS'
,
'startIndex'
:
1
,
'endIndex'
:
20
}
}
}
]
}
self
.
ss
.
batch_update
(
body
)
#resize col 0
sheetId
=
self
.
ss
.
worksheet
(
destinationSheetName
).
_properties
[
'sheetId'
]
body
=
{
"requests"
:
[
{
"updateDimensionProperties"
:
{
"range"
:
{
"sheetId"
:
sheetId
,
"dimension"
:
"COLUMNS"
,
"startIndex"
:
0
,
"endIndex"
:
1
},
"properties"
:
{
"pixelSize"
:
100
},
"fields"
:
"pixelSize"
}
}
]
}
self
.
ss
.
batch_update
(
body
)
#resize milestones to be cleaner
sheetId
=
self
.
ss
.
worksheet
(
destinationSheetName
).
_properties
[
'sheetId'
]
body
=
{
"requests"
:
[
{
"updateDimensionProperties"
:
{
"range"
:
{
"sheetId"
:
sheetId
,
"dimension"
:
"COLUMNS"
,
"startIndex"
:
6
,
"endIndex"
:
10
},
"properties"
:
{
"pixelSize"
:
135
},
"fields"
:
"pixelSize"
}
}
]
}
self
.
ss
.
batch_update
(
body
)
def
main
():
my_gDashboard
=
gDashboard
(
"/home/oaicicd/remi/creds.json"
,
'OAI RAN Dashboard'
,
'MR Status'
)
cmd
=
"""curl --silent "https://gitlab.eurecom.fr/api/v4/projects/oai%2Fopenairinterface5g/merge_requests?state=opened&per_page=100" """
my_gDashboard
.
fetchData
(
cmd
)
my_gDashboard
.
gBuild
()
my_gDashboard
.
gFormat
(
"Formating"
,
"MR Status"
)
if
__name__
==
"__main__"
:
# execute only if run as a script
main
()
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