-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
135 lines (116 loc) · 6.18 KB
/
background-tests.yml
File metadata and controls
135 lines (116 loc) · 6.18 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
name: Background Callback Tests
on:
push:
pull_request:
workflow_dispatch: # Allows manual triggering
jobs:
run-background-tests:
name: Run Background Callback Tests (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false # Don't cancel other jobs in the matrix if one fails
matrix:
python-version: ["3.9", "3.12"] # Specify Python versions to test against
# Service container for Redis
services:
redis:
image: redis:6 # You can use redis:latest or a specific version like redis:6 or redis:7
ports:
- 6379:6379
# Optional: healthcheck to ensure Redis is ready before tests start
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: 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: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip' # Cache pip dependencies
- name: Install build tools (and pin setuptools if needed)
run: |
python -m pip install --upgrade pip wheel
# IMPORTANT: If setuptools >80.0.0 causes issues, pin it here
python -m pip install "setuptools<80.0.0"
- name: Install Dash dependencies
run: |
# Mirroring how Dash installs its extras, adjust if your needs are simpler
pip install -e .[ci,testing,dev,celery,diskcache]
python -m pip install "selenium==4.32.0"
- name: Build project (JS/CSS, etc.)
run: npm run build
- name: Verify Redis connection
run: |
# Optional: A quick check that Redis is accessible. Requires redis-cli.
# sudo apt-get update && sudo apt-get install -y redis-tools # If redis-cli is not in the runner
# redis-cli -h localhost -p 6379 ping
# Alternatively, a python script:
python -c "import redis; r = redis.Redis(host='localhost', port=6379, db=0); r.ping(); print('Successfully connected to Redis!')"
- name: Run Background Callback Tests
run: |
pytest --headless --nopercyfinalize tests/background_callback -v -s