diff --git a/.github/workflows/QCSchema.yml b/.github/workflows/QCSchema.yml new file mode 100644 index 0000000..c18310c --- /dev/null +++ b/.github/workflows/QCSchema.yml @@ -0,0 +1,86 @@ +--- +name: QCSchema + +# yamllint disable-line rule:truthy +on: [push, pull_request] + +jobs: + test: + name: Test on Python ${{ matrix.python-version }} using ${{ matrix.env-type.env-type-name }} + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8, 3.9] + # yamllint disable rule:braces + env-type: + - { env-type-name: venv, shell: bash } + - { env-type-name: conda, shell: 'bash -l {0}' } + # yamllint enable rule:braces + defaults: + run: + shell: ${{ matrix.env-type.shell }} + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + if: ${{ matrix.env-type.env-type-name == 'venv' }} + - name: Set up Python ${{ matrix.python-version }} with conda + uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: test + auto-activate-base: false + auto-update-conda: true + miniforge-version: latest + python-version: ${{ matrix.python-version }} + if: ${{ matrix.env-type.env-type-name == 'conda' }} + - name: Print Python information + run: | + command -v python + $(command -v python) --version + - name: Update pip and setuptools + run: python -m pip install -U pip setuptools + - name: Print pip config + run: python -m pip config list + - name: Install test dependencies + run: python -m pip install pytest-cov + - name: Install package + run: python -m pip install . + - name: Print installed package contents + run: | + cd ~ + PACKAGE_INSTALL_DIR=$(python -c 'import qcschema as _; print(_.__path__[0])') + echo "${PACKAGE_INSTALL_DIR}" + find $PACKAGE_INSTALL_DIR -type f | sort + - name: Print Python environment + run: python -m pip list + - name: Print conda environment + run: conda list + if: ${{ matrix.env-type.env-type-name == 'conda' }} + - name: Print conda info + run: conda info + if: ${{ matrix.env-type.env-type-name == 'conda' }} + - name: Print conda config + run: conda config --show + if: ${{ matrix.env-type.env-type-name == 'conda' }} + - name: Run tests + run: | + # Testing the installed package requires moving out of the source + # directory. There are problems with the pytest cache when trying + # to run from a non-writable dir. + cd ~ + PACKAGE_INSTALL_DIR=$(python -c 'import qcschema as _; print(_.__path__[0])') + echo "${PACKAGE_INSTALL_DIR}" + python -m pytest -v --cov=qcschema --cov-report=xml ${PACKAGE_INSTALL_DIR} + # - name: Install docs dependencies + # run: | + # python -m pip install sphinx==1.2.3 sphinxcontrib-napoleon sphinx_rtd_theme numpydoc + # - name: Make docs + # run: make docs + # - name: CodeCov + # users: codecov/codecov-action@v1 + # with: + # file: ./coverage.xml + # flags: unittests + # name: codecov-py${{ matrix.python-version }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6f93b17..0000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -# After changing this file, check it on: -# http://lint.travis-ci.org/ -language: python - -# Run jobs on container-based infrastructure, can be overridden per job -sudo: false - -matrix: - include: - - python: 2.7 - - python: 3.5 - -before_install: - - uname -a - - free -m - - df -h - - ulimit -a - - python -V - - pip install --upgrade pip setuptools - - pip install pytest jsonschema - - pip install -e . - -script: - - make test - -after_success: - - make docs - -notifications: - email: false diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..5c987a2 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include qcschema *.json +recursive-include qcschema *.schema diff --git a/qcschema/data/v2/__init__.py b/qcschema/data/v2/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/qcschema/tests/__init__.py b/qcschema/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/basis/waterZr_energy_B3LYP_STO3G_DEF2_input.json b/qcschema/tests/basis/waterZr_energy_B3LYP_STO3G_DEF2_input.json similarity index 100% rename from tests/basis/waterZr_energy_B3LYP_STO3G_DEF2_input.json rename to qcschema/tests/basis/waterZr_energy_B3LYP_STO3G_DEF2_input.json diff --git a/tests/basis/water_energy_B3LYP_631G_input.json b/qcschema/tests/basis/water_energy_B3LYP_631G_input.json similarity index 100% rename from tests/basis/water_energy_B3LYP_631G_input.json rename to qcschema/tests/basis/water_energy_B3LYP_631G_input.json diff --git a/tests/input_failures/missing_molecule_symbols.json b/qcschema/tests/input_failures/missing_molecule_symbols.json similarity index 100% rename from tests/input_failures/missing_molecule_symbols.json rename to qcschema/tests/input_failures/missing_molecule_symbols.json diff --git a/tests/input_failures/multiplicity_float.json b/qcschema/tests/input_failures/multiplicity_float.json similarity index 100% rename from tests/input_failures/multiplicity_float.json rename to qcschema/tests/input_failures/multiplicity_float.json diff --git a/tests/output_failures/dipole_wrong_type.json b/qcschema/tests/output_failures/dipole_wrong_type.json similarity index 100% rename from tests/output_failures/dipole_wrong_type.json rename to qcschema/tests/output_failures/dipole_wrong_type.json diff --git a/tests/output_failures/unknown_property.json b/qcschema/tests/output_failures/unknown_property.json similarity index 100% rename from tests/output_failures/unknown_property.json rename to qcschema/tests/output_failures/unknown_property.json diff --git a/tests/output_failures/wavefunction_basis_name.json b/qcschema/tests/output_failures/wavefunction_basis_name.json similarity index 100% rename from tests/output_failures/wavefunction_basis_name.json rename to qcschema/tests/output_failures/wavefunction_basis_name.json diff --git a/tests/output_failures/wavefunction_missing_basis.json b/qcschema/tests/output_failures/wavefunction_missing_basis.json similarity index 100% rename from tests/output_failures/wavefunction_missing_basis.json rename to qcschema/tests/output_failures/wavefunction_missing_basis.json diff --git a/tests/simple/he2_energy_VV10_input.json b/qcschema/tests/simple/he2_energy_VV10_input.json similarity index 100% rename from tests/simple/he2_energy_VV10_input.json rename to qcschema/tests/simple/he2_energy_VV10_input.json diff --git a/tests/simple/he2_energy_VV10_output.json b/qcschema/tests/simple/he2_energy_VV10_output.json similarity index 100% rename from tests/simple/he2_energy_VV10_output.json rename to qcschema/tests/simple/he2_energy_VV10_output.json diff --git a/tests/simple/water_energy_B3LYP_input.json b/qcschema/tests/simple/water_energy_B3LYP_input.json similarity index 100% rename from tests/simple/water_energy_B3LYP_input.json rename to qcschema/tests/simple/water_energy_B3LYP_input.json diff --git a/tests/simple/water_energy_B3LYP_output.json b/qcschema/tests/simple/water_energy_B3LYP_output.json similarity index 100% rename from tests/simple/water_energy_B3LYP_output.json rename to qcschema/tests/simple/water_energy_B3LYP_output.json diff --git a/tests/simple/water_energy_CCSD_PRT_PR_input.json b/qcschema/tests/simple/water_energy_CCSD_PRT_PR_input.json similarity index 100% rename from tests/simple/water_energy_CCSD_PRT_PR_input.json rename to qcschema/tests/simple/water_energy_CCSD_PRT_PR_input.json diff --git a/tests/simple/water_energy_CCSD_PRT_PR_output.json b/qcschema/tests/simple/water_energy_CCSD_PRT_PR_output.json similarity index 100% rename from tests/simple/water_energy_CCSD_PRT_PR_output.json rename to qcschema/tests/simple/water_energy_CCSD_PRT_PR_output.json diff --git a/tests/simple/water_energy_CCSD_input.json b/qcschema/tests/simple/water_energy_CCSD_input.json similarity index 100% rename from tests/simple/water_energy_CCSD_input.json rename to qcschema/tests/simple/water_energy_CCSD_input.json diff --git a/tests/simple/water_energy_CCSD_output.json b/qcschema/tests/simple/water_energy_CCSD_output.json similarity index 100% rename from tests/simple/water_energy_CCSD_output.json rename to qcschema/tests/simple/water_energy_CCSD_output.json diff --git a/tests/simple/water_energy_MP2_input.json b/qcschema/tests/simple/water_energy_MP2_input.json similarity index 100% rename from tests/simple/water_energy_MP2_input.json rename to qcschema/tests/simple/water_energy_MP2_input.json diff --git a/tests/simple/water_energy_MP2_output.json b/qcschema/tests/simple/water_energy_MP2_output.json similarity index 100% rename from tests/simple/water_energy_MP2_output.json rename to qcschema/tests/simple/water_energy_MP2_output.json diff --git a/tests/simple/water_gradient_HF_input.json b/qcschema/tests/simple/water_gradient_HF_input.json similarity index 100% rename from tests/simple/water_gradient_HF_input.json rename to qcschema/tests/simple/water_gradient_HF_input.json diff --git a/tests/simple/water_gradient_HF_output.json b/qcschema/tests/simple/water_gradient_HF_output.json similarity index 100% rename from tests/simple/water_gradient_HF_output.json rename to qcschema/tests/simple/water_gradient_HF_output.json diff --git a/tests/test_failures.py b/qcschema/tests/test_failures.py similarity index 96% rename from tests/test_failures.py rename to qcschema/tests/test_failures.py index bc423b8..a82cc1d 100644 --- a/tests/test_failures.py +++ b/qcschema/tests/test_failures.py @@ -3,9 +3,8 @@ """ import jsonschema import pytest -import os -import test_helpers +from qcschema.tests import test_helpers import qcschema ### Test input validation errors diff --git a/tests/test_helpers.py b/qcschema/tests/test_helpers.py similarity index 58% rename from tests/test_helpers.py rename to qcschema/tests/test_helpers.py index 6f4daa1..c3614cb 100644 --- a/tests/test_helpers.py +++ b/qcschema/tests/test_helpers.py @@ -2,14 +2,9 @@ Contains helper scripts to assist in testing the schema """ -import pytest -import os import glob -import copy import json -import subprocess - -import qcschema +import os def _read_json_file(*filename): @@ -20,15 +15,28 @@ def _read_json_file(*filename): # Find a few required relative paths _test_path = os.path.dirname(os.path.abspath(__file__)) -_base_path = os.path.dirname(_test_path) + def list_tests(folder, ext=".json", matcher=""): """ Lists all tests in a given folder. + + Since this function operates under the assumption that tests were expected + in the given folder, raise a RuntimeError if none were found. This is a + workaround for tests being skipped when their parametrizations receive no + values. """ files = glob.glob(os.path.join(_test_path, folder, "*" + matcher + "*" + ext)) names = [os.path.basename(x).replace(ext, "") for x in files] + if not files: + raise RuntimeError( + "No files were found in the folder " + "{} with the extension '{}' and matcher '{}'".format( + os.path.abspath(folder), ext, matcher + ) + ) + return files, names def get_test(name): diff --git a/tests/test_schema.py b/qcschema/tests/test_schema.py similarity index 98% rename from tests/test_schema.py rename to qcschema/tests/test_schema.py index 69238ce..c6c87c2 100644 --- a/tests/test_schema.py +++ b/qcschema/tests/test_schema.py @@ -3,9 +3,8 @@ """ import jsonschema import pytest -import os -import test_helpers +from qcschema.tests import test_helpers import qcschema diff --git a/tests/wavefunction/water_output.json b/qcschema/tests/wavefunction/water_output.json similarity index 100% rename from tests/wavefunction/water_output.json rename to qcschema/tests/wavefunction/water_output.json diff --git a/tests/wavefunction/water_output_v3.json b/qcschema/tests/wavefunction/water_output_v3.json similarity index 100% rename from tests/wavefunction/water_output_v3.json rename to qcschema/tests/wavefunction/water_output_v3.json diff --git a/setup.py b/setup.py index 742f1b1..801246c 100644 --- a/setup.py +++ b/setup.py @@ -9,6 +9,7 @@ url="https://github.com/MolSSI/QCSchema", license='', packages=setuptools.find_packages(), + include_package_data=True, install_requires=[ 'jsonschema', 'pathlib2; python_version < "3.5"', # redundant with jsonschema @@ -28,5 +29,5 @@ tests_require=[ 'pytest', ], - zip_safe=True, + zip_safe=False, )