@echo off
setlocal enabledelayedexpansion

echo ================================
echo Development Workflow Runner
echo ================================
echo.

echo This script will run the complete development workflow:
echo 1. Code linting (gdlint)
echo 2. Code formatting (gdformat)
echo 3. Test execution (godot tests)
echo.

set start_time=%time%

REM Step 1: Run Linters
echo --------------------------------
echo Step 1: Running Linters
echo --------------------------------
call run_lint.bat
set lint_result=!errorlevel!
if !lint_result! neq 0 (
    echo.
    echo ❌ LINTING FAILED - Workflow aborted
    echo Please fix linting errors before continuing
    pause
    exit /b 1
)
echo ✅ Linting completed successfully
echo.

REM Step 2: Run Formatters
echo --------------------------------
echo Step 2: Running Formatters
echo --------------------------------
call run_format.bat
set format_result=!errorlevel!
if !format_result! neq 0 (
    echo.
    echo ❌ FORMATTING FAILED - Workflow aborted
    echo Please fix formatting errors before continuing
    pause
    exit /b 1
)
echo ✅ Formatting completed successfully
echo.

REM Step 3: Run Tests
echo --------------------------------
echo Step 3: Running Tests
echo --------------------------------
call run_tests.bat
set test_result=!errorlevel!
if !test_result! neq 0 (
    echo.
    echo ❌ TESTS FAILED - Workflow completed with errors
    set workflow_failed=1
) else (
    echo ✅ Tests completed successfully
    set workflow_failed=0
)
echo.

REM Calculate elapsed time
set end_time=%time%

echo ================================
echo Workflow Summary
echo ================================
echo Linting:   ✅ PASSED
echo Formatting: ✅ PASSED
if !workflow_failed! equ 0 (
    echo Testing:    ✅ PASSED
    echo.
    echo ✅ ALL WORKFLOW STEPS COMPLETED SUCCESSFULLY!
    echo Your code is ready for commit.
) else (
    echo Testing:    ❌ FAILED
    echo.
    echo ❌ WORKFLOW COMPLETED WITH TEST FAILURES
    echo Please review and fix failing tests before committing.
)
echo.
echo Start time: %start_time%
echo End time:   %end_time%

pause
exit /b !workflow_failed!