fix(types,lint): resolve mypy errors and ruff lint issues across code… #13
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 | |
| - master | |
| - dev | |
| pull_request: | |
| branches: [ main, master, dev ] | |
| permissions: | |
| contents: write | |
| jobs: | |
| test: | |
| name: test (py${{ matrix.python-version }}, numpy${{ matrix.numpy-version }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.10', '3.11', '3.12', '3.13'] | |
| numpy-version: ['1.26.4', '2.2.0'] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Free disk space | |
| run: | | |
| sudo rm -rf /usr/local/lib/android | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf /usr/local/share/powershell | |
| sudo rm -rf /usr/local/share/chromium | |
| sudo rm -rf /usr/local/.ghcup | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install uv | |
| run: curl -LsSf https://astral.sh/uv/install.sh | sh | |
| - name: Cache uv dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/uv | |
| key: ${{ runner.os }}-uv-${{ hashFiles('**/pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-uv- | |
| - name: Create virtual environment and install dependencies | |
| env: | |
| UV_HTTP_TIMEOUT: 300 | |
| UV_CONCURRENT_DOWNLOADS: 4 | |
| run: | | |
| uv venv | |
| uv pip install -e ".[test,dev]" | |
| - name: Install specific numpy version | |
| run: | | |
| source .venv/bin/activate | |
| uv pip install "numpy==${{ matrix.numpy-version }}" | |
| - name: Run linting and code quality checks with Ruff | |
| run: | | |
| source .venv/bin/activate | |
| # Check formatting | |
| ruff format --check . | |
| # Check linting | |
| ruff check . --statistics | |
| - name: Run fast tests | |
| run: | | |
| source .venv/bin/activate | |
| pytest tests/ -v -m "not slow" --cov=dnallm --cov-report=xml --cov-report=term-missing --tb=short | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage.xml | |
| fail_ci_if_error: false | |
| - name: Run slow tests | |
| continue-on-error: true | |
| run: | | |
| source .venv/bin/activate | |
| pytest tests/ -v -m "slow" --cov=dnallm --cov-report=xml --cov-report=term-missing --tb=short --cov-append | |
| - name: Run type checking | |
| run: | | |
| source .venv/bin/activate | |
| mypy dnallm/ --show-error-codes --pretty --exclude=dnallm/tasks/metrics/ || true | |
| test-cuda: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.11'] | |
| cuda-version: ['12.1', '12.4'] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Free disk space | |
| run: | | |
| sudo rm -rf /usr/local/lib/android | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /opt/ghc | |
| sudo rm -rf /usr/local/share/powershell | |
| sudo rm -rf /usr/local/share/chromium | |
| sudo rm -rf /usr/local/.ghcup | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install CUDA dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y nvidia-cuda-toolkit | |
| - name: Install uv | |
| run: curl -LsSf https://astral.sh/uv/install.sh | sh | |
| - name: Cache uv dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/uv | |
| key: ${{ runner.os }}-uv-cuda-${{ matrix.cuda-version }}-${{ hashFiles('**/pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-uv-cuda-${{ matrix.cuda-version }}- | |
| ${{ runner.os }}-uv- | |
| - name: Create virtual environment and install CUDA dependencies | |
| env: | |
| UV_HTTP_TIMEOUT: 300 | |
| UV_CONCURRENT_DOWNLOADS: 4 | |
| run: | | |
| uv venv | |
| if [ "${{ matrix.cuda-version }}" = "12.1" ]; then | |
| uv pip install -e ".[test,dev,cuda121]" | |
| elif [ "${{ matrix.cuda-version }}" = "12.4" ]; then | |
| uv pip install -e ".[test,dev,cuda124]" | |
| fi | |
| - name: Run GPU-enabled tests | |
| run: | | |
| source .venv/bin/activate | |
| pytest tests/ -v -m "not slow" --tb=short | |
| test-mamba: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ['3.11'] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Check for GPU | |
| id: gpu-check | |
| run: | | |
| if command -v nvidia-smi &> /dev/null && nvidia-smi > /dev/null 2>&1; then | |
| echo "has_gpu=true" >> $GITHUB_OUTPUT | |
| echo "GPU detected, will run mamba tests" | |
| else | |
| echo "has_gpu=false" >> $GITHUB_OUTPUT | |
| echo "No GPU detected, skipping mamba tests" | |
| fi | |
| - name: Set up Python ${{ matrix.python-version }} | |
| if: steps.gpu-check.outputs.has_gpu == 'true' | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install uv | |
| if: steps.gpu-check.outputs.has_gpu == 'true' | |
| run: curl -LsSf https://astral.sh/uv/install.sh | sh | |
| - name: Create virtual environment and install mamba dependencies | |
| if: steps.gpu-check.outputs.has_gpu == 'true' | |
| run: | | |
| uv venv | |
| uv pip install -e ".[test,dev]" | |
| uv pip install -e ".[mamba]" --no-cache-dir --no-build-isolation | |
| - name: Run mamba-specific tests | |
| if: steps.gpu-check.outputs.has_gpu == 'true' | |
| continue-on-error: true | |
| run: | | |
| source .venv/bin/activate | |
| pytest tests/ -v -m "not slow" --tb=short | |
| - name: Upload mamba test logs on failure | |
| if: steps.gpu-check.outputs.has_gpu == 'true' && failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: mamba-test-logs-${{ matrix.python-version }} | |
| path: | | |
| pytest.log | |
| /tmp/mamba-build.log | |
| deploy: | |
| needs: [test, test-cuda, test-mamba] | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Configure Git credentials | |
| run: | | |
| git config user.name github-actions[bot] | |
| git config user.email 41898282+github-actions[bot]@users.noreply.github.com | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.11 | |
| - name: Cache mkdocs dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| key: mkdocs-material-${{ github.run_number }} | |
| path: .cache | |
| restore-keys: | | |
| mkdocs-material- | |
| - name: Install uv | |
| run: curl -LsSf https://astral.sh/uv/install.sh | sh | |
| - name: Create virtual environment and install documentation dependencies | |
| env: | |
| UV_HTTP_TIMEOUT: 120 | |
| UV_CONCURRENT_DOWNLOADS: 1 | |
| run: | | |
| uv venv | |
| uv pip install -e ".[base,docs]" | |
| - name: Deploy documentation to GitHub Pages | |
| run: | | |
| source .venv/bin/activate | |
| mkdocs gh-deploy --force |