2 from pathlib
import Path
10 from gidgethub.aiohttp
import GitHubAPI
12 from rich
import print
13 from rich.rule
import Rule
17 token: str = typer.Option(..., envvar=
"GITHUB_TOKEN"),
18 repo: str = typer.Option(..., envvar=
"GITHUB_REPOSITORY"),
20 asyncio.run(
check(token, repo))
23 async
def check(token: str, repo: str):
26 async with aiohttp.ClientSession()
as session:
27 gh = GitHubAPI(session=session, requester=
"acts-project", oauth_token=token)
28 srcdir = Path(__file__).parent.parent
29 for root, _, files
in os.walk(srcdir):
33 not f.endswith(
".hpp")
34 and not f.endswith(
".cpp")
35 and not f.endswith(
".ipp")
39 rel = f.relative_to(srcdir)
41 with f.open(
"r") as fh:
43 if m := re.match(
r".*\/\/ ?MARK: ?(fpeMask.*)$", line):
49 r"fpeMask(?:Begin)?\( ?(\w+), ?(\d+) ?, ?#(\d+) ?\)",
52 fpeType, count, number = m
58 issue = await gh.getitem(
59 f
"repos/{repo}/issues/{number}"
61 issue_info = issue[
"html_url"]
62 except gidgethub.BadRequest
as e:
64 f
":red_circle: [bold]FPE mask at {loc} has invalid issue number {number}[/bold]"
69 if issue[
"state"] !=
"open":
71 f
":red_circle: [bold]FPE mask at {loc} has issue {number} but is not open[/bold]"
74 if not "fpe" in issue[
"title"].
lower():
76 f
":red_circle: [bold]FPE mask at {loc} has issue {number} but does not contain 'FPE' / 'fpe' in the title[/bold]"
79 if not "fpe" in [l[
"name"]
for l
in issue[
"labels"]]:
81 f
":red_circle: [bold]FPE mask at {loc} has issue {number} but does not have the 'fpe' label[/bold]"
87 f
":green_circle: [bold]FPE mask at {loc}: {fpeType} <= {count}[/bold]"
92 raise typer.Exit(code=0
if ok
else 1)