()
| 104 | # ---- Deployments ---- |
| 105 | |
| 106 | def _fetch_all_deploys() -> list[dict]: |
| 107 | all_runs = [] |
| 108 | for workflow in DEPLOY_WORKFLOWS: |
| 109 | out = _gh([ |
| 110 | 'run', 'list', '--repo', REPO, |
| 111 | '--workflow', workflow, '--limit', '50', |
| 112 | '--json', 'databaseId,status,conclusion,createdAt,updatedAt,headBranch,name' |
| 113 | ]) |
| 114 | if not out: |
| 115 | continue |
| 116 | try: |
| 117 | runs = json.loads(out) |
| 118 | except json.JSONDecodeError: |
| 119 | continue |
| 120 | for run in runs: |
| 121 | started = run.get('createdAt', '') |
| 122 | completed = run.get('updatedAt') |
| 123 | duration = None |
| 124 | if started and completed: |
| 125 | try: |
| 126 | s = datetime.fromisoformat(started.replace('Z', '+00:00')) |
| 127 | c = datetime.fromisoformat(completed.replace('Z', '+00:00')) |
| 128 | duration = round((c - s).total_seconds(), 1) |
| 129 | except (ValueError, TypeError): |
| 130 | pass |
| 131 | all_runs.append({ |
| 132 | 'run_id': str(run.get('databaseId', '')), |
| 133 | 'workflow_name': workflow.replace('.yml', ''), |
| 134 | 'ref_name': run.get('headBranch', ''), |
| 135 | 'status': run.get('conclusion', run.get('status', 'unknown')), |
| 136 | 'started_at': started, |
| 137 | 'completed_at': completed, |
| 138 | 'duration_secs': duration, |
| 139 | 'started_date': started[:10] if started else None, |
| 140 | }) |
| 141 | return all_runs |
| 142 | |
| 143 | |
| 144 | def _ensure_deploys(): |
no test coverage detected