44 lines
1.4 KiB
Python
Executable File
44 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import argparse
|
|
import json
|
|
import re
|
|
from pathlib import Path
|
|
|
|
def parse_intent(path: Path):
|
|
statuses = {}
|
|
for line in path.read_text(encoding='utf-8').splitlines():
|
|
m = re.match(r"\|\s*(\d+)\s*\|\s*(CLOSED|PARTIAL|GAP)\s*\|", line)
|
|
if m:
|
|
statuses[int(m.group(1))] = m.group(2)
|
|
return statuses
|
|
|
|
def main() -> int:
|
|
ap = argparse.ArgumentParser()
|
|
ap.add_argument('--intent-audit', required=True)
|
|
ap.add_argument('--closeout-json', required=True)
|
|
ap.add_argument('--out', required=True)
|
|
args = ap.parse_args()
|
|
|
|
intent = parse_intent(Path(args.intent_audit))
|
|
closeout = json.loads(Path(args.closeout_json).read_text(encoding='utf-8'))
|
|
|
|
inconsistent = []
|
|
for row in closeout.get('results', []):
|
|
sprint = int(row.get('sprint', 0))
|
|
state = row.get('state', '')
|
|
i = intent.get(sprint, 'UNKNOWN')
|
|
if state == 'EXECUTION-READY' and i != 'CLOSED':
|
|
inconsistent.append({'sprint': sprint, 'closeout_state': state, 'intent_status': i})
|
|
|
|
out = {
|
|
'inconsistent_count': len(inconsistent),
|
|
'pass': len(inconsistent) == 0,
|
|
'inconsistent': inconsistent,
|
|
}
|
|
Path(args.out).write_text(json.dumps(out, indent=2) + '\n', encoding='utf-8')
|
|
print(json.dumps(out))
|
|
return 0
|
|
|
|
if __name__ == '__main__':
|
|
raise SystemExit(main())
|