Add export/import DB commands and data-dir helper #198
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: | |
| pull_request: | |
| branches: [ main ] | |
| permissions: | |
| contents: read | |
| jobs: | |
| test: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-2025] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install Poetry | |
| run: pip install poetry -U | |
| - name: Install dependencies | |
| run: poetry install | |
| # Linux shell dependencies | |
| - name: Install shell dependencies (Linux) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y fish zsh | |
| # macOS shell dependencies | |
| - name: Install shell dependencies (macOS) | |
| if: matrix.os == 'macos-latest' | |
| run: | | |
| brew install fish zsh | |
| - name: Show environment info | |
| run: | | |
| poetry --version | |
| python --version | |
| poetry show | |
| env | |
| # Install PiecesOS based on platform | |
| - name: Install PiecesOS (Linux) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| sudo apt update | |
| sudo apt install snapd | |
| sudo snap install pieces-os | |
| - name: Install PiecesOS (macOS) | |
| if: matrix.os == 'macos-latest' | |
| run: | | |
| brew install --cask pieces-os | |
| - name: Install PiecesOS (Windows) | |
| if: matrix.os == 'windows-2025' | |
| run: | | |
| winget install "Pieces OS" --silent --accept-package-agreements --accept-source-agreements | |
| - name: Download test database (Linux) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| FILE_ID="1izwYjYrzitZgEznwRbAV_Ft6_hxNYXis" | |
| DOWNLOAD_URL="https://drive.google.com/uc?export=download&id=${FILE_ID}" | |
| DEST_PATH="$HOME/Documents/com.pieces.os/production" | |
| mkdir -p "$(dirname "$DEST_PATH")" | |
| curl -L "$DOWNLOAD_URL" -o "$DEST_PATH" | |
| echo "Saved to $DEST_PATH" | |
| - name: Download test database (macOS) | |
| if: matrix.os == 'macos-latest' | |
| run: | | |
| FILE_ID="1zm_yzWBeDb2KjggdxTkA7IALR0A8EIfC" | |
| DOWNLOAD_URL="https://drive.google.com/uc?export=download&id=${FILE_ID}" | |
| DEST_PATH="$HOME/Library/com.pieces.os/production" | |
| mkdir -p "$(dirname "$DEST_PATH")" | |
| curl -L "$DOWNLOAD_URL" -o "$DEST_PATH" | |
| echo "Saved to $DEST_PATH" | |
| - name: Download test database (Windows) | |
| if: matrix.os == 'windows-2025' | |
| run: | | |
| $FILE_ID = "1zm_yzWBeDb2KjggdxTkA7IALR0A8EIfC" | |
| $DOWNLOAD_URL = "https://drive.google.com/uc?export=download&id=$FILE_ID" | |
| $DEST_PATH = "$env:LOCALAPPDATA\Mesh Intelligent Technologies, Inc.\Pieces OS\com.pieces.os\production" | |
| New-Item -ItemType Directory -Force -Path (Split-Path $DEST_PATH) | |
| Invoke-WebRequest -Uri $DOWNLOAD_URL -OutFile $DEST_PATH | |
| Write-Host "Saved to $DEST_PATH" | |
| - name: Fix Windows permissions for config directory | |
| if: matrix.os == 'windows-2025' | |
| run: | | |
| # Create and set permissions on config directory before any Python code runs | |
| $configDir = "$env:LOCALAPPDATA\pieces\pieces-cli" | |
| $parentDir = "$env:LOCALAPPDATA\pieces" | |
| Write-Host "Creating parent directory: $parentDir" | |
| New-Item -ItemType Directory -Force -Path $parentDir | |
| Write-Host "Creating config directory: $configDir" | |
| New-Item -ItemType Directory -Force -Path $configDir | |
| Write-Host "Setting permissions on parent directory..." | |
| icacls $parentDir /grant "${env:USERNAME}:(OI)(CI)(F)" /T | |
| if ($LASTEXITCODE -ne 0) { Write-Error "Failed to set parent permissions"; exit 1 } | |
| Write-Host "Setting permissions on config directory..." | |
| icacls $configDir /grant "${env:USERNAME}:(OI)(CI)(F)" /T | |
| if ($LASTEXITCODE -ne 0) { Write-Error "Failed to set config permissions"; exit 1 } | |
| # Test permissions by creating and deleting a test file | |
| Write-Host "Testing permissions..." | |
| $testFile = Join-Path $configDir "permission_test.json" | |
| try { | |
| '{"test": true}' | Out-File -FilePath $testFile -Encoding utf8 | |
| Remove-Item $testFile -Force | |
| Write-Host "Permission test successful" | |
| } catch { | |
| Write-Error "Permission test failed: $_" | |
| # Show current permissions for debugging | |
| icacls $configDir | |
| exit 1 | |
| } | |
| shell: powershell | |
| - name: Ignore Onboarding for the tests to work | |
| run: | | |
| poetry run python -c "from pieces.settings import Settings; Settings.user_config.skip_onboarding = True" | |
| - name: Open PiecesOS | |
| run: | | |
| poetry run pieces open | |
| - name: Run tests | |
| run: | | |
| poetry run pytest tests/ --maxfail=1 --exitfirst -v | |
| - name: Collect log directories | |
| if: always() | |
| run: | | |
| LOG_DIR=$(poetry run python -c "import os; from pieces.config.constants import PIECES_DATA_DIR; print(os.path.join(PIECES_DATA_DIR, 'logs'))") | |
| TEST_LOG_DIR=$(poetry run python -c "import os; from pieces.config.constants import PIECES_DATA_DIR; print(os.path.join(PIECES_DATA_DIR, 'test_logs'))") | |
| echo "Log directory: $LOG_DIR" | |
| echo "Test log directory: $TEST_LOG_DIR" | |
| mkdir -p artifacts/logs | |
| mkdir -p artifacts/test_logs | |
| cp -r "$LOG_DIR"/* artifacts/logs || echo "No logs found" | |
| cp -r "$TEST_LOG_DIR"/* artifacts/test_logs || echo "No test logs found" | |
| shell: bash | |
| - name: Upload logs as artifact | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pieces-cli-logs-${{ matrix.os }} | |
| path: artifacts/ |