|
| 1 | +name: Build and Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, master, develop ] |
| 6 | + pull_request: |
| 7 | + branches: [ main, master ] |
| 8 | + release: |
| 9 | + types: [published] |
| 10 | + |
| 11 | +jobs: |
| 12 | + test: |
| 13 | + runs-on: ${{ matrix.os }} |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + os: [ubuntu-latest] |
| 18 | + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] |
| 19 | + cuda-version: ["11.8", "12.1"] |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + submodules: recursive |
| 25 | + |
| 26 | + - name: Set up Python ${{ matrix.python-version }} |
| 27 | + uses: actions/setup-python@v4 |
| 28 | + with: |
| 29 | + python-version: ${{ matrix.python-version }} |
| 30 | + |
| 31 | + - name: Install CUDA Toolkit |
| 32 | + if: matrix.os == 'ubuntu-latest' |
| 33 | + uses: Jimver/cuda-toolkit@v0.2.11 |
| 34 | + with: |
| 35 | + cuda: ${{ matrix.cuda-version }} |
| 36 | + |
| 37 | + - name: Install system dependencies |
| 38 | + if: matrix.os == 'ubuntu-latest' |
| 39 | + run: | |
| 40 | + sudo apt-get update |
| 41 | + sudo apt-get install -y cmake build-essential ninja-build libboost-all-dev |
| 42 | + |
| 43 | + - name: Install Python dependencies |
| 44 | + run: | |
| 45 | + python -m pip install --upgrade pip |
| 46 | + pip install build wheel setuptools cmake pybind11 ninja |
| 47 | + pip install pytest pytest-cov numpy matplotlib scipy |
| 48 | +
|
| 49 | + - name: Build package (superbuild) |
| 50 | + run: | |
| 51 | + python -m build --wheel |
| 52 | + |
| 53 | + - name: Install package |
| 54 | + run: | |
| 55 | + pip install dist/*.whl |
| 56 | +
|
| 57 | + - name: Run tests |
| 58 | + run: | |
| 59 | + pytest odevis/python/tests/ -v |
| 60 | +
|
| 61 | + build-wheel: |
| 62 | + if: github.event_name == 'release' |
| 63 | + runs-on: ubuntu-latest |
| 64 | + steps: |
| 65 | + - uses: actions/checkout@v4 |
| 66 | + with: |
| 67 | + submodules: recursive |
| 68 | + |
| 69 | + - name: Set up Python |
| 70 | + uses: actions/setup-python@v4 |
| 71 | + with: |
| 72 | + python-version: "3.10" |
| 73 | + |
| 74 | + - name: Install CUDA Toolkit |
| 75 | + uses: Jimver/cuda-toolkit@v0.2.11 |
| 76 | + with: |
| 77 | + cuda: "12.1" |
| 78 | + |
| 79 | + - name: Install system dependencies |
| 80 | + run: | |
| 81 | + sudo apt-get update |
| 82 | + sudo apt-get install -y cmake build-essential ninja-build libboost-all-dev |
| 83 | +
|
| 84 | + - name: Install build dependencies |
| 85 | + run: | |
| 86 | + python -m pip install --upgrade pip |
| 87 | + pip install build twine cmake pybind11 ninja |
| 88 | +
|
| 89 | + - name: Build wheel |
| 90 | + run: | |
| 91 | + python -m build |
| 92 | +
|
| 93 | + - name: Upload to PyPI |
| 94 | + env: |
| 95 | + TWINE_USERNAME: __token__ |
| 96 | + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
| 97 | + run: | |
| 98 | + twine upload dist/* |
0 commit comments