|
|
|
|
|
|
|
|
| name: Tests
|
|
|
| on:
|
| push:
|
| branches: [ main, develop ]
|
| pull_request:
|
| branches: [ main, develop ]
|
|
|
| jobs:
|
| test:
|
| runs-on: ${{ matrix.os }}
|
| strategy:
|
| matrix:
|
| os: [ubuntu-latest, windows-latest, macos-latest]
|
| python-version: ['3.8', '3.9', '3.10', '3.11']
|
|
|
| steps:
|
| - uses: actions/checkout@v3
|
|
|
| - name: Set up Python ${{ matrix.python-version }}
|
| uses: actions/setup-python@v4
|
| with:
|
| python-version: ${{ matrix.python-version }}
|
|
|
| - name: Install dependencies
|
| run: |
|
| python -m pip install --upgrade pip
|
| pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
|
| pip install -e ".[dev]"
|
|
|
| - name: Lint with flake8
|
| run: |
|
| flake8 bitlinear --count --select=E9,F63,F7,F82 --show-source --statistics
|
| flake8 bitlinear --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
|
|
| - name: Check formatting with black
|
| run: |
|
| black --check bitlinear tests
|
|
|
| - name: Type check with mypy
|
| run: |
|
| mypy bitlinear
|
| continue-on-error: true
|
|
|
| - name: Test with pytest
|
| run: |
|
| pytest tests/ -v --cov=bitlinear --cov-report=xml
|
|
|
| - name: Upload coverage to Codecov
|
| uses: codecov/codecov-action@v3
|
| with:
|
| file: ./coverage.xml
|
| flags: unittests
|
| name: codecov-${{ matrix.os }}-py${{ matrix.python-version }}
|
|
|
| build-cuda:
|
| runs-on: ubuntu-latest
|
|
|
| if: github.ref == 'refs/heads/main'
|
|
|
| steps:
|
| - uses: actions/checkout@v3
|
|
|
| - name: Set up Python
|
| uses: actions/setup-python@v4
|
| with:
|
| python-version: '3.10'
|
|
|
| - name: Install CUDA toolkit
|
| uses: Jimver/cuda-toolkit@v0.2.11
|
| with:
|
| cuda: '11.8.0'
|
|
|
| - name: Install dependencies
|
| run: |
|
| python -m pip install --upgrade pip
|
| pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118
|
| pip install -e .
|
|
|
| - name: Build CUDA extension
|
| run: |
|
| python setup.py build_ext --inplace
|
|
|
| - name: Test CUDA build
|
| run: |
|
| python -c "import bitlinear; print('CUDA build successful')"
|
|
|