Skip to content

Commit 664e0b3

Browse files
committed
move background tests to github workflow
1 parent 9a9246c commit 664e0b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+128
-41
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Background Callback Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch: # Allows manual triggering
7+
8+
jobs:
9+
run-background-tests:
10+
name: Run Background Callback Tests (Python ${{ matrix.python-version }})
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false # Don't cancel other jobs in the matrix if one fails
14+
matrix:
15+
python-version: ["3.8", "3.12"] # Specify Python versions to test against
16+
17+
# Service container for Redis
18+
services:
19+
redis:
20+
image: redis:6 # You can use redis:latest or a specific version like redis:6 or redis:7
21+
ports:
22+
- 6379:6379
23+
# Optional: healthcheck to ensure Redis is ready before tests start
24+
options: >-
25+
--health-cmd "redis-cli ping"
26+
--health-interval 10s
27+
--health-timeout 5s
28+
--health-retries 5
29+
30+
env:
31+
# Set REDIS_URL for your application/tests
32+
# The service 'redis' will be available on localhost (or redis) at port 6379
33+
REDIS_URL: redis://localhost:6379/0
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v4
38+
39+
- name: Set up Node.js
40+
uses: actions/setup-node@v4
41+
with:
42+
node-version: '20'
43+
cache: 'npm'
44+
45+
- name: Install Node.js dependencies
46+
run: npm ci
47+
48+
- name: Set up Python ${{ matrix.python-version }}
49+
uses: actions/setup-python@v5
50+
with:
51+
python-version: ${{ matrix.python-version }}
52+
cache: 'pip' # Cache pip dependencies
53+
54+
- name: Install build tools (and pin setuptools if needed)
55+
run: |
56+
python -m pip install --upgrade pip wheel
57+
# IMPORTANT: If setuptools >80.0.0 causes issues, pin it here
58+
python -m pip install "setuptools<80.0.0"
59+
60+
- name: Install Dash dependencies
61+
run: |
62+
# Mirroring how Dash installs its extras, adjust if your needs are simpler
63+
python -m pip install --progress-bar off ".[ci,testing,dev,celery,diskcache]"
64+
65+
- name: Build project (JS/CSS, etc.)
66+
run: npm run build
67+
68+
- name: Verify Redis connection
69+
run: |
70+
# Optional: A quick check that Redis is accessible. Requires redis-cli.
71+
# sudo apt-get update && sudo apt-get install -y redis-tools # If redis-cli is not in the runner
72+
# redis-cli -h localhost -p 6379 ping
73+
# Alternatively, a python script:
74+
python -c "import redis; r = redis.Redis(host='localhost', port=6379, db=0); r.ping(); print('Successfully connected to Redis!')"
75+
76+
- name: Run Background Callback Tests
77+
run: |
78+
pytest tests/background_callback -v -s

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ignore
1010
.env
1111
.venv
1212
env/
13-
venv/
13+
venv*/
1414
ENV/
1515
env.bak/
1616
venv.bak/

tests/integration/background_callback/app1.py renamed to tests/background_callback/app1.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
import os
2+
13
from dash import Dash, Input, Output, dcc, html
24
import time
35

4-
from tests.integration.background_callback.utils import get_background_callback_manager
6+
from tests.background_callback.utils import get_background_callback_manager
7+
8+
9+
os.environ["LONG_CALLBACK_MANAGER"] = "celery"
10+
os.environ["REDIS_URL"] = "redis://localhost:6379"
11+
redis_url = os.environ["REDIS_URL"].rstrip("/")
12+
os.environ["CELERY_BROKER"] = f"{redis_url}/0"
13+
os.environ["CELERY_BACKEND"] = f"{redis_url}/1"
514

615
background_callback_manager = get_background_callback_manager()
716
handle = background_callback_manager.handle

tests/integration/background_callback/app2.py renamed to tests/background_callback/app2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import time
44

5-
from tests.integration.background_callback.utils import get_background_callback_manager
5+
from tests.background_callback.utils import get_background_callback_manager
66

77
background_callback_manager = get_background_callback_manager()
88
handle = background_callback_manager.handle

tests/integration/background_callback/app3.py renamed to tests/background_callback/app3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from dash import Dash, Input, Output, State, dcc, html
22
import time
33

4-
from tests.integration.background_callback.utils import get_background_callback_manager
4+
from tests.background_callback.utils import get_background_callback_manager
55

66
background_callback_manager = get_background_callback_manager()
77
handle = background_callback_manager.handle

tests/integration/background_callback/app4.py renamed to tests/background_callback/app4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from dash import Dash, Input, Output, State, dcc, html
22
import time
33

4-
from tests.integration.background_callback.utils import get_background_callback_manager
4+
from tests.background_callback.utils import get_background_callback_manager
55

66
bg_callback_manager = get_background_callback_manager()
77
handle = bg_callback_manager.handle

tests/integration/background_callback/app5.py renamed to tests/background_callback/app5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import time
33
from multiprocessing import Value
44

5-
from tests.integration.background_callback.utils import get_background_callback_manager
5+
from tests.background_callback.utils import get_background_callback_manager
66

77
background_callback_manager = get_background_callback_manager()
88
handle = background_callback_manager.handle

tests/integration/background_callback/app6.py renamed to tests/background_callback/app6.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import time
44
from multiprocessing import Value
55

6-
from tests.integration.background_callback.utils import get_background_callback_manager
6+
from tests.background_callback.utils import get_background_callback_manager
77

88
background_callback_manager = get_background_callback_manager()
99
handle = background_callback_manager.handle

tests/integration/background_callback/app7.py renamed to tests/background_callback/app7.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import time
44

5-
from tests.integration.background_callback.utils import get_background_callback_manager
5+
from tests.background_callback.utils import get_background_callback_manager
66

77
bg_callback_manager = get_background_callback_manager()
88
handle = bg_callback_manager.handle

0 commit comments

Comments
 (0)