CI to wait for redis to become available #33
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
services: | |
redis: | |
image: redis | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.11 | |
- name: Copy config-example.yaml to config.yaml | |
run: cp config-example.yaml config.yaml | |
- name: Modify config.yaml for CI | |
run: | | |
sed -i 's/localhost/redis/' config.yaml | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Wait for Redis to be available | |
run: | | |
for i in {1..10}; do | |
if redis-cli -h redis ping; then | |
break | |
fi | |
echo "Waiting for Redis to be available..." | |
sleep 5 | |
done | |
- name: Run tests | |
run: | | |
python -m unittest discover tests | |
env: | |
REDIS_HOST: redis | |
REDIS_PORT: 6379 | |
VALKEY_HOST: redis |