Add packaging scripts and user home config #26
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test Victoria Script | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| workflow_dispatch: | |
| jobs: | |
| test-victoria: | |
| name: Test Victoria on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.x' # Latest stable Python version | |
| - name: Display Python version and environment info | |
| run: | | |
| python --version | |
| python -c "import sys; print('Platform:', sys.platform)" | |
| python -c "import os; print('OS name:', os.name)" | |
| python -c "import platform; print('System:', platform.system(), platform.release())" | |
| - name: Test Python script imports and basic functionality | |
| shell: bash | |
| run: | | |
| # Set UTF-8 encoding for Windows | |
| if [[ "${{ runner.os }}" == "Windows" ]]; then | |
| export PYTHONIOENCODING=utf-8 | |
| chcp 65001 || true # Set Windows console to UTF-8 | |
| python tests/test_victoria.py | |
| python tests/test_non_interactive.py | |
| else | |
| python3 tests/test_victoria.py | |
| python3 tests/test_non_interactive.py | |
| fi | |
| - name: Test script execution with different terminal environments | |
| shell: bash | |
| run: | | |
| echo "Testing with different TERM settings..." | |
| # Use appropriate Python command based on OS | |
| if [[ "${{ runner.os }}" == "Windows" ]]; then | |
| PYTHON_CMD="python" | |
| else | |
| PYTHON_CMD="python3" | |
| fi | |
| # Test with no TERM set | |
| unset TERM | |
| echo "Testing with no TERM variable:" | |
| if [[ "${{ runner.os }}" == "Windows" ]]; then | |
| timeout 5 $PYTHON_CMD victoria.py < nul || echo "Script handled no TERM gracefully (exit code: $?)" | |
| else | |
| timeout 5 $PYTHON_CMD victoria.py < /dev/null || echo "Script handled no TERM gracefully (exit code: $?)" | |
| fi | |
| # Test with basic TERM | |
| export TERM=dumb | |
| echo "Testing with TERM=dumb:" | |
| if [[ "${{ runner.os }}" == "Windows" ]]; then | |
| timeout 5 $PYTHON_CMD victoria.py < nul || echo "Script handled TERM=dumb gracefully (exit code: $?)" | |
| else | |
| timeout 5 $PYTHON_CMD victoria.py < /dev/null || echo "Script handled TERM=dumb gracefully (exit code: $?)" | |
| fi | |
| # Test with color TERM | |
| export TERM=xterm-256color | |
| echo "Testing with TERM=xterm-256color:" | |
| if [[ "${{ runner.os }}" == "Windows" ]]; then | |
| timeout 5 $PYTHON_CMD victoria.py < nul || echo "Script handled TERM=xterm-256color gracefully (exit code: $?)" | |
| else | |
| timeout 5 $PYTHON_CMD victoria.py < /dev/null || echo "Script handled TERM=xterm-256color gracefully (exit code: $?)" | |
| fi | |
| - name: Test script execution on Windows (PowerShell) | |
| if: runner.os == 'Windows' | |
| shell: powershell | |
| run: | | |
| # Set UTF-8 encoding for PowerShell | |
| [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 | |
| $env:PYTHONIOENCODING = "utf-8" | |
| chcp 65001 | Out-Null | |
| Write-Host "Testing Victoria script in PowerShell environment" | |
| # Test with timeout to prevent hanging | |
| try { | |
| $process = Start-Process -FilePath "python" -ArgumentList "victoria.py" -PassThru -NoNewWindow -RedirectStandardInput $null | |
| $process.WaitForExit(5000) # 5 second timeout | |
| if (!$process.HasExited) { | |
| $process.Kill() | |
| Write-Host "Script was terminated after timeout (expected behavior)" | |
| } else { | |
| Write-Host "Script exited with code: $($process.ExitCode)" | |
| } | |
| } catch { | |
| Write-Host "PowerShell test completed with exception (expected): $_" | |
| } | |
| Write-Host "PowerShell test completed" | |
| - name: Test with various environment variables | |
| shell: bash | |
| run: | | |
| echo "Testing with different environment configurations..." | |
| # Use appropriate Python command based on OS | |
| if [[ "${{ runner.os }}" == "Windows" ]]; then | |
| PYTHON_CMD="python" | |
| NULL_INPUT="nul" | |
| else | |
| PYTHON_CMD="python3" | |
| NULL_INPUT="/dev/null" | |
| fi | |
| # Test with UTF-8 locale (skip on Windows as it handles locales differently) | |
| if [[ "${{ runner.os }}" != "Windows" ]]; then | |
| export LANG=en_US.UTF-8 | |
| export LC_ALL=en_US.UTF-8 | |
| timeout 5 $PYTHON_CMD victoria.py < $NULL_INPUT || echo "UTF-8 locale test completed (exit code: $?)" | |
| # Test with C locale | |
| export LANG=C | |
| export LC_ALL=C | |
| timeout 5 $PYTHON_CMD victoria.py < $NULL_INPUT || echo "C locale test completed (exit code: $?)" | |
| else | |
| echo "Skipping locale tests on Windows (different locale system)" | |
| fi | |
| # Test with debug mode | |
| export VICTORIA_DEBUG=1 | |
| timeout 5 $PYTHON_CMD victoria.py < $NULL_INPUT || echo "Debug mode test completed (exit code: $?)" | |
| - name: Verify script handles Ctrl+C gracefully | |
| shell: bash | |
| run: | | |
| echo "Testing Ctrl+C handling..." | |
| # Use appropriate Python command based on OS | |
| if [[ "${{ runner.os }}" == "Windows" ]]; then | |
| PYTHON_CMD="python" | |
| NULL_INPUT="nul" | |
| else | |
| PYTHON_CMD="python3" | |
| NULL_INPUT="/dev/null" | |
| fi | |
| # This should exit with code 130 (128 + SIGINT) or timeout | |
| timeout 3 $PYTHON_CMD victoria.py < $NULL_INPUT || { | |
| exit_code=$? | |
| if [ $exit_code -eq 124 ]; then | |
| echo "Script was terminated by timeout (expected)" | |
| elif [ $exit_code -eq 130 ]; then | |
| echo "Script handled Ctrl+C gracefully (exit code 130)" | |
| else | |
| echo "Script exited with code: $exit_code" | |
| fi | |
| } | |
| - name: Test script syntax and imports | |
| shell: bash | |
| run: | | |
| echo "Checking Python syntax..." | |
| # Use appropriate Python command based on OS | |
| if [[ "${{ runner.os }}" == "Windows" ]]; then | |
| PYTHON_CMD="python" | |
| else | |
| PYTHON_CMD="python3" | |
| fi | |
| $PYTHON_CMD -m py_compile victoria.py | |
| echo "Syntax check passed!" | |
| echo "Testing imports..." | |
| $PYTHON_CMD -c " | |
| import sys | |
| sys.path.insert(0, '.') | |
| try: | |
| import victoria | |
| print('+ All imports successful') | |
| except ImportError as e: | |
| print(f'- Import error: {e}') | |
| sys.exit(1) | |
| except Exception as e: | |
| print(f'+ Script loaded (non-import error is expected): {e}') | |
| " | |
| - name: Test cross-platform file operations | |
| shell: bash | |
| run: | | |
| echo "Testing file operations..." | |
| # Use appropriate Python command based on OS | |
| if [[ "${{ runner.os }}" == "Windows" ]]; then | |
| PYTHON_CMD="python" | |
| else | |
| PYTHON_CMD="python3" | |
| fi | |
| $PYTHON_CMD -c " | |
| import os | |
| import tempfile | |
| from pathlib import Path | |
| # Test Path operations (used in victoria.py) | |
| temp_dir = Path(tempfile.mkdtemp()) | |
| test_file = temp_dir / 'test.json' | |
| test_file.write_text('{\"test\": true}') | |
| print(f'+ File operations work: {test_file.exists()}') | |
| # Cleanup | |
| import shutil | |
| shutil.rmtree(temp_dir) | |
| print('+ Cleanup successful') | |
| " | |
| - name: Test terminal capability detection | |
| shell: bash | |
| run: | | |
| echo "Testing terminal capability detection..." | |
| # Use appropriate Python command based on OS | |
| if [[ "${{ runner.os }}" == "Windows" ]]; then | |
| PYTHON_CMD="python" | |
| else | |
| PYTHON_CMD="python3" | |
| fi | |
| $PYTHON_CMD -c " | |
| import sys | |
| import os | |
| sys.path.insert(0, '.') | |
| try: | |
| # Import the terminal detection functions | |
| with open('victoria.py', 'r', encoding='utf-8') as f: | |
| content = f.read() | |
| # Execute only the function definitions, not the main block | |
| exec(content.split('if __name__')[0]) | |
| caps = detect_terminal_capabilities() | |
| print(f'Terminal capabilities detected: {caps}') | |
| # Test that it doesn't crash | |
| width = get_terminal_width() | |
| print(f'Terminal width: {width}') | |
| print('+ Terminal capability detection works') | |
| except Exception as e: | |
| print(f'+ Terminal capability test completed with expected error: {e}') | |
| " |