Skip to content

Instantly share code, notes, and snippets.

@bradhowes
Last active December 19, 2023 17:26
Show Gist options
  • Save bradhowes/c08477cf2f81335ca83dfcebb5533360 to your computer and use it in GitHub Desktop.
Save bradhowes/c08477cf2f81335ca83dfcebb5533360 to your computer and use it in GitHub Desktop.
Simple repo workflow status
#!/usr/bin/env python
import concurrent.futures
from dataclasses import dataclass
from github import Github
from termcolor import colored
from functools import partial
@dataclass
class Status:
repo: str
when: str
ok: bool
def show(self, max_name_length: int):
status = colored('OK', 'green') if self.ok else colored('FAILED', 'red')
dots = colored('.', 'light_blue') * (max_name_length - len(self.repo) + 2)
print(self.repo + dots + status)
def __lt__(self, other: 'Status') -> bool:
return self.repo.lower() < other.repo.lower()
results: list[Status] = []
with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
def workflows_fut_done(fut, repo):
for flow in list(fut.result()):
if flow.name == 'CI':
for run in flow.get_runs():
results.append(Status(repo.name, run.created_at, run.conclusion == 'success'))
break
break
gh = Github("<<< GITHUB ACCESS TOKEN >>>")
for repo in gh.get_user().get_repos():
get_workflows_fut = executor.submit(repo.get_workflows)
get_workflows_fut.add_done_callback(partial(workflows_fut_done, repo=repo))
max_name_width = max([len(r.repo) for r in results])
for result in sorted(results):
result.show(max_name_width)
# AUv3Controls.................OK
# AUv3Support..................OK
# AUv3Template.................OK
# Joystick.....................OK
# Knob.........................OK
# LPF..........................OK
# morkandmidi..................OK
# remarkable-katex.............OK
# SF2Lib.......................OK
# SimplyChorus.................OK
# SimplyFlange.................OK
# SimplyPhaser.................OK
# SimplyTremolo................OK
# SoundFonts...................OK
# swift-math-parser............OK
# swift-uitableview-searching..OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment