mirror of
https://github.com/FuzzingLabs/fuzzforge_ai.git
synced 2026-08-24 14:02:32 +02:00
fix: resolve linter errors and optimize CI worker builds
- Remove unused Literal import from backend findings model - Remove unnecessary f-string prefixes in CLI findings command - Optimize GitHub Actions to build only modified workers - Detect specific worker changes (python, secrets, rust, android, ossfuzz) - Build only changed workers instead of all 5 - Build all workers if docker-compose.yml changes - Significantly reduces CI build time
This commit is contained in:
+49
-16
@@ -26,7 +26,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Fetch all history for proper diff
|
fetch-depth: 0 # Fetch all history for proper diff
|
||||||
|
|
||||||
- name: Check if workers were modified
|
- name: Check which workers were modified
|
||||||
id: check-workers
|
id: check-workers
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ github.event_name }}" == "pull_request" ]; then
|
if [ "${{ github.event_name }}" == "pull_request" ]; then
|
||||||
@@ -34,22 +34,54 @@ jobs:
|
|||||||
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
|
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
|
||||||
echo "Changed files:"
|
echo "Changed files:"
|
||||||
echo "$CHANGED_FILES"
|
echo "$CHANGED_FILES"
|
||||||
|
|
||||||
if echo "$CHANGED_FILES" | grep -q "^workers/\|^docker-compose.yml"; then
|
|
||||||
echo "workers_modified=true" >> $GITHUB_OUTPUT
|
|
||||||
echo "✅ Workers or docker-compose.yml modified - will build"
|
|
||||||
else
|
|
||||||
echo "workers_modified=false" >> $GITHUB_OUTPUT
|
|
||||||
echo "⏭️ No worker changes detected - skipping build"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
# For direct pushes, check last commit
|
# For direct pushes, check last commit
|
||||||
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
|
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
|
||||||
if echo "$CHANGED_FILES" | grep -q "^workers/\|^docker-compose.yml"; then
|
fi
|
||||||
echo "workers_modified=true" >> $GITHUB_OUTPUT
|
|
||||||
else
|
# Check if docker-compose.yml changed (build all workers)
|
||||||
echo "workers_modified=false" >> $GITHUB_OUTPUT
|
if echo "$CHANGED_FILES" | grep -q "^docker-compose.yml"; then
|
||||||
fi
|
echo "workers_to_build=worker-python worker-secrets worker-rust worker-android worker-ossfuzz" >> $GITHUB_OUTPUT
|
||||||
|
echo "workers_modified=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "✅ docker-compose.yml modified - building all workers"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Detect which specific workers changed
|
||||||
|
WORKERS_TO_BUILD=""
|
||||||
|
|
||||||
|
if echo "$CHANGED_FILES" | grep -q "^workers/python/"; then
|
||||||
|
WORKERS_TO_BUILD="$WORKERS_TO_BUILD worker-python"
|
||||||
|
echo "✅ Python worker modified"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if echo "$CHANGED_FILES" | grep -q "^workers/secrets/"; then
|
||||||
|
WORKERS_TO_BUILD="$WORKERS_TO_BUILD worker-secrets"
|
||||||
|
echo "✅ Secrets worker modified"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if echo "$CHANGED_FILES" | grep -q "^workers/rust/"; then
|
||||||
|
WORKERS_TO_BUILD="$WORKERS_TO_BUILD worker-rust"
|
||||||
|
echo "✅ Rust worker modified"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if echo "$CHANGED_FILES" | grep -q "^workers/android/"; then
|
||||||
|
WORKERS_TO_BUILD="$WORKERS_TO_BUILD worker-android"
|
||||||
|
echo "✅ Android worker modified"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if echo "$CHANGED_FILES" | grep -q "^workers/ossfuzz/"; then
|
||||||
|
WORKERS_TO_BUILD="$WORKERS_TO_BUILD worker-ossfuzz"
|
||||||
|
echo "✅ OSS-Fuzz worker modified"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$WORKERS_TO_BUILD" ]; then
|
||||||
|
echo "workers_modified=false" >> $GITHUB_OUTPUT
|
||||||
|
echo "⏭️ No worker changes detected - skipping build"
|
||||||
|
else
|
||||||
|
echo "workers_to_build=$WORKERS_TO_BUILD" >> $GITHUB_OUTPUT
|
||||||
|
echo "workers_modified=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "Building workers:$WORKERS_TO_BUILD"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
@@ -59,8 +91,9 @@ jobs:
|
|||||||
- name: Build worker images
|
- name: Build worker images
|
||||||
if: steps.check-workers.outputs.workers_modified == 'true'
|
if: steps.check-workers.outputs.workers_modified == 'true'
|
||||||
run: |
|
run: |
|
||||||
echo "Building worker Docker images..."
|
WORKERS="${{ steps.check-workers.outputs.workers_to_build }}"
|
||||||
docker compose build worker-python worker-secrets worker-rust worker-android worker-ossfuzz --no-cache
|
echo "Building worker Docker images: $WORKERS"
|
||||||
|
docker compose build $WORKERS --no-cache
|
||||||
continue-on-error: false
|
continue-on-error: false
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ Models for workflow findings and submissions
|
|||||||
# Additional attribution and requirements are provided in the NOTICE file.
|
# Additional attribution and requirements are provided in the NOTICE file.
|
||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
from typing import Dict, Any, Optional, Literal, List
|
from typing import Dict, Any, Optional, List
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -253,15 +253,15 @@ def display_finding_detail(finding: Dict[str, Any], tool: Dict[str, Any], run_id
|
|||||||
content_lines.append(f"[bold]Tool:[/bold] {tool.get('name', 'Unknown')} v{tool.get('version', 'unknown')}")
|
content_lines.append(f"[bold]Tool:[/bold] {tool.get('name', 'Unknown')} v{tool.get('version', 'unknown')}")
|
||||||
content_lines.append(f"[bold]Run ID:[/bold] {run_id}")
|
content_lines.append(f"[bold]Run ID:[/bold] {run_id}")
|
||||||
content_lines.append("")
|
content_lines.append("")
|
||||||
content_lines.append(f"[bold]Summary:[/bold]")
|
content_lines.append("[bold]Summary:[/bold]")
|
||||||
content_lines.append(message_text)
|
content_lines.append(message_text)
|
||||||
content_lines.append("")
|
content_lines.append("")
|
||||||
content_lines.append(f"[bold]Description:[/bold]")
|
content_lines.append("[bold]Description:[/bold]")
|
||||||
content_lines.append(message_markdown)
|
content_lines.append(message_markdown)
|
||||||
|
|
||||||
if code_snippet:
|
if code_snippet:
|
||||||
content_lines.append("")
|
content_lines.append("")
|
||||||
content_lines.append(f"[bold]Code Snippet:[/bold]")
|
content_lines.append("[bold]Code Snippet:[/bold]")
|
||||||
content_lines.append(f"[dim]{code_snippet}[/dim]")
|
content_lines.append(f"[dim]{code_snippet}[/dim]")
|
||||||
|
|
||||||
content = "\n".join(content_lines)
|
content = "\n".join(content_lines)
|
||||||
@@ -270,7 +270,7 @@ def display_finding_detail(finding: Dict[str, Any], tool: Dict[str, Any], run_id
|
|||||||
console.print()
|
console.print()
|
||||||
console.print(Panel(
|
console.print(Panel(
|
||||||
content,
|
content,
|
||||||
title=f"🔍 Finding Detail",
|
title="🔍 Finding Detail",
|
||||||
border_style=severity_color,
|
border_style=severity_color,
|
||||||
box=box.ROUNDED,
|
box=box.ROUNDED,
|
||||||
padding=(1, 2)
|
padding=(1, 2)
|
||||||
|
|||||||
Reference in New Issue
Block a user