summary refs log tree commit diff
path: root/maintainers/scripts/hydra-eval-failures.py
diff options
context:
space:
mode:
authorSamuel Leathers <samuel.leathers@iohk.io>2019-09-13 23:33:38 -0400
committerSamuel Leathers <samuel.leathers@iohk.io>2019-09-13 23:33:38 -0400
commit11fc56348ee4b5efc6f44d9f91a286ade4609371 (patch)
tree0a4c118e77d9c8c8b89242d2a9a0f0944d224272 /maintainers/scripts/hydra-eval-failures.py
parenta412701c8de181777558677b16be0bfed6eba519 (diff)
downloadnixpkgs-11fc56348ee4b5efc6f44d9f91a286ade4609371.tar
nixpkgs-11fc56348ee4b5efc6f44d9f91a286ade4609371.tar.gz
nixpkgs-11fc56348ee4b5efc6f44d9f91a286ade4609371.tar.bz2
nixpkgs-11fc56348ee4b5efc6f44d9f91a286ade4609371.tar.lz
nixpkgs-11fc56348ee4b5efc6f44d9f91a286ade4609371.tar.xz
nixpkgs-11fc56348ee4b5efc6f44d9f91a286ade4609371.tar.zst
nixpkgs-11fc56348ee4b5efc6f44d9f91a286ade4609371.zip
maintainer scripts: fix hydra-eval-failures script
Diffstat (limited to 'maintainers/scripts/hydra-eval-failures.py')
-rwxr-xr-xmaintainers/scripts/hydra-eval-failures.py36
1 files changed, 24 insertions, 12 deletions
diff --git a/maintainers/scripts/hydra-eval-failures.py b/maintainers/scripts/hydra-eval-failures.py
index 23669502e46..6e7ec2dbc00 100755
--- a/maintainers/scripts/hydra-eval-failures.py
+++ b/maintainers/scripts/hydra-eval-failures.py
@@ -11,13 +11,15 @@ import click
 import requests
 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([
-    'nix-instantiate', '-E', 'import ./maintainers/maintainer-list.nix {}', '--eval', '--json'
+    'nix-instantiate', '-A', 'lib.maintainers', '--eval', '--strict', '--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):
     return pq(requests.get(url).text)  # IO
@@ -38,30 +40,39 @@ def get_maintainers(attr_name):
             '-A',
             '.'.join(nixname[1:]) + '.meta',
             EVAL_FILE[nixname[0]],
+            '--arg',
+            'nixpkgs',
+            './.',
             '--json'])
         meta = json.loads(meta_json)
-        if meta.get('maintainers'):
-            return [MAINTAINERS[name] for name in meta['maintainers'] if MAINTAINERS.get(name)]
+        return meta.get('maintainers', [])
     except:
        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):
     a = pq(table_row)('a')[1]
     print("- [ ] [{}]({})".format(a.text, a.get('href')), flush=True)
-    
-    maintainers = get_maintainers(a.text)
-    if maintainers:
-        print("  - maintainers: {}".format(", ".join(map(lambda u: '@' + u, maintainers))))
+
+    job_maintainers = filter_github_users(get_maintainers(a.text))
+    if job_maintainers:
+        print("  - maintainers: {}".format(" ".join(map(lambda u: '@' + u.get('github'), job_maintainers))))
     # 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?
-    
+
     sys.stdout.flush()
 
 @click.command()
 @click.option(
     '--jobset',
-    default="nixos/release-17.09",
-    help='Hydra project like nixos/release-17.09')
+    default="nixos/release-19.09",
+    help='Hydra project like nixos/release-19.09')
 def cli(jobset):
     """
     Given a Hydra project, inspect latest evaluation
@@ -93,6 +104,7 @@ def cli(jobset):
         print_build(tr)
 
 
+
 if __name__ == "__main__":
     try:
         cli()