CI #79
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: CI | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| schedule: | |
| # Weekly to detect dependency drift | |
| - cron: '0 0 * * 0' | |
| workflow_dispatch: | |
| jobs: | |
| test: | |
| name: Tests (Python ${{ matrix.python-version }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ['3.9', '3.10', '3.11', '3.12'] | |
| env: | |
| PYTHONHASHSEED: '0' | |
| 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 -r requirements.txt | |
| - name: Run test suite | |
| run: | | |
| pytest tests/ -v \ | |
| --cov=theory --cov=analysis --cov=simulations \ | |
| --cov-report=term-missing --cov-report=xml | |
| lint: | |
| name: Lint and type checks | |
| runs-on: ubuntu-latest | |
| env: | |
| PYTHONHASHSEED: '0' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Check formatting (Black) | |
| run: | | |
| black --check --diff theory/ analysis/ simulations/ experiments/ tests/ | |
| - name: Check import ordering (isort) | |
| run: | | |
| isort --check-only --diff theory/ analysis/ simulations/ experiments/ tests/ | |
| - name: Lint (flake8) | |
| run: | | |
| flake8 theory/ analysis/ simulations/ experiments/ tests/ --count --show-source --statistics | |
| - name: Type check (mypy) | |
| run: | | |
| mypy theory/ analysis/ --ignore-missing-imports --no-strict-optional | |
| notebooks: | |
| name: Execute notebooks | |
| runs-on: ubuntu-latest | |
| env: | |
| PYTHONHASHSEED: '0' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Execute notebooks | |
| run: | | |
| for notebook in examples/*.ipynb; do | |
| echo "Executing $notebook" | |
| jupyter nbconvert --to notebook --execute --inplace \ | |
| --ExecutePreprocessor.timeout=600 "$notebook" | |
| done | |
| reproducibility: | |
| name: Reproducibility check | |
| runs-on: ubuntu-latest | |
| env: | |
| PYTHONHASHSEED: '0' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Verify deterministic kernel output | |
| run: | | |
| python - <<'PY' | |
| import numpy as np | |
| from theory.dynamics import MemoryKernelConfig, memory_kernel | |
| np.random.seed(42) | |
| cfg = MemoryKernelConfig(kernel_type='exponential', tau_mem=1.0) | |
| K1 = memory_kernel(np.array([0, 1, 2]), cfg) | |
| np.random.seed(42) | |
| K2 = memory_kernel(np.array([0, 1, 2]), cfg) | |
| assert np.allclose(K1, K2), 'Reproducibility check failed' | |
| print('✓ Reproducibility verified') | |
| PY |