-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
435 lines (374 loc) · 16.5 KB
/
testing.yml
File metadata and controls
435 lines (374 loc) · 16.5 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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
name: Dash Testing
on:
push:
branches:
- dev
- master
pull_request:
workflow_dispatch:
jobs:
changes_filter:
name: Detect Relevant Path Changes
runs-on: ubuntu-latest
outputs:
# This output will be 'true' if files in the 'table_related_paths' list changed, 'false' otherwise.
table_paths_changed: ${{ steps.filter.outputs.table_related_paths }}
background_cb_changed: ${{ steps.filter.outputs.background_paths }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Detect changed files for table tests
id: filter # Give an ID to this step to reference its outputs
uses: dorny/paths-filter@v3
with:
filters: |
table_related_paths:
- 'components/dash-table/**'
- 'dash/dash-renderer/**'
background_paths:
- 'dash/background_callback/**'
- 'dash/dash-renderer/**'
- 'dash/_callback.py'
- 'dash/_callback_context.py'
- 'tests/background_callback/**'
- 'tests/async_tests/**'
- 'requirements/**'
build:
name: Build Dash Package
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
artifact_name: dash-packages
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js for frontend build
uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
- name: Install NPM dependencies
run: npm ci
- name: Set up Python for build
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
python -m pip install "setuptools<80.0.0"
python -m pip install build wheel
python -m pip install -e .[dev,ci]
- name: Build Dash
run: npm run build
- name: Build Dash sdist and wheel
run: |
# This command will invoke hatchling (via hatch_dash.py) which includes building JS assets
python -m build --sdist --wheel
echo "Built packages:"
ls -lhR dist/
mkdir packages
cp dist/*.whl packages
- name: Upload Dash packages as artifact
uses: actions/upload-artifact@v4
with:
name: dash-packages # This name will be used by dependent jobs to download
path: packages/ # Upload the contents of the dist directory
retention-days: 1 # Keep artifact for 1 day (adjust as needed)
test-typing:
name: Typing Tests
runs-on: ubuntu-latest
needs: build
timeout-minutes: 30
strategy:
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install Node.js dependencies
run: npm ci
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Download built Dash packages
uses: actions/download-artifact@v4
with:
name: dash-packages
path: packages/
- name: Install Dash packages
run: |
python -m pip install --upgrade pip wheel
python -m pip install "setuptools<80.0.0"
find packages -name dash-*.whl -print -exec sh -c 'pip install "{}[ci,testing,dev]"' \;
- name: Build/Setup test components
run: npm run setup-tests.py # TODO build the packages and save them to packages/ in build job
- name: Run typing tests
run: |
pytest tests/compliance/test_typing.py
background-callbacks:
name: Run Background & Async Callback Tests (Python ${{ matrix.python-version }})
needs: [build, changes_filter]
if: |
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev')) ||
needs.changes_filter.outputs.background_cb_changed == 'true'
timeout-minutes: 30
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.12"]
# Service container for Redis
services:
redis:
image: redis:6
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
# Set REDIS_URL for your application/tests
# The service 'redis' will be available on localhost (or redis) at port 6379
REDIS_URL: redis://localhost:6379
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install Node.js dependencies
run: npm ci
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Download built Dash packages
uses: actions/download-artifact@v4
with:
name: dash-packages
path: packages/
- name: Install Dash packages
run: |
python -m pip install --upgrade pip wheel
python -m pip install "setuptools<78.0.0"
python -m pip install "selenium==4.32.0"
find packages -name dash-*.whl -print -exec sh -c 'pip install "{}[async,ci,testing,dev,celery,diskcache]"' \;
- name: Install Google Chrome
run: |
sudo apt-get update
# Attempt to install a specific recent, stable version or just google-chrome-stable
# For more deterministic builds, you might consider a specific version if available via apt,
# or using a Docker image with Chrome pre-installed if extreme consistency is needed.
sudo apt-get install -y google-chrome-stable
- name: Install ChromeDriver
run: |
echo "Determining Chrome version..."
CHROME_BROWSER_VERSION=$(google-chrome --version)
echo "Installed Chrome Browser version: $CHROME_BROWSER_VERSION"
# Extract the major version number (e.g., 124 from "Google Chrome 124.0.6367.207")
CHROME_MAJOR_VERSION=$(echo "$CHROME_BROWSER_VERSION" | cut -f 3 -d ' ' | cut -f 1 -d '.')
echo "Detected Chrome Major version: $CHROME_MAJOR_VERSION"
# For Chrome 115 and later, use the new Chrome for Testing (CfT) JSON endpoints
if [ "$CHROME_MAJOR_VERSION" -ge 115 ]; then
echo "Fetching ChromeDriver version for Chrome $CHROME_MAJOR_VERSION using CfT endpoint..."
# Get the latest known good version of chromedriver for this major Chrome version
CHROMEDRIVER_VERSION_STRING=$(curl -sS "https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_${CHROME_MAJOR_VERSION}")
if [ -z "$CHROMEDRIVER_VERSION_STRING" ]; then
echo "Could not automatically find ChromeDriver version for Chrome $CHROME_MAJOR_VERSION via LATEST_RELEASE. Please check CfT endpoints."
# As a fallback, attempt to fetch the known good versions and pick the latest chromedriver.
# This is more complex and might require parsing JSON with jq.
# For simplicity, we'll rely on LATEST_RELEASE_ for now.
# If that fails consistently, you might need a more robust script or a fixed ChromeDriver version.
# Alternative: List all known good versions
# curl -sS "https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json"
exit 1
fi
CHROMEDRIVER_URL="https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/${CHROMEDRIVER_VERSION_STRING}/linux64/chromedriver-linux64.zip"
else
# For older Chrome versions (less common now)
echo "Fetching ChromeDriver version for Chrome $CHROME_MAJOR_VERSION using older method..."
CHROMEDRIVER_VERSION_STRING=$(curl -sS "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_MAJOR_VERSION}")
CHROMEDRIVER_URL="https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION_STRING}/chromedriver_linux64.zip"
fi
echo "Using ChromeDriver version string: $CHROMEDRIVER_VERSION_STRING"
echo "Downloading ChromeDriver from: $CHROMEDRIVER_URL"
wget -q -O chromedriver.zip "$CHROMEDRIVER_URL"
unzip -o chromedriver.zip -d /tmp/ # Unzip to /tmp
# The zip for CfT often contains a directory like chromedriver-linux64/
sudo mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver || sudo mv /tmp/chromedriver /usr/local/bin/chromedriver
sudo chmod +x /usr/local/bin/chromedriver
# Add /usr/local/bin to GITHUB_PATH to ensure chromedriver is found
echo "/usr/local/bin" >> $GITHUB_PATH
shell: bash
- name: Verify Redis connection
run: |
python -c "import redis; r = redis.Redis(host='localhost', port=6379, db=0); r.ping(); print('Successfully connected to Redis!')"
- name: Build/Setup test components
run: npm run setup-tests.py
- name: Run Background & Async Callback Tests
run: |
mkdir bgtests
cp -r tests bgtests/tests
cd bgtests
touch __init__.py
pytest --headless --nopercyfinalize tests/background_callback -v -s
- name: Run Async Callback Tests
run: |
cd bgtests
pytest --headless --nopercyfinalize tests/async_tests -v -s
table-unit:
name: Table Unit/Lint Tests (Python ${{ matrix.python-version }})
needs: [build, changes_filter]
if: |
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev')) ||
needs.changes_filter.outputs.table_paths_changed == 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
python-version: ["3.12"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install Node.js dependencies
run: npm ci
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Download built Dash packages
uses: actions/download-artifact@v4
with:
name: dash-packages # Must match the name used in the 'build' job's upload step
path: packages/ # Download to a local 'dist' directory
- name: Install Dash packages
run: |
python -m pip install --upgrade pip wheel
python -m pip install "setuptools<80.0.0"
find packages -name dash-*.whl -print -exec sh -c 'pip install "{}[ci,testing,dev]"' \;
- name: Lint
run: |
cd components/dash-table
npm ci
npm run lint
- name: Unit
run: |
cd components/dash-table
npm run test.unit
table-server:
name: Table Server Tests (Group ${{ matrix.test-group }})
needs: [build, changes_filter]
# Conditional execution:
# OR if the 'changes_filter' job detected changes in 'table_related_paths'.
if: |
(github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev')) ||
needs.changes_filter.outputs.table_paths_changed == 'true'
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
python-version: ["3.12"]
test-group: ["1", "2", "3"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install Node.js dependencies
run: npm ci
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Download built Dash packages
uses: actions/download-artifact@v4
with:
name: dash-packages
path: packages/
- name: Install Dash packages
run: |
python -m pip install --upgrade pip wheel
python -m pip install "setuptools<80.0.0"
find packages -name dash-*.whl -print -exec sh -c 'pip install "{}[ci,testing,dev]"' \;
pip install pytest-split
- name: Install Google Chrome
run: |
sudo apt-get update
# Attempt to install a specific recent, stable version or just google-chrome-stable
# For more deterministic builds, you might consider a specific version if available via apt,
# or using a Docker image with Chrome pre-installed if extreme consistency is needed.
sudo apt-get install -y google-chrome-stable
- name: Install ChromeDriver
run: |
echo "Determining Chrome version..."
CHROME_BROWSER_VERSION=$(google-chrome --version)
echo "Installed Chrome Browser version: $CHROME_BROWSER_VERSION"
# Extract the major version number (e.g., 124 from "Google Chrome 124.0.6367.207")
CHROME_MAJOR_VERSION=$(echo "$CHROME_BROWSER_VERSION" | cut -f 3 -d ' ' | cut -f 1 -d '.')
echo "Detected Chrome Major version: $CHROME_MAJOR_VERSION"
# For Chrome 115 and later, use the new Chrome for Testing (CfT) JSON endpoints
if [ "$CHROME_MAJOR_VERSION" -ge 115 ]; then
echo "Fetching ChromeDriver version for Chrome $CHROME_MAJOR_VERSION using CfT endpoint..."
# Get the latest known good version of chromedriver for this major Chrome version
CHROMEDRIVER_VERSION_STRING=$(curl -sS "https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_${CHROME_MAJOR_VERSION}")
if [ -z "$CHROMEDRIVER_VERSION_STRING" ]; then
echo "Could not automatically find ChromeDriver version for Chrome $CHROME_MAJOR_VERSION via LATEST_RELEASE. Please check CfT endpoints."
# As a fallback, attempt to fetch the known good versions and pick the latest chromedriver.
# This is more complex and might require parsing JSON with jq.
# For simplicity, we'll rely on LATEST_RELEASE_ for now.
# If that fails consistently, you might need a more robust script or a fixed ChromeDriver version.
# Alternative: List all known good versions
# curl -sS "https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json"
exit 1
fi
CHROMEDRIVER_URL="https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/${CHROMEDRIVER_VERSION_STRING}/linux64/chromedriver-linux64.zip"
else
# For older Chrome versions (less common now)
echo "Fetching ChromeDriver version for Chrome $CHROME_MAJOR_VERSION using older method..."
CHROMEDRIVER_VERSION_STRING=$(curl -sS "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_MAJOR_VERSION}")
CHROMEDRIVER_URL="https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION_STRING}/chromedriver_linux64.zip"
fi
echo "Using ChromeDriver version string: $CHROMEDRIVER_VERSION_STRING"
echo "Downloading ChromeDriver from: $CHROMEDRIVER_URL"
wget -q -O chromedriver.zip "$CHROMEDRIVER_URL"
unzip -o chromedriver.zip -d /tmp/ # Unzip to /tmp
# The zip for CfT often contains a directory like chromedriver-linux64/
sudo mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver || sudo mv /tmp/chromedriver /usr/local/bin/chromedriver
sudo chmod +x /usr/local/bin/chromedriver
# Add /usr/local/bin to GITHUB_PATH to ensure chromedriver is found
echo "/usr/local/bin" >> $GITHUB_PATH
shell: bash
- name: Verify ChromeDriver Installation
run: |
chromedriver --version
- name: Run Table Server Tests
run: |
cd components/dash-table
pytest --nopercyfinalize --headless --splits 3 --group ${{ matrix.test-group }}