fix: change bundle ID from com.tabatago.app to fr.millianlmx.tabatago
This commit is contained in:
63
ci_agent.py
Normal file
63
ci_agent.py
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Fetch CI status for tabatago - check latest runs and get logs for failures."""
|
||||
import urllib.request, json, base64, sys, os
|
||||
|
||||
repo = "millianlmx/tabatago"
|
||||
base_url = f"https://gitea.1000co.fr/api/v1/repos/{repo}/actions"
|
||||
|
||||
# Load token from base64 file
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
with open(os.path.join(script_dir, ".gtb64")) as f:
|
||||
token = base64.b64decode(f.read().strip()).decode().strip()
|
||||
|
||||
def api(path, expect_json=True):
|
||||
req = urllib.request.Request(f"{base_url}{path}")
|
||||
req.add_header("Authorization", f"token {token}")
|
||||
with urllib.request.urlopen(req) as resp:
|
||||
body = resp.read()
|
||||
if expect_json:
|
||||
return json.loads(body)
|
||||
return body.decode('utf-8', 'replace')
|
||||
|
||||
# Check mode
|
||||
mode = sys.argv[1] if len(sys.argv) > 1 else "status"
|
||||
|
||||
if mode == "status":
|
||||
data = api("/runs?limit=5")
|
||||
runs = data.get('workflow_runs', [])
|
||||
for r in runs:
|
||||
print(f"Run #{r['run_number']} (ID={r['id']}) status={r['status']} conclusion={r.get('conclusion','?')}")
|
||||
|
||||
elif mode == "check":
|
||||
# Check latest run and return status
|
||||
data = api("/runs?limit=1")
|
||||
runs = data.get('workflow_runs', [])
|
||||
if runs:
|
||||
r = runs[0]
|
||||
print(f"run_number={r['run_number']}|id={r['id']}|status={r['status']}|conclusion={r.get('conclusion','?')}")
|
||||
|
||||
elif mode == "jobs":
|
||||
run_id = sys.argv[2]
|
||||
try:
|
||||
jobs_data = api(f"/runs/{run_id}/jobs")
|
||||
jobs = jobs_data if isinstance(jobs_data, list) else jobs_data.get('jobs', [])
|
||||
for j in jobs:
|
||||
print(f"job_id={j['id']}|name={j.get('name','?')}|status={j.get('status')}|conclusion={j.get('conclusion','?')}")
|
||||
except Exception as e:
|
||||
print(f"ERROR: {e}", file=sys.stderr)
|
||||
|
||||
elif mode == "logs":
|
||||
job_id = sys.argv[2]
|
||||
try:
|
||||
logs = api(f"/jobs/{job_id}/logs", expect_json=False)
|
||||
# Get last 150 lines
|
||||
lines = logs.split('\n')
|
||||
print(f"Total lines: {len(lines)}")
|
||||
# Show error-context lines
|
||||
for i, line in enumerate(lines[-200:]):
|
||||
print(line)
|
||||
except Exception as e:
|
||||
print(f"ERROR: {e}", file=sys.stderr)
|
||||
|
||||
else:
|
||||
print(f"Unknown mode: {mode}")
|
||||
Reference in New Issue
Block a user