Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /SHAdd0WTAka_Zen-Ai-Pentest /.kimi /get_workflow_logs.py
| #!/usr/bin/env python3 | |
| """Get workflow run logs""" | |
| import os | |
| import sys | |
| sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| import requests | |
| from github_app_auth import ( | |
| REPO_NAME, | |
| REPO_OWNER, | |
| get_headers, | |
| get_installation_token, | |
| ) | |
| def get_latest_workflow_run(workflow_name="Test Coverage"): | |
| """Get latest run ID for a workflow""" | |
| token = get_installation_token() | |
| headers = get_headers(token) | |
| headers["Accept"] = "application/vnd.github.v3+json" | |
| url = f"https://api.github.com/repos/{REPO_OWNER}/{REPO_NAME}/actions/runs" | |
| params = {"per_page": 10} | |
| response = requests.get(url, headers=headers, params=params, timeout=30) | |
| if response.status_code == 200: | |
| runs = response.json().get("workflow_runs", []) | |
| for run in runs: | |
| if run.get("name") == workflow_name: | |
| return run | |
| return None | |
| def get_run_logs(run_id): | |
| """Get logs for a specific run""" | |
| token = get_installation_token() | |
| headers = get_headers(token) | |
| headers["Accept"] = "application/vnd.github.v3+json" | |
| # Get run details | |
| url = f"https://api.github.com/repos/{REPO_OWNER}/{REPO_NAME}/actions/runs/{run_id}" | |
| response = requests.get(url, headers=headers, timeout=30) | |
| if response.status_code == 200: | |
| run = response.json() | |
| print(f"\nWorkflow: {run.get('name')}") | |
| print(f"Status: {run.get('status')}") | |
| print(f"Conclusion: {run.get('conclusion')}") | |
| print(f"URL: {run.get('html_url')}") | |
| # Get jobs | |
| jobs_url = run.get("jobs_url") | |
| jobs_resp = requests.get(jobs_url, headers=headers, timeout=30) | |
| if jobs_resp.status_code == 200: | |
| jobs = jobs_resp.json().get("jobs", []) | |
| print(f"\nJobs ({len(jobs)}):") | |
| for job in jobs: | |
| print(f"\n - {job.get('name')}") | |
| print(f" Status: {job.get('status')}") | |
| print(f" Conclusion: {job.get('conclusion')}") | |
| # Get steps | |
| steps = job.get("steps", []) | |
| for step in steps: | |
| if step.get("conclusion") == "failure": | |
| print(f" FAILED STEP: {step.get('name')}") | |
| print(f" Status: {step.get('status')}") | |
| print(f" Number: {step.get('number')}") | |
| if __name__ == "__main__": | |
| run = get_latest_workflow_run("Test Coverage") | |
| if run: | |
| get_run_logs(run.get("id")) | |
| else: | |
| print("No workflow run found") | |
Xet Storage Details
- Size:
- 2.56 kB
- Xet hash:
- 107adfbc7dfa5f3db7d1c40d9799f7dc6fca92be16706d60124568e7e80619c0
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.