Get a list of all CI jobs (GitHub Actions and other) in a unified format
(self)
| 273 | return self.head_commit()["oid"] |
| 274 | |
| 275 | def ci_jobs(self) -> list[CIJob]: |
| 276 | """ |
| 277 | Get a list of all CI jobs (GitHub Actions and other) in a unified format |
| 278 | """ |
| 279 | jobs = [] |
| 280 | for item in self.head_commit()["statusCheckRollup"]["contexts"]["nodes"]: |
| 281 | if "checkSuite" in item: |
| 282 | # GitHub Actions job, parse separately |
| 283 | status = item["conclusion"] |
| 284 | if status is None: |
| 285 | # If the 'conclusion' isn't filled out the job hasn't |
| 286 | # finished yet |
| 287 | status = "PENDING" |
| 288 | workflow_name = item["checkSuite"]["workflowRun"]["workflow"]["name"] |
| 289 | if workflow_name != "CI": |
| 290 | # Ignore all jobs that aren't in the main.yml workflow (these are mostly |
| 291 | # automation jobs that run on PRs for tagging / reviews) |
| 292 | continue |
| 293 | check_name = item["name"] |
| 294 | jobs.append( |
| 295 | { |
| 296 | "name": f"{workflow_name} / {check_name}", |
| 297 | "url": item["url"], |
| 298 | "status": status.upper(), |
| 299 | } |
| 300 | ) |
| 301 | else: |
| 302 | # GitHub Status (e.g. from Jenkins) |
| 303 | jobs.append( |
| 304 | { |
| 305 | "name": item["context"], |
| 306 | "url": item["targetUrl"], |
| 307 | "status": item["state"].upper(), |
| 308 | } |
| 309 | ) |
| 310 | |
| 311 | logging.info(f"Found CI jobs for {self.head_commit()['oid']} {to_json_str(jobs)}") |
| 312 | return jobs |
| 313 | |
| 314 | def reviews(self) -> list[Review]: |
| 315 | return self.raw["reviews"]["nodes"] |
no test coverage detected