Compare commits
5 Commits
Engine/mov
...
v56
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8c14cc268 | ||
|
|
566d72c2d6 | ||
| ad26d22281 | |||
| 352b4e57d7 | |||
|
|
cdd8b45da8 |
74
.github/workflows/upload_data.yml
vendored
74
.github/workflows/upload_data.yml
vendored
@@ -20,33 +20,77 @@ jobs:
|
|||||||
echo "$GOOGLE_SERVICE_ACCOUNT_JSON" > service_account.json
|
echo "$GOOGLE_SERVICE_ACCOUNT_JSON" > service_account.json
|
||||||
|
|
||||||
python <<'PYCODE'
|
python <<'PYCODE'
|
||||||
import gspread, json, time, subprocess
|
import gspread, json, subprocess
|
||||||
|
|
||||||
# credentials
|
|
||||||
creds = json.load(open("service_account.json"))
|
creds = json.load(open("service_account.json"))
|
||||||
gc = gspread.service_account_from_dict(creds)
|
gc = gspread.service_account_from_dict(creds)
|
||||||
sh = gc.open_by_key("${{ secrets.SPREADSHEET_ID }}")
|
sh = gc.open_by_key("${{ secrets.SPREADSHEET_ID }}")
|
||||||
v = subprocess.run(['git','rev-parse','--show-toplevel'], capture_output=True).stdout.decode().strip()
|
v = subprocess.run(['git','rev-parse','--show-toplevel'], capture_output=True).stdout.decode().strip()
|
||||||
print(f"{v}/test_data.log")
|
print(f"{v}/test_data.log")
|
||||||
|
|
||||||
with open(f"{v}/test_data.log", "r") as f:
|
|
||||||
lines = [line.strip() for line in f if line.strip()]
|
|
||||||
|
|
||||||
project = lines[0].lower()
|
def writeRowsToSpreadsheet(data_list, worksheet):
|
||||||
worksheet = sh.worksheet(project)
|
|
||||||
|
|
||||||
# project name
|
|
||||||
data = lines[1:]
|
|
||||||
|
|
||||||
#blank rows
|
|
||||||
existing_rows = len(worksheet.get_all_values())
|
existing_rows = len(worksheet.get_all_values())
|
||||||
start_row = existing_rows + 3
|
start_row = existing_rows + 3
|
||||||
|
rows_to_append = [row.split() for row in data_list]
|
||||||
# Split data into columns (by spaces)
|
print("rows to append")
|
||||||
rows_to_append = [row.split() for row in data]
|
print(f"{rows_to_append}")
|
||||||
|
|
||||||
for i, row in enumerate(rows_to_append):
|
for i, row in enumerate(rows_to_append):
|
||||||
worksheet.insert_row(row, start_row + i)
|
worksheet.insert_row(row, start_row + i)
|
||||||
|
|
||||||
print(f"Uploaded {len(rows_to_append)} rows to '{project}' tab.")
|
|
||||||
|
with open(f"{v}/test_data.log", "r") as f:
|
||||||
|
lines = [line.strip() for line in f if line.strip()]
|
||||||
|
|
||||||
|
isMaster = False
|
||||||
|
project = lines[0].lower()
|
||||||
|
if project == "master":
|
||||||
|
isMaster = True
|
||||||
|
|
||||||
|
engine_data = []
|
||||||
|
server_data = []
|
||||||
|
ui_data = []
|
||||||
|
master_data = []
|
||||||
|
|
||||||
|
for entry in lines:
|
||||||
|
if not isMaster and entry == "engine":
|
||||||
|
project = "engine"
|
||||||
|
elif not isMaster and entry == "server":
|
||||||
|
project = "server"
|
||||||
|
elif not isMaster and entry == "ui":
|
||||||
|
project = "ui"
|
||||||
|
|
||||||
|
if project == "engine" and entry != "engine":
|
||||||
|
engine_data.append(entry)
|
||||||
|
elif project == "server" and entry != "server":
|
||||||
|
server_data.append(entry)
|
||||||
|
elif project == "ui" and entry != "ui":
|
||||||
|
ui_data.append(entry)
|
||||||
|
elif project == "master" and entry != "master":
|
||||||
|
master_data.append(entry)
|
||||||
|
|
||||||
|
print("PRINTING FILTERED DATA\n\n")
|
||||||
|
print(f"engine\n{engine_data}")
|
||||||
|
print(f"server\n{server_data}")
|
||||||
|
print(f"ui\n{ui_data}")
|
||||||
|
print(f"master\n{master_data}")
|
||||||
|
print("\n\n\n")
|
||||||
|
|
||||||
|
if isMaster and len(master_data) != 0:
|
||||||
|
print("uploading to master tab")
|
||||||
|
worksheet = sh.worksheet("master")
|
||||||
|
writeRowsToSpreadsheet(master_data, worksheet)
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
if len(engine_data) != 0:
|
||||||
|
print("uploading to engine tab")
|
||||||
|
writeRowsToSpreadsheet(engine_data, sh.worksheet("engine"))
|
||||||
|
if len(server_data) != 0:
|
||||||
|
print("uploading to server tab")
|
||||||
|
writeRowsToSpreadsheet(server_data, sh.worksheet("server"))
|
||||||
|
if len(ui_data) != 0:
|
||||||
|
print("uploading to ui tab")
|
||||||
|
writeRowsToSpreadsheet(ui_data, sh.worksheet("ui"))
|
||||||
|
|
||||||
PYCODE
|
PYCODE
|
||||||
|
|||||||
Reference in New Issue
Block a user