synapse-hub 2.2.2 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -237,43 +237,42 @@ def gate_2_path_portability(repo_root, mode="AUTO"):
237
237
 
238
238
 
239
239
  def gate_3_clean_pom(repo_root, mode="AUTO"):
240
- print("\n[GATE 3] Checking Clean POM & Flat Architecture in Scripts/......")
241
- scripts_dir = os.path.join(repo_root, "Scripts")
242
-
243
- has_groovy = False
244
- if os.path.isdir(scripts_dir):
245
- groovy_files = [f for f in glob.glob(os.path.join(scripts_dir, "**", "*.groovy"), recursive=True)]
246
- has_groovy = len(groovy_files) > 0
247
-
248
- if not has_groovy:
249
- if mode == "HUB":
250
- print("[SKIP] Hub Mode: Repository contains QA Hub assets; no target Groovy scripts in Scripts/ to verify.")
251
- return True
252
- else:
253
- print("[SKIP] No Groovy test scripts present in Scripts/ directory.")
254
- return True
240
+ print("\n[GATE 3] Checking Clean POM & Flat Architecture in Test Scripts...")
241
+ effective_mode = detect_repo_mode(repo_root) if mode == "AUTO" else mode
242
+ if effective_mode == "HUB":
243
+ print("[PASS] Hub Mode: Repository contains QA Hub assets; Clean POM applies to target test suites.")
244
+ return True
245
+
246
+ test_dirs = ["Scripts", "tests", "test", "e2e", "specs", "cypress"]
247
+ test_files = []
248
+ for td in test_dirs:
249
+ d = os.path.join(repo_root, td)
250
+ if os.path.isdir(d):
251
+ for ext in ("*.groovy", "*.ts", "*.js", "*.py", "*.java"):
252
+ test_files.extend(glob.glob(os.path.join(d, "**", ext), recursive=True))
253
+
254
+ if not test_files:
255
+ print("[SKIP] No test scripts present in candidate directories (Scripts/, tests/, e2e/).")
256
+ return True
255
257
 
256
258
  violations = []
257
- for root, dirs, files in os.walk(scripts_dir):
258
- for f in files:
259
- if f.endswith(".groovy"):
260
- full_path = os.path.join(root, f)
261
- rel_path = os.path.relpath(full_path, repo_root)
262
- try:
263
- with open(full_path, "r", encoding="utf-8", errors="ignore") as fp:
264
- for line_no, line in enumerate(fp, 1):
265
- stripped = line.strip()
266
- if stripped.startswith("//") or stripped.startswith("/*"):
267
- continue
268
- if "findTestObject" in line:
269
- violations.append((rel_path, line_no, "Raw findTestObject"))
270
- if "//" in line and ("//table" in line or "//input" in line or "//button" in line):
271
- violations.append((rel_path, line_no, "Raw XPath"))
272
- except Exception:
273
- pass
259
+ for full_path in sorted(set(test_files)):
260
+ rel_path = os.path.relpath(full_path, repo_root)
261
+ try:
262
+ with open(full_path, "r", encoding="utf-8", errors="ignore") as fp:
263
+ for line_no, line in enumerate(fp, 1):
264
+ stripped = line.strip()
265
+ if stripped.startswith("//") or stripped.startswith("/*") or stripped.startswith("#"):
266
+ continue
267
+ if "findTestObject" in line:
268
+ violations.append((rel_path, line_no, "Raw findTestObject"))
269
+ if "//" in line and ("//table" in line or "//input" in line or "//button" in line):
270
+ violations.append((rel_path, line_no, "Raw XPath"))
271
+ except Exception:
272
+ pass
274
273
 
275
274
  if violations:
276
- print(f"[FAIL] {len(violations)} Clean POM violations in Scripts/:")
275
+ print(f"[FAIL] {len(violations)} Clean POM violations in test scripts:")
277
276
  for rel_path, line_no, reason in violations:
278
277
  print(f" - {rel_path}:{line_no} ({reason})")
279
278
  return False
@@ -404,26 +403,35 @@ def gate_6_credential_security(repo_root, mode="AUTO"):
404
403
 
405
404
  def gate_7_infer_linter(repo_root, mode="AUTO"):
406
405
  print("\n[GATE 7] Running Meta Infer-Style Static Defect & Fake-Pass Sentinel...")
407
- scripts_dir = os.path.join(repo_root, "Scripts")
408
- has_groovy = False
409
- if os.path.isdir(scripts_dir):
410
- groovy_files = [f for f in glob.glob(os.path.join(scripts_dir, "**", "*.groovy"), recursive=True)]
411
- has_groovy = len(groovy_files) > 0
412
-
413
- if not has_groovy:
414
- if mode == "HUB":
415
- print("[SKIP] Hub Mode: No Groovy test scripts in Scripts/ to scan (Static Defect Sentinel active for target projects).")
416
- return True
417
- else:
418
- print("[SKIP] No Groovy test scripts present in Scripts/ directory.")
419
- return True
406
+ effective_mode = detect_repo_mode(repo_root) if mode == "AUTO" else mode
407
+ if effective_mode == "HUB":
408
+ print("[PASS] Hub Mode: Static Defect Sentinel active for target projects.")
409
+ return True
410
+
411
+ test_dirs = ["Scripts", "tests", "test", "e2e", "specs", "cypress"]
412
+ has_tests = False
413
+ target_scan_dir = None
414
+ for td in test_dirs:
415
+ d = os.path.join(repo_root, td)
416
+ if os.path.isdir(d):
417
+ for ext in ("*.groovy", "*.ts", "*.js", "*.py", "*.java"):
418
+ if glob.glob(os.path.join(d, "**", ext), recursive=True):
419
+ has_tests = True
420
+ target_scan_dir = d
421
+ break
422
+ if has_tests:
423
+ break
424
+
425
+ if not has_tests:
426
+ print("[SKIP] No test scripts (Groovy/TS/JS/Py) present in candidate test directories.")
427
+ return True
420
428
 
421
429
  infer_script = os.path.join(SCRIPT_DIR, "infer_linter.py")
422
430
  if not os.path.exists(infer_script):
423
431
  infer_script = os.path.join(repo_root, "tools", "infer_linter.py")
424
432
 
425
433
  if os.path.exists(infer_script):
426
- res = subprocess.run([sys.executable, infer_script, "--dir", scripts_dir], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
434
+ res = subprocess.run([sys.executable, infer_script, "--dir", target_scan_dir], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
427
435
  if res.returncode != 0:
428
436
  print("[FAIL] Static Defect Sentinel detected critical issues in test scripts:")
429
437
  print(res.stdout)