update #43
This file contains hidden or 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: Tests | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| schedule: | |
| - cron: '0 0 * * *' # Daily at midnight UTC | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| test: | |
| name: Python ${{ matrix.python-version }} on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest] | |
| python-version: ['3.8', '3.9', '3.10', '3.11'] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 # Fetch all history for version tagging | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| # Use pip cache by default to avoid poetry.lock dependency | |
| cache: 'pip' | |
| - name: Debug system info | |
| run: | | |
| echo "=== System Information ===" | |
| uname -a | |
| echo "Python version: $(python --version)" | |
| echo "pip version: $(pip --version)" | |
| echo "===========================" | |
| - name: Install system dependencies | |
| run: | | |
| echo "=== Installing system dependencies ===" | |
| sudo apt-get update | |
| sudo apt-get install -y python3-venv python3-dev | |
| echo "======================================" | |
| - name: Install Poetry | |
| run: | | |
| echo "=== Installing Poetry ===" | |
| python -m pip install --upgrade pip | |
| python -m pip install --user "poetry==1.5.1" | |
| echo "Poetry version: $(python -m poetry --version)" | |
| echo "Adding Poetry to PATH" | |
| echo "$(python -m site --user-base)/bin" >> $GITHUB_PATH | |
| echo "========================" | |
| - name: Configure Poetry | |
| run: | | |
| echo "=== Configuring Poetry ===" | |
| python -m poetry config virtualenvs.create true | |
| python -m poetry config virtualenvs.in-project true | |
| python -m poetry config --list | |
| echo "Poetry version: $(python -m poetry --version)" | |
| echo "Python executable: $(which python)" | |
| echo "==========================" | |
| - name: Install dependencies | |
| run: | | |
| set -x # Enable debug mode | |
| echo "=== Installing dependencies ===" | |
| echo "Current directory: $(pwd)" | |
| echo "Directory contents:" | |
| ls -la | |
| # First install only the project dependencies (without lock file) | |
| echo "\n=== Installing project dependencies (initial pass) ===" | |
| python -m poetry install --no-interaction --no-ansi -v --only main || \ | |
| { echo "Initial dependency installation failed"; exit 1; } | |
| # Now generate the lock file if it doesn't exist | |
| if [ ! -f poetry.lock ]; then | |
| echo "\n=== Generating poetry.lock ===" | |
| python -m poetry lock --no-update || \ | |
| { echo "Failed to generate poetry.lock"; exit 1; } | |
| fi | |
| # Install all dependencies with the lock file | |
| echo "\n=== Installing all dependencies ===" | |
| python -m poetry install --with dev,test --no-interaction --no-ansi -v || \ | |
| { echo "poetry install with dev/test failed"; exit 1; } | |
| # Verify the environment | |
| echo "\n=== Environment information ===" | |
| python -m poetry env info | |
| echo "\n=== Installed packages ===" | |
| python -m poetry show --tree || echo "Failed to show package tree" | |
| echo "\n=== Python path ===" | |
| python -c "import sys; print('\n'.join(sys.path))" | |
| echo "============================" | |
| - name: Run tests with coverage | |
| run: | | |
| poetry run pytest --cov=dialogchain --cov-report=xml | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| file: ./coverage.xml | |
| fail_ci_if_error: false | |
| - name: Run type checking | |
| run: | | |
| poetry run mypy src/dialogchain tests | |
| - name: Lint with flake8 | |
| run: | | |
| poetry run flake8 src/dialogchain tests | |
| - name: Check formatting with black | |
| run: | | |
| poetry run black --check src tests | |
| - name: Check import sorting with isort | |
| run: | | |
| poetry run isort --check-only src tests |