Dev/master #142
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: Continuous Integration | |
| on: | |
| push: | |
| branches: [ master ] | |
| paths-ignore: | |
| - "docs/**" | |
| - "*.md" | |
| pull_request: | |
| branches: [ master ] | |
| paths-ignore: | |
| - "docs/**" | |
| - "*.md" | |
| jobs: | |
| test: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| # Exclude Python 3.13 on Windows due to missing wheels and build tool requirements | |
| exclude: | |
| - os: windows-latest | |
| python-version: "3.13" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install system dependencies (Ubuntu) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y pkg-config gfortran g++ | |
| # Install OpenBLAS for scipy builds (needed for Python 3.13) | |
| if [[ "${{ matrix.python-version }}" == "3.13" ]]; then | |
| sudo apt-get install -y libopenblas-dev liblapack-dev | |
| fi | |
| - name: Install system dependencies (macOS) | |
| if: matrix.os == 'macos-latest' | |
| run: | | |
| brew update | |
| brew install pkg-config | |
| # Install gcc and OpenBLAS for Python versions that need compilation | |
| if [[ "${{ matrix.python-version }}" == "3.13" ]]; then | |
| brew install gcc openblas | |
| # Add Homebrew's bin directory to PATH to ensure gcc is found | |
| echo "$(brew --prefix)/bin" >> $GITHUB_PATH | |
| fi | |
| - name: Install dependencies for tox | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install tox tox-gh-actions | |
| pip install poetry | |
| - name: Install project dependencies with retry | |
| # Use poetry install with retry logic for network issues | |
| shell: bash | |
| run: | | |
| # Try with system dependencies first, fall back to source if needed | |
| poetry config virtualenvs.create true | |
| poetry config virtualenvs.in-project false | |
| # For Python 3.13, try to install with --no-build-isolation first | |
| if [[ "${{ matrix.python-version }}" == "3.13" ]]; then | |
| # Use environment variables to help with compilation | |
| if [[ "${{ matrix.os }}" == "macos-latest" ]]; then | |
| export LDFLAGS="-L$(brew --prefix zlib)/lib" | |
| export CPPFLAGS="-I$(brew --prefix zlib)/include" | |
| fi | |
| # Try to install with system site packages enabled for system libraries | |
| poetry install --no-root --without dev --no-interaction || \ | |
| echo "First attempt failed, retrying with different options..." | |
| # Fallback: try using pip directly with pre-compiled wheels where possible | |
| python -m pip install --upgrade setuptools wheel | |
| # For problematic packages, try to get pre-compiled wheels | |
| if [[ "${{ matrix.os }}" == "macos-latest" ]]; then | |
| python -m pip install --only-binary :all: numpy scipy matplotlib || \ | |
| python -m pip install numpy scipy matplotlib --no-build-isolation | |
| fi | |
| else | |
| poetry install --no-root --without dev --no-interaction | |
| fi | |
| - name: Pre-install problematic packages for Python 3.13 (macOS) | |
| if: matrix.os == 'macos-latest' && matrix.python-version == '3.13' | |
| run: | | |
| python -m pip install --upgrade pip | |
| # Try to install matplotlib with pre-built wheels if available | |
| # If no wheels available, this will fail but we'll handle it in tox | |
| python -m pip install --only-binary :all: matplotlib || echo "No wheels available, will try source build" | |
| - name: Install dependencies for tox | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install tox tox-gh-actions | |
| pip install poetry | |
| - name: Run unit tests | |
| shell: bash | |
| env: | |
| # For Python 3.13 compilation | |
| NPY_DISTUTILS_APPEND_FLAGS: 1 | |
| # Use system site packages for Python 3.13 on macOS to reuse pre-installed matplotlib | |
| TOX_SKIP_ENV: ${{ matrix.os == 'macos-latest' && matrix.python-version == '3.13' && 'false' || 'false' }} | |
| run: | | |
| # Use tox-gh-actions to select the right tox environment | |
| # For Python 3.13 on macOS, pass --sitepackages to use system packages | |
| if [[ "${{ matrix.os }}" == "macos-latest" && "${{ matrix.python-version }}" == "3.13" ]]; then | |
| tox --sitepackages | |
| else | |
| tox | |
| fi | |
| linters: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.10" | |
| - name: Install dependencies for linters | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install tox tox-gh-actions | |
| pip install poetry | |
| poetry install --no-root | |
| - name: Run linters (mypy, codespell, docs) | |
| run: | | |
| tox |