-
Notifications
You must be signed in to change notification settings - Fork 0
204 lines (168 loc) · 5.24 KB
/
ci.yml
File metadata and controls
204 lines (168 loc) · 5.24 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
name: CI
on:
push:
branches: [ main, docs/* ]
pull_request:
branches: [ main ]
jobs:
test:
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e '.[dev]'
- name: Build UI
run: npm install && npm run build
- name: Start Artifacta server (Unix)
if: runner.os != 'Windows'
run: |
mkdir -p data
nohup artifacta ui --port 8000 > server.log 2>&1 &
echo $! > server.pid
# Wait for server to be ready
echo "Waiting for server to start..."
SERVER_READY=false
for i in {1..30}; do
if curl -s http://localhost:8000/health > /dev/null 2>&1; then
echo "✓ Server is ready"
SERVER_READY=true
break
fi
echo "Waiting for server... ($i/30)"
sleep 1
done
# Fail if server never started
if [ "$SERVER_READY" = "false" ]; then
echo "✗ Server failed to start after 30 seconds"
echo "Server log:"
cat server.log
exit 1
fi
- name: Start Artifacta server (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
if (-not (Test-Path data)) { New-Item -ItemType Directory -Path data }
$process = Start-Process python -ArgumentList "-m","tracking_server.cli","ui","--port","8000" -PassThru -WindowStyle Hidden
Start-Sleep -Seconds 2
# Health check with retries
$maxAttempts = 5
$attempt = 0
$success = $false
while ($attempt -lt $maxAttempts -and -not $success) {
try {
$response = Invoke-WebRequest -Uri "http://127.0.0.1:8000/health" -UseBasicParsing -TimeoutSec 2
if ($response.StatusCode -eq 200) {
$success = $true
Write-Host "Server is ready"
}
} catch {
$attempt++
if ($attempt -lt $maxAttempts) {
Start-Sleep -Seconds 3
}
}
}
if (-not $success) {
Write-Host "Server failed to start after $maxAttempts attempts"
exit 1
}
- name: Run pytest
run: pytest tests/ -v --tb=short
env:
TRACKING_SERVER_HOST: ${{ runner.os == 'Windows' && '127.0.0.1' || 'localhost' }}
- name: Stop Artifacta server (Unix)
if: always() && runner.os != 'Windows'
run: |
if [ -f server.pid ]; then
kill $(cat server.pid) || true
rm server.pid
fi
- name: Stop Artifacta server (Windows)
if: always() && runner.os == 'Windows'
shell: pwsh
run: |
Get-Process python -ErrorAction SilentlyContinue | Where-Object { $_.CommandLine -like '*tracking_server*' } | Stop-Process -Force -ErrorAction SilentlyContinue
Write-Host "Server cleanup completed"
e2e:
name: E2E Tests on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -e '.[dev]'
- name: Install Node dependencies and build UI
run: npm install && npm run build
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: Run E2E tests
run: npm run test:e2e
env:
ARTIFACTA_URL: ${{ runner.os == 'Windows' && 'http://127.0.0.1:8000' || 'http://localhost:8000' }}
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e '.[dev]'
- name: Run ruff
run: ruff check . --fix
- name: Run mypy
run: mypy --ignore-missing-imports tracking-server
build:
name: Build Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/