Skip to content
Snippets Groups Projects
Commit 76a70ef4 authored by Ben Gamari's avatar Ben Gamari :turtle:
Browse files

summarize: Allow skipping out log collection

parent a0278195
No related branches found
No related tags found
No related merge requests found
......@@ -55,7 +55,9 @@ def export_dot(summary):
for pkg, dep in edges:
s += f' "{pkg}" -> "{dep}";\n'
for pkg in summary['pkgs']:
# Deduplicate
pkgs = {pkg['drvPath']: pkg for pkg in summary['pkgs']}
for pkg in pkgs.values():
color = 'lightblue'
if pkg['failed']:
color = 'indianred'
......@@ -67,9 +69,9 @@ def export_dot(summary):
return s
def show_failures(summary, log_excerpt=100):
failed = [pkg
failed = {pkg['drvPath']: pkg
for pkg in summary['pkgs']
if pkg['failed']]
if pkg['failed']}
if len(failed) == 0:
print('='*80)
print('No issues encountered.')
......@@ -78,33 +80,40 @@ def show_failures(summary, log_excerpt=100):
print('='*80)
print('These packages failed to build:')
print()
for pkg in failed:
for pkg in failed.values():
print(f"* {pkg['name']} ({pkg['drvPath']})")
print()
proc = subprocess.run(['nix', 'log', '--quiet', pkg['drvPath']],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
encoding='UTF-8')
if proc.returncode != 0:
print(f' Error: Failed to fetch log')
continue
print(f' ---- Last {log_excerpt} lines of log follow ----')
lines = proc.stdout.split('\n')
if len(lines) > log_excerpt:
print('')
print('\n '.join(lines[-log_excerpt:]))
print(' ---- End of log ----------------------------')
print()
print()
if log_excerpt is not None:
print()
proc = subprocess.run(['nix', 'log', '--quiet', pkg['drvPath']],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
encoding='UTF-8')
if proc.returncode != 0:
print(f' Error: Failed to fetch log')
continue
print(f' ---- Last {log_excerpt} lines of log follow ----')
lines = proc.stdout.split('\n')
if len(lines) > log_excerpt:
print('')
print('\n '.join(lines[-log_excerpt:]))
print(' ---- End of log ----------------------------')
print()
print()
print('='*80)
if __name__ == "__main__":
assert os.environ['GHC_TARBALL'] != None
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--no-logs', action='store_true', help="Don't export logs (useful when logs are unavailable as nix remote builds were used)")
args = parser.parse_args()
summary = read_summary()
export_logs(summary)
if not args.no_logs:
export_logs(summary)
json.dump(summary, Path('summary.json').open('w'))
show_failures(summary)
show_failures(summary, log_excerpt=None if args.no_logs else 100)
Path('summary.dot').write_text(export_dot(summary))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment