aboutsummaryrefslogtreecommitdiff
path: root/scripts/newos4-maintain.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/newos4-maintain.py')
-rw-r--r--scripts/newos4-maintain.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/scripts/newos4-maintain.py b/scripts/newos4-maintain.py
index 6321a3f..10ac62b 100644
--- a/scripts/newos4-maintain.py
+++ b/scripts/newos4-maintain.py
@@ -55,10 +55,11 @@ def check_index():
idxp = os.path.join(ROOT, 'modules-index.json')
atlas = json.load(open(os.path.join(ROOT, 'course/atlas.json')))
idx = json.load(open(idxp))
- cur = len(set(c for m in idx.get('modules', {}).values() for c in m.get('commands', [])))
- if cur == atlas['coverage']['commands']:
- add('PASS', f'modules-index {cur} commands'); return
- add('WARN', f'modules-index stale {cur} vs {atlas["coverage"]["commands"]}')
+ index_cmds = set(c for m in idx.get('modules', {}).values() for c in m.get('commands', []))
+ missing = sorted(c for c, e in atlas.get('commands', {}).items() if not e.get('builtin') and c not in index_cmds)
+ if not missing:
+ add('PASS', f'modules-index covers {len(index_cmds)} commands'); return
+ add('WARN', f'modules-index missing {len(missing)}: ' + ', '.join(missing[:5]))
if not FIX: return
for name, m in atlas['modules'].items():
e = idx['modules'].get(name, {'name': name, 'file': m['file'], 'type': 'core' if m['tier'] == 'core-bundle' else 'ext',
@@ -87,6 +88,14 @@ def check_live():
code = sh(f"curl -s -o /dev/null -w '%{{http_code}}' '{url}'")
add('PASS' if code == '200' else 'FAIL', f'HTTP {code} {url.replace(WEB, "")}')
+def check_atlas():
+ p = os.path.join(ROOT, 'course/atlas.json')
+ before = (json.load(open(p)).get('coverage', {}).get('commands') if os.path.exists(p) else None)
+ r = run([sys.executable, 'scripts/gen-course-atlas.py'], cwd=ROOT)
+ after = (json.load(open(p)).get('coverage', {}).get('commands') if os.path.exists(p) else None)
+ add('PASS' if r.returncode == 0 else 'FAIL',
+ f'atlas {after} commands' + (' (refreshed from ' + str(before) + ')' if before != after else ''))
+
def check_course():
r = run([sys.executable, 'scripts/course-validate.py'], cwd=ROOT)
add('PASS' if r.returncode == 0 else 'FAIL', 'course ' + ('valid' if r.returncode == 0 else 'INVALID: ' + r.stdout[-160:]))
@@ -106,7 +115,7 @@ def check_links():
def main():
os.chdir(ROOT)
- check_versions(); check_bundles(); check_syntax(); check_perms(); check_index(); check_data(); check_live(); check_course(); check_links()
+ check_versions(); check_bundles(); check_syntax(); check_perms(); check_index(); check_data(); check_live(); check_atlas(); check_course(); check_links()
fails = [m for l, m in issues if l == 'FAIL']
print('newOS4 maintenance — ' + datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%MZ') + (' [fix]' if FIX else '') + (' [deep]' if DEEP else ''))
for l, m in issues: print(f'{l}: {m}')