Skip to content

Commit 18e1861

Browse files
committed
style: apply code formatting
- Run make format to apply consistent code formatting - Clean whitespace and apply black/isort/autopep8 formatting
1 parent d8c0510 commit 18e1861

2 files changed

Lines changed: 64 additions & 38 deletions

File tree

dev-tools/scripts/install_dev_tools.py

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -344,24 +344,26 @@ def _install_uv_generic(self):
344344
def _install_actionlint_generic(self):
345345
"""Install actionlint using go install or binary download."""
346346
# Try go install first
347-
if self._run_command(["go", "install", "github.com/rhymond/actionlint/cmd/actionlint@latest"]):
347+
if self._run_command(
348+
["go", "install", "github.com/rhymond/actionlint/cmd/actionlint@latest"]
349+
):
348350
return True
349-
351+
350352
# Fallback to binary download
351353
arch = platform.machine().lower()
352354
if arch == "x86_64":
353355
arch = "amd64"
354356
elif arch in ["aarch64", "arm64"]:
355357
arch = "arm64"
356-
358+
357359
os_name = "linux"
358360
if self.os_type == "darwin":
359361
os_name = "darwin"
360-
362+
361363
url = f"https://github.com/rhymond/actionlint/releases/latest/download/actionlint_1.6.26_{os_name}_{arch}.tar.gz"
362-
return self._run_command([
363-
"curl", "-L", url, "|", "sudo", "tar", "-xz", "-C", "/usr/local/bin", "actionlint"
364-
])
364+
return self._run_command(
365+
["curl", "-L", url, "|", "sudo", "tar", "-xz", "-C", "/usr/local/bin", "actionlint"]
366+
)
365367

366368
def _install_shellcheck_generic(self):
367369
"""Install shellcheck using binary download."""
@@ -370,11 +372,23 @@ def _install_shellcheck_generic(self):
370372
arch = "x86_64"
371373
elif arch in ["aarch64", "arm64"]:
372374
arch = "aarch64"
373-
375+
374376
url = f"https://github.com/koalaman/shellcheck/releases/latest/download/shellcheck-latest.linux.{arch}.tar.xz"
375-
return self._run_command([
376-
"curl", "-L", url, "|", "sudo", "tar", "-xJ", "-C", "/usr/local/bin", "--strip-components=1", f"shellcheck-latest/shellcheck"
377-
])
377+
return self._run_command(
378+
[
379+
"curl",
380+
"-L",
381+
url,
382+
"|",
383+
"sudo",
384+
"tar",
385+
"-xJ",
386+
"-C",
387+
"/usr/local/bin",
388+
"--strip-components=1",
389+
f"shellcheck-latest/shellcheck",
390+
]
391+
)
378392

379393
def _install_trufflehog_generic(self):
380394
"""Install trufflehog using curl."""
@@ -495,7 +509,15 @@ def install_all_tools(self, required_only=False):
495509
required_tools = ["yq", "uv", "docker"]
496510

497511
# Optional tools (for security/quality checks)
498-
optional_tools = ["hadolint", "trivy", "syft", "semgrep", "trufflehog", "actionlint", "shellcheck"]
512+
optional_tools = [
513+
"hadolint",
514+
"trivy",
515+
"syft",
516+
"semgrep",
517+
"trufflehog",
518+
"actionlint",
519+
"shellcheck",
520+
]
499521

500522
tools_to_install = required_tools
501523
if not required_only:

dev-tools/scripts/validate_workflows.py

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import yaml
99

1010
# Set up logging
11-
logging.basicConfig(level=logging.INFO, format='%(message)s')
11+
logging.basicConfig(level=logging.INFO, format="%(message)s")
1212
logger = logging.getLogger(__name__)
1313

1414

@@ -30,70 +30,74 @@ def validate_workflow_structure(file_path: Path):
3030
try:
3131
with open(file_path, "r") as f:
3232
workflow = yaml.safe_load(f)
33-
33+
3434
issues = []
35-
35+
3636
# Check required top-level keys
3737
if not isinstance(workflow, dict):
3838
issues.append("Workflow must be a YAML object")
3939
return issues
40-
41-
if 'name' not in workflow:
40+
41+
if "name" not in workflow:
4242
issues.append("Missing required 'name' field")
43-
43+
4444
# Check for 'on' field (can be parsed as True due to YAML boolean conversion)
45-
if 'on' not in workflow and True not in workflow:
45+
if "on" not in workflow and True not in workflow:
4646
issues.append("Missing required 'on' field")
47-
48-
if 'jobs' not in workflow:
47+
48+
if "jobs" not in workflow:
4949
issues.append("Missing required 'jobs' field")
50-
50+
5151
# Check for common malformed patterns we encountered
52-
if 'jobs' in workflow:
53-
for job_name, job in workflow['jobs'].items():
52+
if "jobs" in workflow:
53+
for job_name, job in workflow["jobs"].items():
5454
if not isinstance(job, dict):
5555
continue
56-
57-
if 'steps' in job:
58-
steps = job['steps']
56+
57+
if "steps" in job:
58+
steps = job["steps"]
5959
if isinstance(steps, list):
6060
for i, step in enumerate(steps):
6161
if not isinstance(step, dict):
6262
continue
63-
63+
6464
# Check for malformed step structure (the main issue we had)
6565
step_str = str(step)
66-
if step_str.count('uses:') > 1:
67-
issues.append(f"Job '{job_name}' step {i+1} has duplicate 'uses' fields")
68-
66+
if step_str.count("uses:") > 1:
67+
issues.append(
68+
f"Job '{job_name}' step {i+1} has duplicate 'uses' fields"
69+
)
70+
6971
# Check for steps that have name but no action (less strict)
70-
if 'name' in step and len(step) == 1:
71-
issues.append(f"Job '{job_name}' step {i+1} ('{step['name']}') has no action")
72-
72+
if "name" in step and len(step) == 1:
73+
issues.append(
74+
f"Job '{job_name}' step {i+1} ('{step['name']}') has no action"
75+
)
76+
7377
return issues
74-
78+
7579
except Exception as e:
7680
return [f"Structure validation error: {e}"]
7781

7882

7983
def validate_workflow(file_path: Path):
8084
"""Validate a single workflow file comprehensively."""
8185
logger.info(f"Validating {file_path.name}...")
82-
86+
8387
# First check YAML syntax
8488
syntax_valid, syntax_error = validate_workflow_syntax(file_path)
8589
if not syntax_valid:
8690
logger.error(f" ❌ {file_path.name}: {syntax_error}")
8791
return False
88-
92+
8993
# Then check workflow structure
9094
structure_issues = validate_workflow_structure(file_path)
9195
if structure_issues:
9296
logger.error(f" ❌ {file_path.name}: Structure issues:")
9397
for issue in structure_issues:
9498
logger.error(f" - {issue}")
9599
return False
96-
100+
97101
logger.info(f" ✅ {file_path.name}: Valid")
98102
return True
99103

0 commit comments

Comments
 (0)