Skip to content

Merge pull request #6 from mukul975/dependabot/github_actions/actions… #7

Merge pull request #6 from mukul975/dependabot/github_actions/actions…

Merge pull request #6 from mukul975/dependabot/github_actions/actions… #7

Workflow file for this run

name: CI
on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]
env:
PYTHON_VERSION_DEFAULT: '3.11'
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
exclude:
# Reduce matrix size by excluding some combinations
- os: windows-latest
python-version: '3.8'
- os: macos-latest
python-version: '3.8'
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: testpassword
MYSQL_DATABASE: testdb
MYSQL_USER: testuser
MYSQL_PASSWORD: testpass
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov pytest-mock pytest-asyncio
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
shell: bash
- name: Wait for MySQL to be ready
if: matrix.os == 'ubuntu-latest'
run: |
for i in {1..30}; do
if mysqladmin ping -h127.0.0.1 -P3306 -uroot -ptestpassword --silent; then
break
fi
echo "Waiting for MySQL..."
sleep 2
done
- name: Test with pytest
run: |
pytest -v --cov=. --cov-report=xml --cov-report=term-missing
env:
MYSQL_HOST: localhost
MYSQL_PORT: 3306
MYSQL_USER: testuser
MYSQL_PASSWORD: testpass
MYSQL_DATABASE: testdb
- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.python-version == env.PYTHON_VERSION_DEFAULT
uses: codecov/codecov-action@v5
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black isort flake8 mypy pylint
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Run linting
run: |
black --check --diff .
isort --check-only --diff .
flake8 .
mypy . --ignore-missing-imports
integration-test:
runs-on: ubuntu-latest
needs: [test, lint]
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: integration_test
MYSQL_USER: testuser
MYSQL_PASSWORD: testpass
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION_DEFAULT }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-asyncio
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Wait for MySQL
run: |
for i in {1..60}; do
if mysqladmin ping -h127.0.0.1 -P3306 -uroot -prootpassword --silent; then
echo "MySQL is ready!"
break
fi
echo "Waiting for MySQL... ($i/60)"
sleep 2
done
- name: Set up test database
run: |
mysql -h127.0.0.1 -P3306 -uroot -prootpassword -e "CREATE DATABASE IF NOT EXISTS integration_test;"
mysql -h127.0.0.1 -P3306 -uroot -prootpassword -e "SHOW DATABASES;"
- name: Run integration tests
run: |
if [ -d "tests/integration" ]; then
pytest tests/integration/ -v
else
echo "No integration tests found, skipping"
fi
env:
MYSQL_HOST: localhost
MYSQL_PORT: 3306
MYSQL_USER: root
MYSQL_PASSWORD: rootpassword
MYSQL_DATABASE: integration_test