lexicalspace commited on
Commit
cdc6498
·
verified ·
1 Parent(s): 7999328

Update ci_guard.py

Browse files
Files changed (1) hide show
  1. ci_guard.py +23 -16
ci_guard.py CHANGED
@@ -1,29 +1,36 @@
1
  import json
2
  import sys
3
-
4
  def run_ci():
5
- rules = json.load(open("artifacts/normalized_rules.json"))
6
- findings = json.load(open("artifacts/rule_findings.json"))
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  critical_rules = {
9
- r["id"] for r in rules["rules"]
 
10
  if r.get("severity") == "critical"
11
  }
12
 
13
- violated = {
14
- f["rule"] for f in findings
15
- if f["status"] == "VIOLATED"
 
16
  }
17
 
18
- failed = critical_rules & violated
19
 
20
  if failed:
21
- print("❌ CI FAILED")
22
- print("Critical rule violations:", failed)
23
- sys.exit(0)
24
-
25
- print("✅ CI PASSED")
26
- sys.exit(0)
27
 
28
- if __name__ == "__main__":
29
- run_ci()
 
1
  import json
2
  import sys
 
3
  def run_ci():
4
+ """
5
+ UI-safe CI Guard
6
+ Returns:
7
+ (passed: bool, failed_rules: list)
8
+ """
9
+
10
+ rules_path = "artifacts/normalized_rules.json"
11
+ findings_path = "artifacts/rule_findings.json"
12
+
13
+ if not os.path.exists(rules_path) or not os.path.exists(findings_path):
14
+ return False, ["CI setup incomplete"]
15
+
16
+ rules = json.load(open(rules_path, "r", encoding="utf-8"))
17
+ findings = json.load(open(findings_path, "r", encoding="utf-8"))
18
 
19
  critical_rules = {
20
+ r["id"]
21
+ for r in rules.get("rules", [])
22
  if r.get("severity") == "critical"
23
  }
24
 
25
+ violated_rules = {
26
+ f["rule"]
27
+ for f in findings
28
+ if f.get("status") == "VIOLATED"
29
  }
30
 
31
+ failed = sorted(critical_rules & violated_rules)
32
 
33
  if failed:
34
+ return False, failed
 
 
 
 
 
35
 
36
+ return True, []