Skip to content

Commit

Permalink
Use bundled package in deployment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwthompson committed Feb 15, 2024
1 parent 5ffcb58 commit 2470ca9
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 209 deletions.
11 changes: 1 addition & 10 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
name: CI

on:
push:
branches:
- "main"
- "maintenance/.*"
pull_request:
branches:
- "main"
- "maintenance/.*"
schedule:
# Nightly tests run on main by default:
# Scheduled workflows run on the latest commit on the default or base branch.
Expand Down Expand Up @@ -41,7 +33,6 @@ jobs:

env:
OE_LICENSE: ${{ github.workspace }}/oe_license.txt
PACKAGE: openff
PYTEST_ARGS: -r fE --tb=short -nauto
COV: --cov=openff/toolkit --cov-config=setup.cfg --cov-append --cov-report=xml

Expand Down Expand Up @@ -151,7 +142,7 @@ jobs:
PYTEST_ARGS+=" --ignore=openff/toolkit/_tests/test_examples.py"
PYTEST_ARGS+=" --ignore=openff/toolkit/_tests/test_links.py"
if [[ "$GITHUB_EVENT_NAME" == "schedule" ]]; then
PYTEST_ARGS+=" --runslow"
PYTEST_ARGS+=" -m 'slow or not slow'"
fi
python -m pytest $PYTEST_ARGS $COV
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/beta_rc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
run: |
PYTEST_ARGS+=" --ignore=openff/toolkit/_tests/test_examples.py"
PYTEST_ARGS+=" --ignore=openff/toolkit/_tests/test_links.py"
PYTEST_ARGS+=" --runslow"
PYTEST_ARGS+=" -m 'slow or not slow'"
pytest $PYTEST_ARGS $COV
- name: Run code snippets in docs
Expand Down
62 changes: 25 additions & 37 deletions .github/workflows/conda.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Conda latest

on:
push:
release:
types:
- released
Expand All @@ -20,59 +21,46 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.9", "3.10"]
os: [ubuntu-latest]
python-version: ["3.11"]
openeye: ["true", "false"]

env:
CI_OS: ${{ matrix.os }}
OPENEYE: ${{ matrix.openeye }}
PYVER: ${{ matrix.python-version }}
OE_LICENSE: ${{ github.workspace }}/oe_license.txt
PACKAGE: openff-toolkit
PYTEST_ARGS: -r fE --tb=short -n logical --durations=20

steps:
- uses: actions/checkout@v4

- name: Vanilla install from conda
uses: mamba-org/setup-micromamba@v1
if: ${{ matrix.openeye == 'false' }}
with:
environment-file: devtools/conda-envs/conda.yaml
create-args: >-
python=${{ matrix.python-version }}
- name: Install from conda with OpenEye
uses: mamba-org/setup-micromamba@v1
if: ${{ matrix.openeye == 'true' }}
with:
environment-file: devtools/conda-envs/conda_oe.yaml
environment-name: latest-deployment
create-args: >-
python=${{ matrix.python-version }}
openff-toolkit-examples
smirnoff-plugins=2024
pytest-xdist
pytest-rerunfailures
- name: Additional info about the build
run: |
uname -a
df -h
ulimit -a
- name: Install OpenEye Toolkits
if: ${{ matrix.openeye == 'true' }}
run: micromamba install openeye-toolkits -c openeye

- name: Make oe_license.txt file from GH org secret "OE_LICENSE"
if: ${{ matrix.openeye == 'true' }}
env:
OE_LICENSE_TEXT: ${{ secrets.OE_LICENSE }}
run: |
echo "${OE_LICENSE_TEXT}" > ${OE_LICENSE}
- name: Environment Information
run: |
conda info
conda list
run: micromamba info && micromamba list

- name: Check installed toolkits
run: |
# Checkout the state of the repo as of the last release (including RCs)
export LATEST_TAG=$(git ls-remote --tags https://github.com/openforcefield/openff-toolkit.git | cut -f2 | grep -E "([0-9]+)\.([0-9]+)\.([0-9]+)$" | sort --version-sort | tail -1 | sed 's/refs\/tags\///')
git fetch --tags
git checkout tags/$LATEST_TAG
git log -1 | cat
if [[ "$OPENEYE" == true ]]; then
python -c "from openff.toolkit.utils.toolkits import OPENEYE_AVAILABLE; assert OPENEYE_AVAILABLE, 'OpenEye unavailable'"
Expand All @@ -86,9 +74,6 @@ jobs:
- name: Check that correct OFFTK version was installed
run: |
# Go up one directory to ensure that we don't just load the OFFTK from the checked-out repo
cd ../
export LATEST_TAG=$(git ls-remote --tags https://github.com/openforcefield/openff-toolkit.git | cut -f2 | grep -E "([0-9]+)\.([0-9]+)\.([0-9]+)$" | sort --version-sort | tail -1 | sed 's/refs\/tags\///')
export FOUND_VER=$(python -c "import openff.toolkit; print(openff.toolkit.__version__)")
Expand All @@ -102,20 +87,23 @@ jobs:
exit 1
fi
cd openff-toolkit
- name: Test the package
run: |
python -m pip install utilities/test_plugins
pwd
ls
# Act like we're testing with this patch deployed ...
python -m pip install . utilities/test_plugins/
if [[ "$OPENEYE" == true ]]; then
python -c "import openff.toolkit; print(openff.toolkit.__file__)"
python -c "import openeye; print(openeye.oechem.OEChemIsLicensed())"
fi
PYTEST_ARGS=" -r fE --tb=short --runslow openff/toolkit/_tests/conftest.py"
PYTEST_ARGS+=" --ignore=openff/toolkit/_tests/test_links.py"
pytest $PYTEST_ARGS openff
PYTEST_ARGS+=" --ignore-glob='*_links.py'"
PYTEST_ARGS+=" --ignore-glob='*_examples.py'"
PYTEST_ARGS+=" --ignore-glob='*_nagl.py'"
env
python -m pytest $PYTEST_ARGS \
--pyargs "openff.toolkit" \
-m "slow or not slow"
30 changes: 6 additions & 24 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
name: Examples

on:
push:
branches:
- "main"
- "maintenance/.+"
pull_request:
branches:
- "main"
- "maintenance/.+"
schedule:
- cron: "0 0 * * *"

Expand Down Expand Up @@ -66,24 +58,13 @@ jobs:
create-args: >-
python=${{ matrix.python-version }}
- name: Additional info about the build
run: |
uname -a
df -h
ulimit -a
- name: Make oe_license.txt file from GH org secret "OE_LICENSE"
env:
OE_LICENSE_TEXT: ${{ secrets.OE_LICENSE }}
run: |
echo "${OE_LICENSE_TEXT}" > ${OE_LICENSE}
run: echo "${OE_LICENSE_TEXT}" > ${OE_LICENSE}

- name: Install package
run: |
# Maybe remove the packaged openff-toolkit, installed as a dependency of openmmforcefields
# and/or Interchange
micromamba remove --force openff-toolkit-base
python -m pip install .
run: python -m pip install .

- name: Remove undesired toolkits
run: |
Expand All @@ -92,7 +73,7 @@ jobs:
# so don't remove it.
if [ ! -z "${{ env.PACKAGES_TO_REMOVE }}" ]; then
for cpkg in ${{ env.PACKAGES_TO_REMOVE }}; do
if [[ $(conda list | grep $cpkg) ]]; then micromamba remove --force $cpkg --yes ; fi
if [[ $(micromamba list | grep $cpkg) ]]; then micromamba remove --force $cpkg --yes ; fi
done
fi
Expand All @@ -119,10 +100,11 @@ jobs:
python -c "from openff.toolkit.utils.toolkits import ${TK}_AVAILABLE; assert not ${TK}_AVAILABLE, '${TK} available'"
done
fi
- name: Environment Information
run: |
conda info
conda list
micromamba info
micromamba list
- name: Run example scripts
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: lint

on:
push:
release:

jobs:

Expand Down
9 changes: 0 additions & 9 deletions devtools/conda-envs/conda.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions devtools/conda-envs/conda_oe.yaml

This file was deleted.

94 changes: 0 additions & 94 deletions openff/toolkit/_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
"""
Configuration file for pytest.
This adds the following command line options.
- runslow: Run tests marked as slow (default is False).
"""

import logging

import pytest

logger = logging.getLogger(__name__)

# Ensure QCPortal is imported before any OpenEye modules, see
Expand All @@ -20,16 +14,6 @@
pass


def pytest_configure(config):
"""
Initialization hook to register custom markers without a pytest.ini
More info: https://docs.pytest.org/en/latest/reference.html#initialization-hooks
"""
config.addinivalue_line(
"markers", "slow: marks tests as slow (deselect with `-m 'not slow'`)"
)


def untar_full_alkethoh_and_freesolv_set():
"""When running slow tests, we unpack the full AlkEthOH and FreeSolv test
sets in advance to speed things up.
Expand All @@ -48,81 +32,3 @@ def untar_full_alkethoh_and_freesolv_set():
tarfile_path = os.path.join(molecule_dir_path, tarfile_name)
with tarfile.open(tarfile_path, "r:gz") as tar:
tar.extractall(path=molecule_dir_path)


def pytest_addoption(parser):
"""Add the pytest command line option --runslow and --failwip.
If --runslow is not given, tests marked with pytest.mark.slow are
skipped.
If --failwip is not given, tests marked with pytest.mark.wip are
xfailed.
Parameters
----------
parser : argparsing.parser
The parser used by pytest to process arguments
Returns
-------
None
"""

# Loaded pytest plugins define their own arguments, and in certain cases
# our options use the same name. Although this can define two different
# behaviors for the same argument, the two options below are fairly
# unambiguous in their interpretation, so we skip any errors and allow
# the testing to proceed

try:
parser.addoption(
"--runslow", action="store_true", default=False, help="run slow tests"
)
except ValueError:
logger.warning(
"Option --runslow already added elsewhere (from a plugin possibly?). Skipping..."
)

try:
parser.addoption(
"--failwip",
action="store_true",
default=False,
help="fail work in progress tests",
)
except ValueError:
logger.warning(
"Option --failwip already added elsewhere (from a plugin possibly?). Skipping..."
)


def pytest_collection_modifyitems(config, items):
if config.getoption("runslow"):
# If --runslow is given, we don't have to mark items for skipping,
# but we need to extract the whole AlkEthOH and FreeSolv sets (see
# test_forcefield::test_alkethoh/freesolv_parameters_assignment).
untar_full_alkethoh_and_freesolv_set()
else:
# Mark for skipping all items marked as slow.
skip_slow = pytest.mark.skip(
reason="specify --runslow pytest option to run this test."
)
for item in items:
if "slow" in item.keywords:
item.add_marker(skip_slow)

# Mark work-in-progress tests for xfail.
if not config.getoption("failwip"):
xfail_wip_reason = (
"This is a work in progress test. Specify "
"--failwip pytest option to make this test fail."
)
for item in items:
if "wip" in item.keywords:
# Augment original reason.
reason = xfail_wip_reason + item.get_closest_marker("wip").kwargs.get(
"reason", ""
)
item.add_marker(pytest.mark.xfail(reason=reason))
Loading

0 comments on commit 2470ca9

Please sign in to comment.