fix: fixing api and tests #200
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: Run Tests on All Platforms | |
| on: | |
| push: | |
| branches: | |
| - "*" | |
| pull_request: | |
| branches: | |
| - "*" | |
| permissions: | |
| contents: read | |
| env: | |
| PYTHON_VERSION: "3.12" | |
| jobs: | |
| test-linux: | |
| name: Tests (Linux) | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential libglib2.0-dev libgl1-mesa-dev xvfb | |
| - name: Setup virtual display | |
| run: | | |
| export DISPLAY=:99 | |
| Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & | |
| echo "DISPLAY=:99" >> $GITHUB_ENV | |
| sleep 2 # Wait for Xvfb to start | |
| - name: Install .NET runtime | |
| run: | | |
| wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh | |
| chmod +x dotnet-install.sh | |
| ./dotnet-install.sh --channel 8.0 --runtime dotnet --install-dir $HOME/.dotnet | |
| echo "$HOME/.dotnet" >> $GITHUB_PATH | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install -U pip wheel | |
| pip install -r builds/requirements.txt | |
| pip install -r tests/requirements.txt | |
| - name: Download and extract UTMTCLI for Linux | |
| run: | | |
| mkdir -p src/assets/bin/utmtcli_linux | |
| curl -L -o utmtcli_linux.zip "https://github.com/UnderminersTeam/UndertaleModTool/releases/download/nightly/CLI-ubuntu-latest-Debug-isBundled-true.zip" | |
| unzip -q utmtcli_linux.zip -d src/assets/bin/utmtcli_linux | |
| rm utmtcli_linux.zip | |
| chmod +x src/assets/bin/utmtcli_linux/* 2>/dev/null || true | |
| - name: Debug test discovery | |
| env: | |
| PYTHONPATH: ${{ github.workspace }}/src | |
| DISPLAY: :99 | |
| QT_QPA_PLATFORM: offscreen | |
| run: | | |
| echo "PYTHONPATH: $PYTHONPATH" | |
| echo "Python path:" | |
| python -c "import sys; print('\n'.join(sys.path))" | |
| echo "Test files:" | |
| find tests -name "test_*.py" -type f 2>&1 | head -20 || (ls -R tests/ 2>&1 | grep "test_.*\.py" | head -20) || (ls -la tests/unit/ tests/integration/ tests/ui/ 2>&1 | head -20) || true | |
| echo "Trying to import conftest:" | |
| python -c "import sys; sys.path.insert(0, '${{ github.workspace }}/src'); import tests.conftest; print('conftest imported successfully')" || true | |
| echo "Trying to import a test file:" | |
| python -c "import sys; sys.path.insert(0, '${{ github.workspace }}/src'); import tests.unit.test_config; print('test_config imported successfully')" || echo "Failed to import test_config" | |
| echo "Running pytest with verbose collection:" | |
| pytest tests/ --collect-only -q 2>&1 | head -50 || true | |
| echo "Checking if pytest can see test files:" | |
| python -c "import os; test_files = []; [test_files.extend([os.path.join(root, f) for f in files if f.startswith('test_') and f.endswith('.py')]) for root, dirs, files in os.walk('tests')]; print(f'Found {len(test_files)} test files:'); [print(f) for f in test_files[:10]]" || true | |
| - name: Run all tests | |
| id: run_tests | |
| continue-on-error: true | |
| env: | |
| PYTHONPATH: ${{ github.workspace }}/src | |
| DISPLAY: :99 | |
| QT_QPA_PLATFORM: offscreen | |
| run: | | |
| pytest tests/ -vv --collect-only --tb=short 2>&1 | tee test-collection.log || true | |
| pytest tests/ -v --tb=short --maxfail=5 --html=test-report.html --self-contained-html 2>&1 | tee test-output.log | |
| TEST_EXIT_CODE=$? | |
| echo "exit_code=$TEST_EXIT_CODE" >> $GITHUB_OUTPUT | |
| exit $TEST_EXIT_CODE | |
| - name: Check test results | |
| if: always() | |
| run: | | |
| if [ "${{ steps.run_tests.outcome }}" != "success" ]; then | |
| echo "Tests failed or were cancelled" | |
| exit 1 | |
| fi | |
| - name: Publish test results summary | |
| if: always() | |
| run: | | |
| echo "## 📊 Test Results Summary (Linux)" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| # Extract test results from log if available | |
| if [ -f test-output.log ]; then | |
| echo "### Test Execution Log" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| tail -20 test-output.log >> $GITHUB_STEP_SUMMARY || true | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| # Extract summary line | |
| SUMMARY=$(grep -E "(passed|failed|skipped|error)" test-output.log | tail -1 || echo "") | |
| if [ -n "$SUMMARY" ]; then | |
| echo "### Test Statistics" >> $GITHUB_STEP_SUMMARY | |
| echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| fi | |
| if [ -f test-report.html ]; then | |
| echo "✅ **HTML Test Report Generated**" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Download the report from artifacts: \`test-results-linux\`" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "⚠️ **HTML Test Report Not Generated**" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Check test logs for details." >> $GITHUB_STEP_SUMMARY | |
| fi | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-linux | |
| path: | | |
| .pytest_cache/ | |
| htmlcov/ | |
| test-report.html | |
| test-output.log | |
| test-collection.log | |
| if-no-files-found: ignore | |
| retention-days: 7 | |
| test-macos-x64: | |
| name: Tests (macOS x64) | |
| runs-on: macos-15-intel | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install -U pip wheel | |
| pip install -r builds/requirements.txt | |
| pip install -r tests/requirements.txt | |
| - name: Download and extract UTMTCLI for macOS x64 | |
| run: | | |
| mkdir -p src/assets/bin/utmtcli_macos | |
| curl -L -o utmtcli_macos.zip "https://github.com/UnderminersTeam/UndertaleModTool/releases/download/nightly/CLI-macOS-latest-Debug-isBundled-true.zip" | |
| unzip -q utmtcli_macos.zip -d src/assets/bin/utmtcli_macos | |
| rm utmtcli_macos.zip | |
| chmod +x src/assets/bin/utmtcli_macos/* 2>/dev/null || true | |
| - name: Debug test discovery | |
| env: | |
| PYTHONPATH: ${{ github.workspace }}/src | |
| run: | | |
| echo "PYTHONPATH: $PYTHONPATH" | |
| echo "Python path:" | |
| python -c "import sys; print('\n'.join(sys.path))" | |
| echo "Test files:" | |
| find tests -name "test_*.py" -type f 2>&1 | head -20 || (ls -R tests/ 2>&1 | grep "test_.*\.py" | head -20) || (ls -la tests/unit/ tests/integration/ tests/ui/ 2>&1 | head -20) || true | |
| echo "Trying to import conftest:" | |
| python -c "import sys; sys.path.insert(0, '${{ github.workspace }}/src'); import tests.conftest; print('conftest imported successfully')" || true | |
| echo "Trying to import a test file:" | |
| python -c "import sys; sys.path.insert(0, '${{ github.workspace }}/src'); import tests.unit.test_config; print('test_config imported successfully')" || echo "Failed to import test_config" | |
| echo "Running pytest with verbose collection:" | |
| pytest tests/ --collect-only -q 2>&1 | head -50 || true | |
| echo "Checking if pytest can see test files:" | |
| python -c "import os; test_files = []; [test_files.extend([os.path.join(root, f) for f in files if f.startswith('test_') and f.endswith('.py')]) for root, dirs, files in os.walk('tests')]; print(f'Found {len(test_files)} test files:'); [print(f) for f in test_files[:10]]" || true | |
| - name: Run all tests | |
| id: run_tests | |
| continue-on-error: true | |
| env: | |
| PYTHONPATH: ${{ github.workspace }}/src | |
| run: | | |
| pytest tests/ -vv --collect-only --tb=short 2>&1 | tee test-collection.log || true | |
| pytest tests/ -v --tb=short --maxfail=5 --html=test-report.html --self-contained-html 2>&1 | tee test-output.log | |
| TEST_EXIT_CODE=$? | |
| echo "exit_code=$TEST_EXIT_CODE" >> $GITHUB_OUTPUT | |
| exit $TEST_EXIT_CODE | |
| - name: Check test results | |
| if: always() | |
| run: | | |
| if [ "${{ steps.run_tests.outcome }}" != "success" ]; then | |
| echo "Tests failed or were cancelled" | |
| exit 1 | |
| fi | |
| - name: Publish test results summary | |
| if: always() | |
| run: | | |
| echo "## 📊 Test Results Summary (macOS x64)" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| # Extract test results from log if available | |
| if [ -f test-output.log ]; then | |
| echo "### Test Execution Log" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| tail -20 test-output.log >> $GITHUB_STEP_SUMMARY || true | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| # Extract summary line | |
| SUMMARY=$(grep -E "(passed|failed|skipped|error)" test-output.log | tail -1 || echo "") | |
| if [ -n "$SUMMARY" ]; then | |
| echo "### Test Statistics" >> $GITHUB_STEP_SUMMARY | |
| echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| fi | |
| if [ -f test-report.html ]; then | |
| echo "✅ **HTML Test Report Generated**" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Download the report from artifacts: \`test-results-macos-x64\`" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "⚠️ **HTML Test Report Not Generated**" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Check test logs for details." >> $GITHUB_STEP_SUMMARY | |
| fi | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-macos-x64 | |
| path: | | |
| .pytest_cache/ | |
| htmlcov/ | |
| test-report.html | |
| test-output.log | |
| test-collection.log | |
| if-no-files-found: ignore | |
| retention-days: 7 | |
| test-macos-arm64: | |
| name: Tests (macOS arm64) | |
| runs-on: macos-15 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install -U pip wheel | |
| pip install -r builds/requirements.txt | |
| pip install -r tests/requirements.txt | |
| - name: Download and extract UTMTCLI for macOS arm64 | |
| run: | | |
| mkdir -p src/assets/bin/utmtcli_macos | |
| curl -L -o utmtcli_macos.zip "https://github.com/UnderminersTeam/UndertaleModTool/releases/download/nightly/CLI-macOS-latest-Debug-isBundled-true.zip" | |
| unzip -q utmtcli_macos.zip -d src/assets/bin/utmtcli_macos | |
| rm utmtcli_macos.zip | |
| chmod +x src/assets/bin/utmtcli_macos/* 2>/dev/null || true | |
| - name: Debug test discovery | |
| env: | |
| PYTHONPATH: ${{ github.workspace }}/src | |
| run: | | |
| echo "PYTHONPATH: $PYTHONPATH" | |
| echo "Python path:" | |
| python -c "import sys; print('\n'.join(sys.path))" | |
| echo "Test files:" | |
| find tests -name "test_*.py" -type f 2>&1 | head -20 || (ls -R tests/ 2>&1 | grep "test_.*\.py" | head -20) || (ls -la tests/unit/ tests/integration/ tests/ui/ 2>&1 | head -20) || true | |
| echo "Trying to import conftest:" | |
| python -c "import sys; sys.path.insert(0, '${{ github.workspace }}/src'); import tests.conftest; print('conftest imported successfully')" || true | |
| echo "Trying to import a test file:" | |
| python -c "import sys; sys.path.insert(0, '${{ github.workspace }}/src'); import tests.unit.test_config; print('test_config imported successfully')" || echo "Failed to import test_config" | |
| echo "Running pytest with verbose collection:" | |
| pytest tests/ --collect-only -q 2>&1 | head -50 || true | |
| echo "Checking if pytest can see test files:" | |
| python -c "import os; test_files = []; [test_files.extend([os.path.join(root, f) for f in files if f.startswith('test_') and f.endswith('.py')]) for root, dirs, files in os.walk('tests')]; print(f'Found {len(test_files)} test files:'); [print(f) for f in test_files[:10]]" || true | |
| - name: Run all tests | |
| id: run_tests | |
| continue-on-error: true | |
| env: | |
| PYTHONPATH: ${{ github.workspace }}/src | |
| run: | | |
| pytest tests/ -vv --collect-only --tb=short 2>&1 | tee test-collection.log || true | |
| pytest tests/ -v --tb=short --maxfail=5 --html=test-report.html --self-contained-html 2>&1 | tee test-output.log | |
| TEST_EXIT_CODE=$? | |
| echo "exit_code=$TEST_EXIT_CODE" >> $GITHUB_OUTPUT | |
| exit $TEST_EXIT_CODE | |
| - name: Check test results | |
| if: always() | |
| run: | | |
| if [ "${{ steps.run_tests.outcome }}" != "success" ]; then | |
| echo "Tests failed or were cancelled" | |
| exit 1 | |
| fi | |
| - name: Publish test results summary | |
| if: always() | |
| run: | | |
| echo "## 📊 Test Results Summary (macOS arm64)" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| # Extract test results from log if available | |
| if [ -f test-output.log ]; then | |
| echo "### Test Execution Log" >> $GITHUB_STEP_SUMMARY | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| tail -20 test-output.log >> $GITHUB_STEP_SUMMARY || true | |
| echo '```' >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| # Extract summary line | |
| SUMMARY=$(grep -E "(passed|failed|skipped|error)" test-output.log | tail -1 || echo "") | |
| if [ -n "$SUMMARY" ]; then | |
| echo "### Test Statistics" >> $GITHUB_STEP_SUMMARY | |
| echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| fi | |
| if [ -f test-report.html ]; then | |
| echo "✅ **HTML Test Report Generated**" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Download the report from artifacts: \`test-results-macos-arm64\`" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "⚠️ **HTML Test Report Not Generated**" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Check test logs for details." >> $GITHUB_STEP_SUMMARY | |
| fi | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-macos-arm64 | |
| path: | | |
| .pytest_cache/ | |
| htmlcov/ | |
| test-report.html | |
| test-output.log | |
| test-collection.log | |
| if-no-files-found: ignore | |
| retention-days: 7 | |
| test-windows: | |
| name: Tests (Windows) | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install -U pip wheel | |
| pip install -r builds/requirements.txt | |
| pip install -r tests/requirements.txt | |
| - name: Download and extract UTMTCLI for Windows | |
| shell: powershell | |
| run: | | |
| New-Item -ItemType Directory -Force -Path "src\assets\bin\utmtcli_windows" | Out-Null | |
| $zipPath = "utmtcli_windows.zip" | |
| Invoke-WebRequest -Uri "https://github.com/UnderminersTeam/UndertaleModTool/releases/download/nightly/CLI-windows-latest-Debug-isBundled-true.zip" -OutFile $zipPath | |
| Expand-Archive -Path $zipPath -DestinationPath "src\assets\bin\utmtcli_windows" -Force | |
| Remove-Item $zipPath | |
| - name: Debug test discovery | |
| shell: powershell | |
| env: | |
| PYTHONPATH: ${{ github.workspace }}\src | |
| run: | | |
| Write-Host "PYTHONPATH: $env:PYTHONPATH" | |
| Write-Host "Python path:" | |
| python -c "import sys; print('\n'.join(sys.path))" | |
| Write-Host "Test files:" | |
| Get-ChildItem -Path tests -Recurse -Filter "test_*.py" | Select-Object -ExpandProperty FullName | |
| Write-Host "Trying to import conftest:" | |
| python -c "import sys; sys.path.insert(0, r'${{ github.workspace }}\src'); import tests.conftest; print('conftest imported successfully')" | |
| if ($LASTEXITCODE -ne 0) { Write-Host "Failed to import conftest" } | |
| Write-Host "Trying to import a test file:" | |
| python -c "import sys; sys.path.insert(0, r'${{ github.workspace }}\src'); import tests.unit.test_config; print('test_config imported successfully')" | |
| if ($LASTEXITCODE -ne 0) { Write-Host "Failed to import test_config" } | |
| Write-Host "Running pytest with verbose collection:" | |
| pytest tests/ --collect-only -q 2>&1 | Select-Object -First 50 | |
| Write-Host "Checking if pytest can see test files:" | |
| python -c "import os; test_files = []; [test_files.extend([os.path.join(root, f) for f in files if f.startswith('test_') and f.endswith('.py')]) for root, dirs, files in os.walk('tests')]; print(f'Found {len(test_files)} test files:'); [print(f) for f in test_files[:10]]" | |
| - name: Run all tests | |
| id: run_tests | |
| continue-on-error: true | |
| shell: powershell | |
| env: | |
| PYTHONPATH: ${{ github.workspace }}\src | |
| run: | | |
| pytest tests/ -vv --collect-only --tb=short 2>&1 | Tee-Object -FilePath test-collection.log | |
| if ($LASTEXITCODE -ne 0) { Write-Host "Collection failed with exit code $LASTEXITCODE" } | |
| pytest tests/ -v --tb=short --maxfail=5 --html=test-report.html --self-contained-html 2>&1 | Tee-Object -FilePath test-output.log | |
| $exitCode = if ($LASTEXITCODE) { $LASTEXITCODE } else { 0 } | |
| echo "exit_code=$exitCode" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8 | |
| exit $exitCode | |
| - name: Check test results | |
| if: always() | |
| shell: powershell | |
| run: | | |
| if ("${{ steps.run_tests.outcome }}" -ne "success") { | |
| Write-Host "Tests failed or were cancelled" | |
| exit 1 | |
| } | |
| - name: Publish test results summary | |
| if: always() | |
| shell: powershell | |
| run: | | |
| $summary = @" | |
| ## 📊 Test Results Summary (Windows) | |
| "@ | |
| if (Test-Path "test-output.log") { | |
| $summary += "### Test Execution Log`n" | |
| $summary += "``````n" | |
| $lastLines = Get-Content "test-output.log" -Tail 20 -ErrorAction SilentlyContinue | |
| if ($lastLines) { | |
| $summary += ($lastLines -join "`n") + "`n" | |
| } | |
| $summary += "``````n`n" | |
| # Extract summary line | |
| $summaryLine = Get-Content "test-output.log" -ErrorAction SilentlyContinue | Select-String -Pattern "(passed|failed|skipped|error)" | Select-Object -Last 1 | |
| if ($summaryLine) { | |
| $summary += "### Test Statistics`n" | |
| $summary += "$($summaryLine.Line)`n`n" | |
| } | |
| } | |
| if (Test-Path "test-report.html") { | |
| $summary += "✅ **HTML Test Report Generated**`n`n" | |
| $summary += "Download the report from artifacts: ``test-results-windows```n" | |
| } else { | |
| $summary += "⚠️ **HTML Test Report Not Generated**`n`n" | |
| $summary += "Check test logs for details.`n" | |
| } | |
| Add-Content -Path $env:GITHUB_STEP_SUMMARY -Value $summary | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-windows | |
| path: | | |
| .pytest_cache/ | |
| htmlcov/ | |
| test-report.html | |
| test-output.log | |
| test-collection.log | |
| if-no-files-found: ignore | |
| retention-days: 7 |