Commit 4b7de394 authored by hardy's avatar hardy

add last_pass

parent 8ccb745d
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
# Import # Import
#----------------------------------------------------------- #-----------------------------------------------------------
#author Remi
#import google spreadsheet API #import google spreadsheet API
import gspread import gspread
from oauth2client.service_account import ServiceAccountCredentials from oauth2client.service_account import ServiceAccountCredentials
...@@ -110,12 +112,13 @@ class gDashboard: ...@@ -110,12 +112,13 @@ class gDashboard:
###line 3 is for the column names ###line 3 is for the column names
i=3 i=3
row =["MR","Created_at","Author","Title","Assignee", "Reviewer", "CAN START","IN PROGRESS","COMPLETED","Review Form","OK MERGE","Merge conflicts"] row =["MR","Created_at","Author","Title","Assignee", "Reviewer", "CAN START","IN PROGRESS","COMPLETED","Review Form","OK MERGE","Merge conflicts",""]
#tests #tests
for t in range(0,len(self.tests)): for t in range(0,len(self.tests)):
row.append("# PASS") row.append("# PASS")
row.append("# FAIL") row.append("# FAIL")
row.append("Last Pass")
row.append("Last Fail") row.append("Last Fail")
self.sheet.insert_row(row, index=i, value_input_option='RAW') self.sheet.insert_row(row, index=i, value_input_option='RAW')
...@@ -182,7 +185,7 @@ class gDashboard: ...@@ -182,7 +185,7 @@ class gDashboard:
#build final row to be inserted, the first column is left empty for now, will be filled afterward with hyperlinks to gitlab MR #build final row to be inserted, the first column is left empty for now, will be filled afterward with hyperlinks to gitlab MR
row =["", str(date_time_obj.date()),str(self.git[x]['author']['name']), str(self.git[x]['title']),\ row =["", str(date_time_obj.date()),str(self.git[x]['author']['name']), str(self.git[x]['title']),\
assignee, reviewer,\ assignee, reviewer,\
milestone1,milestone2,milestone3,review_form,milestone4,conflicts] milestone1,milestone2,milestone3,review_form,milestone4,conflicts,""]
#and append the test results coming from self.db #and append the test results coming from self.db
mr=str(self.git[x]['iid']) mr=str(self.git[x]['iid'])
for t in self.tests: for t in self.tests:
...@@ -205,7 +208,7 @@ class gDashboard: ...@@ -205,7 +208,7 @@ class gDashboard:
#insert the final row to worksheet #insert the final row to worksheet
self.sheet.insert_row(row, index=i, value_input_option='RAW') self.sheet.insert_row(row, index=i, value_input_option='RAW')
time.sleep(20) time.sleep(10)
#add MR hyperlinks in a list of requests to be sent as one update batch; this to save API calls (quotas) #add MR hyperlinks in a list of requests to be sent as one update batch; this to save API calls (quotas)
...@@ -223,15 +226,17 @@ class gDashboard: ...@@ -223,15 +226,17 @@ class gDashboard:
for t in self.tests: for t in self.tests:
job=self.tests[t]['job'] job=self.tests[t]['job']
if job in self.db[mr]: if job in self.db[mr]:
if len(self.db[mr][job]['last_pass'])>0:
hyperlink= '\"'+ self.db[mr][job]['last_pass'][1] +'\"'
text= '\"'+self.db[mr][job]['last_pass'][0]+'"'
requests.append(self.addHyperlink(hyperlink, text, destinationSheetName, rowIndex, colIndex))
if len(self.db[mr][job]['last_fail'])>0: if len(self.db[mr][job]['last_fail'])>0:
hyperlink= '\"'+ self.db[mr][job]['last_fail'][1] +'\"' hyperlink= '\"'+ self.db[mr][job]['last_fail'][1] +'\"'
text= '\"'+self.db[mr][job]['last_fail'][0]+'"' text= '\"'+self.db[mr][job]['last_fail'][0]+'"'
requests.append(self.addHyperlink(hyperlink, text, destinationSheetName, rowIndex, colIndex)) requests.append(self.addHyperlink(hyperlink, text, destinationSheetName, rowIndex, colIndex+1))
colIndex+=3 colIndex+=4 #move to next test
i=i+1 #increment row index for next MR i=i+1 #increment row index for next MR
body = {"requests": requests} body = {"requests": requests}
self.ss.batch_update(body) self.ss.batch_update(body)
...@@ -292,14 +297,14 @@ class gDashboard: ...@@ -292,14 +297,14 @@ class gDashboard:
"startRowIndex": 1, "startRowIndex": 1,
"endRowIndex": 40, "endRowIndex": 40,
"startColumnIndex": 0, "startColumnIndex": 0,
"endColumnIndex": 26 "endColumnIndex": 30
}, },
"destination": { "destination": {
"sheetId": destinationSheetId, "sheetId": destinationSheetId,
"startRowIndex": 1, "startRowIndex": 1,
"endRowIndex": 40, "endRowIndex": 40,
"startColumnIndex": 0, "startColumnIndex": 0,
"endColumnIndex": 26 "endColumnIndex": 30
}, },
"pasteType": "PASTE_FORMAT" "pasteType": "PASTE_FORMAT"
} }
......
#/*
# * 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
#
#---------------------------------------------------------------------
#author Remi
import pymysql import pymysql
import sys import sys
from datetime import datetime from datetime import datetime
import pickle import pickle
#This is the script/package used by the dashboard to retrieve the MR test results from the database #This is the script/package used by the dashboard to retrieve the MR test results from the database
class SQLConnect: class SQLConnect:
...@@ -55,6 +85,19 @@ class SQLConnect: ...@@ -55,6 +85,19 @@ class SQLConnect:
self.data[MR][test]['last_fail'].append(build) self.data[MR][test]['last_fail'].append(build)
self.data[MR][test]['last_fail'].append(link) self.data[MR][test]['last_fail'].append(link)
#get last passing build and link
sql = "select TEST,BUILD, BUILD_LINK from test_results where MR=(%s) and STATUS='PASS' order by DATE DESC;"
cur.execute(sql,MR)
response=cur.fetchall()
if len(response)!=0:
for i in range(0,len(response)):
test=response[i][0]
build=response[i][1]
link=response[i][2]
if 'last_pass' not in self.data[MR][test]:
self.data[MR][test]['last_pass']=[]
self.data[MR][test]['last_pass'].append(build)
self.data[MR][test]['last_pass'].append(link)
#close database connection #close database connection
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment