fix: remove duplicate pytest config from pyproject.toml to avoid conf… #23
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: | |
| - development | |
| - master | |
| paths-ignore: | |
| - 'docs/**' | |
| - '*.md' | |
| - '.readthedocs*.yaml' | |
| pull_request: | |
| branches: | |
| - development | |
| - master | |
| workflow_dispatch: # Allow manual trigger | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install linting tools | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install ruff black isort | |
| - name: Run ruff | |
| run: ruff check backtrader/ | |
| - name: Check formatting with black | |
| run: black --check --line-length 100 backtrader/ | |
| - name: Check imports with isort | |
| run: isort --check-only backtrader/ | |
| test: | |
| name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| needs: lint | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Ubuntu - test all Python versions (3.8 to 3.13) | |
| - os: ubuntu-latest | |
| python-version: '3.8' | |
| - os: ubuntu-latest | |
| python-version: '3.9' | |
| - os: ubuntu-latest | |
| python-version: '3.10' | |
| - os: ubuntu-latest | |
| python-version: '3.11' | |
| - os: ubuntu-latest | |
| python-version: '3.12' | |
| - os: ubuntu-latest | |
| python-version: '3.13' | |
| # macOS - test all Python versions (3.8 to 3.13) | |
| - os: macos-latest | |
| python-version: '3.8' | |
| - os: macos-latest | |
| python-version: '3.9' | |
| - os: macos-latest | |
| python-version: '3.10' | |
| - os: macos-latest | |
| python-version: '3.11' | |
| - os: macos-latest | |
| python-version: '3.12' | |
| - os: macos-latest | |
| python-version: '3.13' | |
| # Windows - test all Python versions (3.8 to 3.13) | |
| - os: windows-latest | |
| python-version: '3.8' | |
| - os: windows-latest | |
| python-version: '3.9' | |
| - os: windows-latest | |
| python-version: '3.10' | |
| - os: windows-latest | |
| python-version: '3.11' | |
| - os: windows-latest | |
| python-version: '3.12' | |
| - os: windows-latest | |
| python-version: '3.13' | |
| steps: | |
| - name: Checkout | |
| 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 | |
| shell: bash | |
| run: | | |
| python -m pip install --upgrade pip setuptools wheel | |
| # Install from setup.py with dev extras | |
| pip install -e ".[dev]" | |
| - name: Debug environment | |
| shell: bash | |
| run: | | |
| echo "Python version:" | |
| python --version | |
| echo "Installed packages:" | |
| pip list | grep -E "pytest|numpy|pandas" | |
| echo "Test files count:" | |
| find tests -name "test_*.py" | wc -l | |
| - name: Run tests | |
| shell: bash | |
| env: | |
| PYTEST_ADDOPTS: "" | |
| run: | | |
| # Verify backtrader import | |
| python -c "import backtrader; print(f'Backtrader imported: {backtrader.__version__}')" | |
| # Run tests without parallel execution first for clearer errors | |
| pytest tests/ --tb=short --timeout=300 -p no:html -p no:benchmark -x -v 2>&1 | head -500 || true | |
| # Run full tests with parallel execution | |
| pytest tests/ -n 4 --tb=short --timeout=600 -p no:html -p no:benchmark | |
| test-summary: | |
| name: Test Summary | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: always() | |
| steps: | |
| - name: Check test results | |
| run: | | |
| if [ "${{ needs.test.result }}" == "success" ]; then | |
| echo "✅ All tests passed!" | |
| else | |
| echo "❌ Some tests failed" | |
| exit 1 | |
| fi |