-
Notifications
You must be signed in to change notification settings - Fork 2
240 lines (222 loc) · 7.98 KB
/
test.yml
File metadata and controls
240 lines (222 loc) · 7.98 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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
name: Test code base
on:
pull_request:
branches:
- trunk
push:
branches:
- trunk
- release-*
tags:
- v*
workflow_dispatch:
permissions:
contents: read
jobs:
test_pip_install:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.11', '3.12', '3.13', '3.14']
name: Test pip install (Python ${{ matrix.python-version }})
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Run pip install
run: |
pip install .
pytest-unit:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.11', '3.12', '3.13', '3.14']
name: Unit tests on ${{ matrix.os }} (Python ${{ matrix.python-version }})
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install requirements
run: |
pip install ".[test]"
- name: Run unit tests
run: |
pytest -s -m "unit or not (integration or cloud or slow)" --ignore=tests/test_main.py tests/
pytest-integration:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.11', '3.12', '3.13', '3.14']
name: Integration tests on ${{ matrix.os }} (Python ${{ matrix.python-version }})
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install requirements
run: |
pip install ".[test]"
- name: Install Spice (https://install.spiceai.org) (Linux)
if: matrix.os == 'ubuntu-latest'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl https://install.spiceai.org | /bin/bash
echo "$HOME/.spice/bin" >> $GITHUB_PATH
$HOME/.spice/bin/spice install
- name: Install Spice (https://install.spiceai.org) (MacOS)
if: matrix.os == 'macos-latest'
run: |
brew install spiceai/spiceai/spice
brew install spiceai/spiceai/spiced
- name: install Spice (Windows)
if: matrix.os == 'windows-latest'
run: |
curl -L "https://install.spiceai.org/Install.ps1" -o Install.ps1 && PowerShell -ExecutionPolicy Bypass -File ./Install.ps1
- name: add Spice bin to PATH (Windows)
if: matrix.os == 'windows-latest'
run: |
Add-Content $env:GITHUB_PATH (Join-Path $HOME ".spice\bin")
shell: pwsh
- name: Init and start spice app
if: matrix.os != 'windows-latest'
run: |
spice init spice_qs
cd spice_qs
spice add spiceai/quickstart
spiced &> spice.log &
# Wait for runtime to be ready (poll /v1/ready endpoint)
for i in {1..60}; do
if curl -s http://localhost:8090/v1/ready > /dev/null 2>&1; then
echo "Spice runtime is ready"
break
fi
echo "Waiting for Spice runtime to be ready... ($i/60)"
sleep 1
done
- name: Init and start spice app (Windows)
if: matrix.os == 'windows-latest'
run: |
spice install
spice init spice_qs
cd spice_qs
spice add spiceai/quickstart
# Use spiced directly; `spice run` on Windows has a bug where it
# reinstalls the runtime and then fails to locate it.
$spiced = Join-Path $HOME ".spice\bin\spiced.exe"
if (-not (Test-Path $spiced)) {
throw "spiced not found at $spiced after `spice install`"
}
Start-Process -FilePath $spiced -RedirectStandardOutput spice.out.log -RedirectStandardError spice.err.log
# Wait for runtime to be ready (poll /v1/ready endpoint)
$timeout = 120
$elapsed = 0
$ready = $false
while ($elapsed -lt $timeout) {
try {
$response = Invoke-WebRequest -Uri "http://localhost:8090/v1/ready" -UseBasicParsing -TimeoutSec 2 -ErrorAction Stop
if ($response.StatusCode -eq 200) {
Write-Host "Spice runtime is ready"
$ready = $true
break
}
} catch {
Write-Host "Waiting for Spice runtime to be ready... ($elapsed/$timeout)"
}
Start-Sleep -Seconds 1
$elapsed++
}
if (-not $ready) {
Write-Host "=== spice stdout log ==="
if (Test-Path spice.out.log) { Get-Content spice.out.log }
Write-Host "=== spice stderr log ==="
if (Test-Path spice.err.log) { Get-Content spice.err.log }
throw "Spice runtime did not become ready within $timeout seconds"
}
shell: pwsh
- name: Running tests
env:
API_KEY: ${{ secrets.API_KEY }}
# run spice.ai cloud tests only on linux with single python version, to avoid concurrent requests
TEST_SPICE_CLOUD: 'false'
run: |
pytest -s tests/test_main.py -k "not cloud"
- name: Stop spice and check logs
working-directory: spice_qs
if: matrix.os != 'windows-latest' && always()
run: |
killall spice || true
cat spice.log
- name: Stop spice and check logs (Windows)
working-directory: spice_qs
if: matrix.os == 'windows-latest' && always()
run: |
Get-Process -Name spice -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
Get-Process -Name spiced -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
Write-Host "=== spice stdout log ==="
if (Test-Path spice.out.log) { Get-Content spice.out.log }
Write-Host "=== spice stderr log ==="
if (Test-Path spice.err.log) { Get-Content spice.err.log }
shell: pwsh
pytest-cloud:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.12']
name: Cloud tests (Python ${{ matrix.python-version }})
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install requirements
run: |
pip install ".[test,params]"
- name: Run cloud tests
env:
SPICE_API_KEY: ${{ secrets.SCP_SPICEAI_TPCH_API_KEY }}
TEST_SPICE_CLOUD: 'true'
run: |
pytest -s tests/test_main.py -k "cloud"
coverage:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.11', '3.12', '3.13', '3.14']
name: Test coverage (Python ${{ matrix.python-version }})
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install requirements
run: |
pip install ".[test]"
- name: Run coverage
run: |
pytest --cov=spicepy --cov-report=xml --cov-report=term-missing --ignore=tests/test_main.py tests/
- name: Upload coverage to Codecov
if: matrix.python-version == '3.12'
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v4.5.0
with:
files: ./coverage.xml
fail_ci_if_error: false
verbose: true