|
6 | 6 | from pathlib import Path |
7 | 7 | from sumologic_client import SumoLogicClient |
8 | 8 |
|
| 9 | +def debug_environment(): |
| 10 | + """Print critical debugging info""" |
| 11 | + print("::group::Debug Information") |
| 12 | + print(f"Current directory: {os.getcwd()}") |
| 13 | + print("Directory contents:") |
| 14 | + os.system("ls -R") |
| 15 | + print(f"Environment: {dict(os.environ)}") |
| 16 | + print("::endgroup::") |
| 17 | + |
| 18 | +def get_changed_files(): |
| 19 | + """Get changed files from GitHub or fallback to full scan""" |
| 20 | + # Try GitHub Actions event data first |
| 21 | + if "GITHUB_EVENT_PATH" in os.environ: |
| 22 | + try: |
| 23 | + with open(os.environ["GITHUB_EVENT_PATH"]) as f: |
| 24 | + event_data = json.load(f) |
| 25 | + return [ |
| 26 | + f for f in |
| 27 | + [f.get('filename') for f in event_data.get('pull_request', {}).get('files', [])] |
| 28 | + if f and f.endswith('.md') |
| 29 | + ] |
| 30 | + except Exception as e: |
| 31 | + print(f"::warning::Failed to read GitHub event: {str(e)}") |
| 32 | + |
| 33 | + # Fallback: Scan all documentation files |
| 34 | + return [str(p) for p in Path(".").rglob("*.md") if "search-query-language" in str(p)] |
| 35 | + |
9 | 36 | def find_sql_blocks_in_pr(): |
10 | 37 | """Detect changed SQL blocks with better debugging""" |
11 | 38 | print("::group::Detecting SQL blocks") # GitHub Actions log grouping |
@@ -34,6 +61,16 @@ def find_sql_blocks_in_pr(): |
34 | 61 | return changed_files |
35 | 62 |
|
36 | 63 | def validate_queries(): |
| 64 | + debug_environment() |
| 65 | + |
| 66 | + changed_files = get_changed_files() |
| 67 | + print(f"::group::Files to validate") |
| 68 | + print("\n".join(changed_files) or "No files found") |
| 69 | + print("::endgroup::") |
| 70 | + |
| 71 | + if not changed_files: |
| 72 | + print("::warning::No Markdown files found to validate") |
| 73 | + return |
37 | 74 | print("::group::Starting validation") |
38 | 75 | client = SumoLogicClient() |
39 | 76 | failed = False |
|
0 commit comments