Skip to content

style: format code with black 26.1.0 and pin version in CI #44

style: format code with black 26.1.0 and pin version in CI

style: format code with black 26.1.0 and pin version in CI #44

Workflow file for this run

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==26.1.0' 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__}')"
# Show pytest and plugin versions
echo "=== Pytest info ==="
pip show pytest pytest-xdist pytest-timeout | grep -E "Name|Version"
# Run tests - use -n auto for parallel execution
pytest tests/ -n auto --tb=short --timeout=300 -q
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