Compare commits

...

5 Commits

Author SHA1 Message Date
Hatvani Tamás
f8c14cc268 Enhance logging for data upload process
Added print statements to log data being uploaded to each tab.
2025-11-12 18:50:01 +01:00
Hatvani Tamás
566d72c2d6 Merge pull request #7 from htamas1210/Workflow
Workflow
2025-11-12 18:45:08 +01:00
ad26d22281 indentation error in python script 2025-11-12 18:44:00 +01:00
352b4e57d7 rewrote the python script
the script now checks for project name on every line read from the log
file and appends it to a list named by the project, if the branch is
master then it appends all lines into one list, then it checks if there
is any data in the list and uploads them to the correct tab that matches
the project name or master
2025-11-12 18:42:17 +01:00
Hatvani Tamás
cdd8b45da8 Merge pull request #6 from htamas1210/Engine/movegen-utils
Engine/movegen utils
2025-11-12 11:08:36 +01:00

View File

@@ -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