Skip to content

Commit 42d764d

Browse files
committed
fixing repo issues
1 parent 38db97f commit 42d764d

2 files changed

Lines changed: 48 additions & 12 deletions

File tree

scripts/workflow/parse_repos.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def parse_known_good(json_file="./known_good.json"):
6363

6464
for name, module in modules.items():
6565
repo_url = module.repo
66-
ref = module.version or module.branch or module.commit_hash
66+
ref = module.version or module.branch or module.hash
6767

6868
repo_obj = {"name": name, "url": repo_url, "version": ref, "path": f"repos/{name}"}
6969
repos.append(repo_obj)
@@ -74,8 +74,8 @@ def parse_known_good(json_file="./known_good.json"):
7474
module_outputs[f"{name}_version"] = module.version
7575
if module.branch:
7676
module_outputs[f"{name}_branch"] = module.branch
77-
if module.commit_hash:
78-
module_outputs[f"{name}_hash"] = module.commit_hash
77+
if module.hash:
78+
module_outputs[f"{name}_hash"] = module.hash
7979

8080
return repos, len(modules), module_outputs
8181

scripts/workflow/recategorize_guidelines.py

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,45 @@
3232

3333

3434
def validate_paths():
35-
"""Validate that required files and directories exist."""
36-
required_files = [
35+
"""
36+
Validate that required files exist.
37+
38+
Note: Only validates files needed for recategorization if SARIF exists.
39+
Returns:
40+
True if validation passes or SARIF doesn't exist, False on critical errors
41+
"""
42+
# First check if SARIF file exists - if not, nothing to recategorize
43+
if not Path(SARIF_FILE).exists():
44+
print(f"Info: SARIF file not found at {SARIF_FILE}", file=sys.stderr)
45+
return False # Signal to skip recategorization
46+
47+
# SARIF exists, check for recategorization dependencies
48+
optional_files = [
3749
RECATEGORIZE_SCRIPT,
38-
CODING_STANDARDS_CONFIG,
3950
CODING_STANDARDS_SCHEMA,
4051
SARIF_SCHEMA,
41-
SARIF_FILE,
4252
]
4353

54+
required_files = [
55+
CODING_STANDARDS_CONFIG,
56+
]
57+
58+
# Check required files (fail if missing)
4459
for file_path in required_files:
4560
if not Path(file_path).exists():
4661
print(f"Error: Required file not found: {file_path}", file=sys.stderr)
4762
return False
4863

64+
# Warn about optional files but don't fail
65+
missing_optional = []
66+
for file_path in optional_files:
67+
if not Path(file_path).exists():
68+
missing_optional.append(file_path)
69+
70+
if missing_optional:
71+
print(f"Warning: Some recategorization files not found: {missing_optional}", file=sys.stderr)
72+
print("Recategorization will be skipped, but filtering will still be applied.", file=sys.stderr)
73+
4974
return True
5075

5176

@@ -54,8 +79,14 @@ def recategorize_sarif():
5479
Run the CodeQL recategorization script on SARIF results.
5580
5681
Returns:
57-
True if successful, False otherwise
82+
True if successful or skipped, False on critical errors
5883
"""
84+
# Check if recategorization script exists
85+
if not Path(RECATEGORIZE_SCRIPT).exists():
86+
print(f"Info: Recategorization script not found at {RECATEGORIZE_SCRIPT}", file=sys.stderr)
87+
print("Skipping recategorization step (will apply filtering only).", file=sys.stderr)
88+
return True # Not a failure, just skip this step
89+
5990
# Create output directory
6091
output_path = Path(OUTPUT_DIR)
6192
output_path.mkdir(parents=True, exist_ok=True)
@@ -172,12 +203,17 @@ def filter_sarif_results():
172203
def main():
173204
"""Main entry point."""
174205
# Validate required files exist
175-
if not validate_paths():
176-
sys.exit(1)
206+
has_sarif = validate_paths()
177207

178-
# Run recategorization
208+
if not has_sarif:
209+
# No SARIF file to process - this is normal before CodeQL analysis runs
210+
print("No SARIF file found - skipping recategorization.")
211+
print("This is expected if CodeQL analysis hasn't completed yet.")
212+
sys.exit(0)
213+
214+
# Run recategorization (will skip gracefully if script not available)
179215
if not recategorize_sarif():
180-
sys.exit(1)
216+
print("Warning: Recategorization failed, continuing with filtering...", file=sys.stderr)
181217

182218
# Filter SARIF results to only include repos/*
183219
if not filter_sarif_results():

0 commit comments

Comments
 (0)