-
Notifications
You must be signed in to change notification settings - Fork 99
244 lines (216 loc) · 8.83 KB
/
Copy pathtest.yml
File metadata and controls
244 lines (216 loc) · 8.83 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
241
242
243
244
name: Test Suite
on:
pull_request:
push:
branches:
- main
schedule:
- cron: "0 2 * * *" # 2 AM UTC nightly
workflow_dispatch:
env:
PYTHON_VERSION: "3.11"
UV_VERSION: "0.12.3"
jobs:
service-tests:
name: Service Tests
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Run service tests
uses: ./.github/actions/run-service-tests
with:
python-version: ${{ env.PYTHON_VERSION }}
uv-version: ${{ env.UV_VERSION }}
env:
HF_HOME: ${{ github.workspace }}/hf_cache
HF_TOKEN: ${{ secrets.HF_TOKEN }}
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GCP_LOCATION: ${{ secrets.GCP_LOCATION }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }}
# The live Azure OpenAI tests gate themselves on AZURE_OPENAI_ENDPOINT,
# AZURE_OPENAI_API_KEY and OPENAI_API_VERSION: if any of the three is empty
# or unset they skip, so an absent secret disables them and re-adding it
# re-enables them with no code change. These lines stay wired up for that
# reason. (test_non_supported_dtypes is deliberately left ungated -- it
# validates dtype before any client is built and needs no network.)
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }}
AZURE_OPENAI_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_DEPLOYMENT_NAME }}
OPENAI_API_VERSION: ${{ secrets.OPENAI_API_VERSION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
LANGCACHE_WITH_ATTRIBUTES_API_KEY: ${{ secrets.LANGCACHE_WITH_ATTRIBUTES_API_KEY }}
LANGCACHE_WITH_ATTRIBUTES_CACHE_ID: ${{ secrets.LANGCACHE_WITH_ATTRIBUTES_CACHE_ID }}
LANGCACHE_WITH_ATTRIBUTES_URL: ${{ secrets.LANGCACHE_WITH_ATTRIBUTES_URL }}
LANGCACHE_NO_ATTRIBUTES_API_KEY: ${{ secrets.LANGCACHE_NO_ATTRIBUTES_API_KEY }}
LANGCACHE_NO_ATTRIBUTES_CACHE_ID: ${{ secrets.LANGCACHE_NO_ATTRIBUTES_CACHE_ID }}
LANGCACHE_NO_ATTRIBUTES_URL: ${{ secrets.LANGCACHE_NO_ATTRIBUTES_URL }}
test:
name: Python ${{ matrix.python-version }} - redis-py ${{ matrix.redis-py-version }} [${{ matrix.redis-image }}]
runs-on: ubuntu-latest
needs: service-tests
env:
HF_HOME: ${{ github.workspace }}/hf_cache
REDIS_IMAGE: ${{ matrix.redis-image }}
REDIS_PY_VERSION: ${{ matrix.redis-py-version }}
# Required: without it `uv run` re-syncs the venv to uv.lock and reverts
# the redis-py pin set below.
UV_NO_SYNC: "1"
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
redis-py-version: ["6.x", "7.x"]
redis-image: ["redis:8.2", "redis:8.4", "redis:latest"]
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Cache HuggingFace Models
uses: actions/cache@v4
with:
path: hf_cache
key: ${{ runner.os }}-hf-cache
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v10.0.0
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
python-version: ${{ matrix.python-version }} # sets UV_PYTHON
cache-dependency-glob: |
pyproject.toml
uv.lock
- name: Install dependencies
run: |
set -euo pipefail
uv sync --all-extras --frozen
# Must cover every redis-py-version matrix value; unhandled values fail.
case "$REDIS_PY_VERSION" in
"6.x") spec="redis>=6,<7" ;;
"7.x") spec="redis>=7,<8" ;;
*)
echo "::error title=Unhandled redis-py-version::Matrix value '${REDIS_PY_VERSION}' has no install rule -- add a case branch in .github/workflows/test.yml."
exit 1
;;
esac
uv pip install "$spec"
uv run python -c 'import redis; print("redis-py:", redis.__version__)'
- name: Run tests
run: |
make test
notebooks:
name: Notebook Validation
runs-on: ubuntu-latest
needs: service-tests
# Needs API-key secrets, unavailable to fork PRs. Keep in sync with
# service-tests.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
env:
HF_HOME: ${{ github.workspace }}/hf_cache
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Cache HuggingFace Models
uses: actions/cache@v4
with:
path: hf_cache
key: ${{ runner.os }}-hf-cache
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@v10.0.0
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
python-version: ${{ env.PYTHON_VERSION }} # sets UV_PYTHON
cache-dependency-glob: |
pyproject.toml
uv.lock
- name: Install dependencies
run: |
uv sync --all-extras --frozen
- name: Start Redis
run: |
set -euo pipefail
# Wait for readiness: `make test-notebooks` probes Redis for SVS
# support and silently skips 09_svs_vamana.ipynb if it can't connect.
# Probe over the same host-to-published-port path the notebooks use.
docker run -d --name redis -p 6379:6379 redis:8.4
probe() {
uv run --no-sync python -c "import redis; redis.Redis.from_url('redis://localhost:6379').ping()"
}
ready=0
for _ in $(seq 1 30); do
if probe 2>/dev/null; then
ready=1
break
fi
sleep 1
done
if [ "$ready" -ne 1 ]; then
# Unsuppressed retry: distinguishes an unreachable server from a
# broken venv or import.
echo "Final probe attempt, stderr shown:"
probe || true
echo "::error title=Redis not ready::redis:8.4 never accepted a connection on localhost:6379 after 30 attempts"
docker logs redis || true
exit 1
fi
docker exec redis redis-cli INFO server | grep redis_version
- name: Run notebooks
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }}
# The Azure cells in docs/user_guide/04_vectorizers.ipynb carry an
# unconditional `# NBVAL_SKIP`, so notebook validation skips them whether or
# not these secrets are set, and never blocks on getpass for missing
# credentials. Restoring the secrets is therefore not enough on its own --
# those markers have to be removed too. These lines stay wired up so that
# re-enabling needs no workflow change.
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }}
AZURE_OPENAI_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_DEPLOYMENT_NAME }}
OPENAI_API_VERSION: ${{ secrets.OPENAI_API_VERSION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
make test-notebooks
docs:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@v10.0.0
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
python-version: ${{ env.PYTHON_VERSION }} # sets UV_PYTHON
cache-dependency-glob: |
pyproject.toml
uv.lock
- name: Install dependencies
run: |
uv sync --group docs --frozen
- name: Build docs
run: |
make docs-build