From 78365452d3c1ee3b47c4d12dc43813b655064eac Mon Sep 17 00:00:00 2001 From: Jette16 <33116335+Jette16@users.noreply.github.com> Date: Wed, 13 Oct 2021 14:13:06 +0200 Subject: [PATCH] Moved test for universe into .github folder (#9447) * Moved universe-test into .github folder * Cleaned code * CHanged a file name --- .github/azure-steps.yml | 5 +++++ .../validate_universe_json.py | 12 +++++++----- .gitignore | 1 - setup.py | 1 - 4 files changed, 12 insertions(+), 7 deletions(-) rename spacy/tests/universe/test_universe_json.py => .github/validate_universe_json.py (72%) diff --git a/.github/azure-steps.yml b/.github/azure-steps.yml index 50e81799e..543804b9f 100644 --- a/.github/azure-steps.yml +++ b/.github/azure-steps.yml @@ -100,3 +100,8 @@ steps: python -m spacy assemble ner_source_md.cfg output_dir 2>&1 | grep -q W113 displayName: 'Test assemble CLI vectors warning' condition: eq(variables['python_version'], '3.8') + + - script: | + python .github/validate_universe_json.py website/meta/universe.json + displayName: 'Test website/meta/universe.json' + condition: eq(variables['python_version'], '3.8') diff --git a/spacy/tests/universe/test_universe_json.py b/.github/validate_universe_json.py similarity index 72% rename from spacy/tests/universe/test_universe_json.py rename to .github/validate_universe_json.py index 295889186..b96b7b347 100644 --- a/spacy/tests/universe/test_universe_json.py +++ b/.github/validate_universe_json.py @@ -1,13 +1,11 @@ import json import re +import sys from pathlib import Path -def test_universe_json(): - - root_dir = Path(__file__).parent - universe_file = root_dir / "universe.json" - +def validate_json(document): + universe_file = Path(document) with universe_file.open() as f: universe_data = json.load(f) for entry in universe_data["resources"]: @@ -15,3 +13,7 @@ def test_universe_json(): assert not re.match( r"^(http:)|^(https:)", entry["github"] ), "Github field should be user/repo, not a url" + + +if __name__ == "__main__": + validate_json(str(sys.argv[1])) diff --git a/.gitignore b/.gitignore index 60036a475..ac72f2bbf 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,6 @@ keys/ spacy/tests/package/setup.cfg spacy/tests/package/pyproject.toml spacy/tests/package/requirements.txt -spacy/tests/universe/universe.json # Website website/.cache/ diff --git a/setup.py b/setup.py index 03a1e01dd..fcc124a43 100755 --- a/setup.py +++ b/setup.py @@ -81,7 +81,6 @@ COPY_FILES = { ROOT / "setup.cfg": PACKAGE_ROOT / "tests" / "package", ROOT / "pyproject.toml": PACKAGE_ROOT / "tests" / "package", ROOT / "requirements.txt": PACKAGE_ROOT / "tests" / "package", - ROOT / "website" / "meta" / "universe.json": PACKAGE_ROOT / "tests" / "universe", }