Declare Python dependencies #5
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 using PyPI | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| pull_request: | |
| branches: | |
| - "main" | |
| defaults: | |
| run: | |
| shell: bash -l {0} | |
| jobs: | |
| test: | |
| name: 💻=${{ matrix.os }}, 🐍=${{ matrix.python-version }}, 🍺=${{ matrix.pint-version }}, ⚛️=${{ matrix.openmm }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [macos-latest, ubuntu-latest] | |
| openmm: ["true", "false"] | |
| python-version: ["3.11", "3.12", "3.13"] | |
| pint-version: ["0.24"] | |
| exclude: | |
| - python-version: "3.13" | |
| openmm: "true" | |
| env: | |
| PYTEST_ARGS: -v -n auto | |
| COV: --cov=openff/units --cov-report=xml --cov-append | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| run: python -m pip install \ | |
| --index-url https://test.pypi.org/simple/ \ | |
| --extra-index-url https://pypi.org/simple/ \ | |
| -e ."[test]" downstream_dummy/ | |
| - name: Optionally install OpenMM | |
| if: ${{ matrix.openmm == 'true' }} | |
| run: pip install openmm | |
| - name: Verify OpenMM is not installed when not expected | |
| if: ${{ matrix.openmm == 'false' }} | |
| run: | | |
| # If the number of packages matching "*openmm*" is greater than zero | |
| if [[ $(pip list | grep openmm | wc -l) -gt 0 ]]; then | |
| pip list; | |
| exit 1; | |
| fi | |
| - name: Run unit tests | |
| run: | | |
| if [[ ${{ matrix.openmm }} == false ]]; then | |
| PYTEST_ARGS+=" --ignore=openff/units/_tests/test_openmm.py" | |
| fi | |
| # https://github.com/openforcefield/openff-units/issues/111 | |
| python -c "from openff.units import *" | |
| python -m pytest $PYTEST_ARGS $COV openff/units/_tests/ | |
| - name: Run dummy package tests | |
| run: python -m pytest $PYTEST_ARGS downstream_dummy/tests/ | |
| - name: Run mypy | |
| if: ${{ matrix.python-version == '3.12' }} | |
| run: python -m mypy -p "openff.units" && python -m mypy downstream_dummy/ --exclude=downstream_dummy/build/ | |
| - name: Run docexamples | |
| if: ${{ matrix.openmm == 'true' }} | |
| run: pytest --doctest-modules $PYTEST_ARGS openff --ignore=openff/units/_tests | |
| - name: Check OpenMM is lazy-imported | |
| if: ${{ matrix.openmm == 'true' }} | |
| run: python -c "import sys; from openff.units import unit, Quantity; assert 'openmm' not in sys.modules" | |
| - name: Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: ./coverage.xml | |
| fail_ci_if_error: false |