-
Notifications
You must be signed in to change notification settings - Fork 38
167 lines (138 loc) · 5.79 KB
/
run_tests.yaml
File metadata and controls
167 lines (138 loc) · 5.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
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/