diff --git a/pykern/pkcli/github.py b/pykern/pkcli/github.py index 224f1e72..d4c85bab 100644 --- a/pykern/pkcli/github.py +++ b/pykern/pkcli/github.py @@ -5,6 +5,7 @@ :license: http://www.apache.org/licenses/LICENSE-2.0.html """ from __future__ import absolute_import, division, print_function +from pykern import pkcli from pykern import pkconfig from pykern import pkio from pykern import pkjson @@ -49,6 +50,31 @@ def backup(): pkdlog("DONE") +def ci_check(repo, branch=None): + def _branch(r, name, reraise=True): + try: + return r.branch(name=name) + except github3.exceptions.NotFoundError: + if reraise: + raise + return None + + r = _repo_arg(repo) + b = ( + _branch(r, branch) + if branch + else _branch(r, "master", False) or _branch(r, "main") + ) + s = b.commit.sha + c = [c.conclusion for c in b.commit.check_runs()] + i = f"branch={b.name} sha={s}" + if not c: + pkcli.command_error(f"{i} No workflow runs for commit") + if c[0] != "success": + pkcli.command_error(f"{i} Unsuccessful conclusion={c}") + return f"{i} Passed CI" + + def collaborators(org, filename, affiliation="outside", private=True): """Lists direct repos to which user has access and is not a team member diff --git a/pykern/pkconfig.py b/pykern/pkconfig.py index 3b482d3c..e9264448 100644 --- a/pykern/pkconfig.py +++ b/pykern/pkconfig.py @@ -158,7 +158,7 @@ class Required(tuple, object): cfg = pkconfig.init( any_param=(1, int, 'A parameter with a default'), - needed=pkconfig.Required(int, 'A parameter with a default'), + needed=pkconfig.Required(int, 'A parameter without a default'), ) Args: