Merge pull request #68754 from disassembler/maintainer-hydra-eval-script

maintainer scripts: fix hydra-eval-failures script
This commit is contained in:
Robin Gloster 2019-09-14 11:02:29 +02:00 committed by GitHub
commit 03cd14da09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,13 +11,15 @@ import click
import requests import requests
from pyquery import PyQuery as pq from pyquery import PyQuery as pq
def map_dict (f, d):
for k,v in d.items():
d[k] = f(v)
maintainers_json = subprocess.check_output([ maintainers_json = subprocess.check_output([
'nix-instantiate', '-E', 'import ./maintainers/maintainer-list.nix {}', '--eval', '--json' 'nix-instantiate', '-A', 'lib.maintainers', '--eval', '--strict', '--json'
]) ])
maintainers = json.loads(maintainers_json) maintainers = json.loads(maintainers_json)
MAINTAINERS = {v: k for k, v in maintainers.items()} MAINTAINERS = map_dict(lambda v: v.get('github', None), maintainers)
def get_response_text(url): def get_response_text(url):
return pq(requests.get(url).text) # IO return pq(requests.get(url).text) # IO
@ -38,20 +40,29 @@ def get_maintainers(attr_name):
'-A', '-A',
'.'.join(nixname[1:]) + '.meta', '.'.join(nixname[1:]) + '.meta',
EVAL_FILE[nixname[0]], EVAL_FILE[nixname[0]],
'--arg',
'nixpkgs',
'./.',
'--json']) '--json'])
meta = json.loads(meta_json) meta = json.loads(meta_json)
if meta.get('maintainers'): return meta.get('maintainers', [])
return [MAINTAINERS[name] for name in meta['maintainers'] if MAINTAINERS.get(name)]
except: except:
return [] return []
def filter_github_users(maintainers):
github_only = []
for i in maintainers:
if i.get('github'):
github_only.append(i)
return github_only
def print_build(table_row): def print_build(table_row):
a = pq(table_row)('a')[1] a = pq(table_row)('a')[1]
print("- [ ] [{}]({})".format(a.text, a.get('href')), flush=True) print("- [ ] [{}]({})".format(a.text, a.get('href')), flush=True)
maintainers = get_maintainers(a.text) job_maintainers = filter_github_users(get_maintainers(a.text))
if maintainers: if job_maintainers:
print(" - maintainers: {}".format(", ".join(map(lambda u: '@' + u, maintainers)))) print(" - maintainers: {}".format(" ".join(map(lambda u: '@' + u.get('github'), job_maintainers))))
# TODO: print last three persons that touched this file # TODO: print last three persons that touched this file
# TODO: pinpoint the diff that broke this build, or maybe it's transient or maybe it never worked? # TODO: pinpoint the diff that broke this build, or maybe it's transient or maybe it never worked?
@ -60,8 +71,8 @@ def print_build(table_row):
@click.command() @click.command()
@click.option( @click.option(
'--jobset', '--jobset',
default="nixos/release-17.09", default="nixos/release-19.09",
help='Hydra project like nixos/release-17.09') help='Hydra project like nixos/release-19.09')
def cli(jobset): def cli(jobset):
""" """
Given a Hydra project, inspect latest evaluation Given a Hydra project, inspect latest evaluation
@ -93,6 +104,7 @@ def cli(jobset):
print_build(tr) print_build(tr)
if __name__ == "__main__": if __name__ == "__main__":
try: try:
cli() cli()