-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #237 from loriab/schemalint13
QCSchema coordination, testing, and export
- Loading branch information
Showing
38 changed files
with
822 additions
and
244 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: QCSchema | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
conda-env: [base] | ||
python-version: [3.7] | ||
env: | ||
PYVER: ${{ matrix.python-version }} | ||
CONDA_ENV: ${{ matrix.conda-env }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
path: qcel | ||
|
||
- name: Checkout schema repo | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: MolSSI/QCSchema | ||
path: qcsk | ||
ref: qcsk_export_2 | ||
#ref: master | ||
persist-credentials: true | ||
fetch-depth: 0 | ||
token: ${{ secrets.qcschema_from_qcelemental }} | ||
|
||
- name: Python Setup | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Create Environment | ||
shell: bash | ||
working-directory: ./qcel | ||
run: | | ||
eval "$(conda shell.bash hook)" && conda activate | ||
python devtools/scripts/create_conda_env.py -n=test -p=$PYVER devtools/conda-envs/$CONDA_ENV.yaml | ||
|
||
- name: Install | ||
shell: bash | ||
working-directory: ./qcel | ||
run: | | ||
eval "$(conda shell.bash hook)" && conda activate test | ||
python -m pip install . --no-deps | ||
|
||
- name: Environment Information | ||
shell: bash | ||
run: | | ||
eval "$(conda shell.bash hook)" && conda activate test | ||
conda list --show-channel-urls | ||
|
||
- name: QCSchema from QCElemental | ||
shell: bash | ||
working-directory: ./qcel | ||
run: | | ||
eval "$(conda shell.bash hook)" && conda activate test | ||
make qcschema | ||
ls -l qcschema | ||
cp -p qcschema/* ../qcsk/qcschema/data/vdev/ | ||
mv ../qcsk/qcschema/data/vdev/QCSchema.schema ../qcsk/qcschema/dev/ | ||
|
||
- name: Compare Schemas (generated vs. community) | ||
shell: bash | ||
working-directory: ./qcsk | ||
run: | | ||
git diff --color-words | ||
pull_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH") | ||
branch=qcel-${pull_number} | ||
git checkout -b ${branch} | ||
git remote -v | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git add -A | ||
git commit -m "auto-generated from QCElemental" | ||
echo "::set-env name=prbranch::${branch}" | ||
|
||
- name: Propose changes | ||
uses: ad-m/github-push-action@master | ||
with: | ||
directory: ./qcsk | ||
repository: MolSSI/QCSchema | ||
branch: ${{ env.prbranch }} | ||
github_token: ${{ secrets.qcschema_from_qcelemental }} | ||
force: true |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption( | ||
"--validate", action="store_true", help="validate JSON from previous test run against exported schema" | ||
) | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def set_up_overall(request): | ||
# in all pytest runs except --validate (which uses the files), clear away the JSON examples and generate fresh | ||
if not request.config.getoption("--validate", default=False): | ||
_data_path = Path(__file__).parent.resolve() / "tests" / "qcschema_instances" | ||
for fl in _data_path.rglob("*.json"): | ||
fl.unlink() | ||
|
||
|
||
def pytest_runtest_setup(item): | ||
# there's a bug where can only set options if specify path in call, so needs to be ``pytest qcelemental/ --validate`` | ||
|
||
# skip the validate-generated-instances-against-exported-schema tests on most ``pytest`` runs. | ||
# run only the validate-generated-instances-against-exported-schema tests on ``pytest --validate`` runs. | ||
if not item.config.getoption("--validate", default=False) and item.name.startswith("test_qcschema"): | ||
pytest.skip("can't run with --validate option") | ||
elif item.config.getoption("--validate", default=False) and not item.name.startswith("test_qcschema"): | ||
pytest.skip("need --validate option to run") | ||
|
||
|
||
# Uncomment below to probe for tests needing `@using_web` | ||
|
||
# import socket | ||
# | ||
# class block_network(socket.socket): | ||
# def __init__(self, *args, **kwargs): | ||
# raise Exception("Network call blocked") | ||
# | ||
# socket.socket = block_network |
This file contains 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
This file contains 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
Oops, something went wrong.