diff options
author | montezdesousa <79287829+montezdesousa@users.noreply.github.com> | 2024-04-26 18:18:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-26 17:18:00 +0000 |
commit | bd75a9746f2643594558f67f710b743caaac9802 (patch) | |
tree | 0896e2327ac7bf944ce507a90b09997cfbe0b6f4 | |
parent | 7f90d7406b0bddc0ce46a76ef15914e8c9a858bf (diff) |
Move files used in gh actions from root (#6346)
* Move files used in gh actions from root
* keep this
* pydocstyle
* ^
* fix: relative path, os independent
* use relative root path
* ^
* move noxfile.py to .github/scripts
* remove flag
-rw-r--r-- | .github/scripts/noxfile.py | 29 | ||||
-rw-r--r-- | .github/scripts/process_changelog.py (renamed from process_changelog.py) | 0 | ||||
-rw-r--r-- | .github/scripts/summarize_changelog.py (renamed from summarize_changelog.py) | 0 | ||||
-rw-r--r-- | .github/workflows/draft-release.yml | 4 | ||||
-rw-r--r-- | .github/workflows/platform-core.yml | 2 | ||||
-rw-r--r-- | noxfile.py | 25 | ||||
-rw-r--r-- | openbb_platform/extensions/tests/utils/integration_tests_generator.py | 6 | ||||
-rw-r--r-- | openbb_platform/tests/test_pyproject_toml.py | 7 |
8 files changed, 41 insertions, 32 deletions
diff --git a/.github/scripts/noxfile.py b/.github/scripts/noxfile.py new file mode 100644 index 00000000000..ed4411601c5 --- /dev/null +++ b/.github/scripts/noxfile.py @@ -0,0 +1,29 @@ +"""Nox sessions.""" + +from pathlib import Path + +import nox + +ROOT_DIR = Path(__file__).parent.parent.parent +PLATFORM_DIR = ROOT_DIR / "openbb_platform" +PLATFORM_TESTS = [ + str(PLATFORM_DIR / p) for p in ["tests", "core", "providers", "extensions"] +] + + +@nox.session(python=["3.9", "3.10", "3.11"]) +def tests(session): + """Run the test suite.""" + session.install("poetry", "toml") + session.run( + "python", + str(PLATFORM_DIR / "dev_install.py"), + "-e", + "all", + external=True, + ) + session.install("pytest") + session.install("pytest-cov") + session.run( + "pytest", *PLATFORM_TESTS, f"--cov={PLATFORM_DIR}", "-m", "not integration" + ) diff --git a/process_changelog.py b/.github/scripts/process_changelog.py index fbdfdf9ce0b..fbdfdf9ce0b 100644 --- a/process_changelog.py +++ b/.github/scripts/process_changelog.py diff --git a/summarize_changelog.py b/.github/scripts/summarize_changelog.py index 75648dff105..75648dff105 100644 --- a/summarize_changelog.py +++ b/.github/scripts/summarize_changelog.py diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index 65c7d52dc66..3dab21e7812 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -36,8 +36,8 @@ jobs: - name: 🧬 Process Changelog run: | pip install requests openai - python process_changelog.py CHANGELOG.md ${{ github.event.inputs.release_pr_number }} - python summarize_changelog.py ${{ secrets.GITHUB_TOKEN }} ${{ secrets.OPENAI_API_KEY }} + python .github/scripts/process_changelog.py CHANGELOG.md ${{ github.event.inputs.release_pr_number }} + python .github/scripts/summarize_changelog.py ${{ secrets.GITHUB_TOKEN }} ${{ secrets.OPENAI_API_KEY }} cat CHANGELOG.md - name: 🛫 Create Release diff --git a/.github/workflows/platform-core.yml b/.github/workflows/platform-core.yml index c509c243c80..84ac783cfaf 100644 --- a/.github/workflows/platform-core.yml +++ b/.github/workflows/platform-core.yml @@ -43,4 +43,4 @@ jobs: - name: Run tests run: | pip install nox - nox -s tests --python ${{ matrix.python_version }} + nox -f .github/scripts/noxfile.py -s tests --python ${{ matrix.python_version }} diff --git a/noxfile.py b/noxfile.py deleted file mode 100644 index 02726297a91..00000000000 --- a/noxfile.py +++ /dev/null @@ -1,25 +0,0 @@ -import nox - -test_locations = [ - "openbb_platform/tests", - "openbb_platform/core", - "openbb_platform/providers", - "openbb_platform/extensions", -] - - -@nox.session(python=["3.9", "3.10", "3.11"]) -def tests(session): - session.install("poetry", "toml") - session.run( - "python", - "./openbb_platform/dev_install.py", - "-e", - "all", - external=True, - ) - session.install("pytest") - session.install("pytest-cov") - session.run( - "pytest", *test_locations, "--cov=openbb_platform/", "-m", "not integration" - ) diff --git a/openbb_platform/extensions/tests/utils/integration_tests_generator.py b/openbb_platform/extensions/tests/utils/integration_tests_generator.py index 7e1f478fd47..0e7663b03e4 100644 --- a/openbb_platform/extensions/tests/utils/integration_tests_generator.py +++ b/openbb_platform/extensions/tests/utils/integration_tests_generator.py @@ -20,6 +20,8 @@ from openbb_core.app.router import CommandMap from pydantic.fields import FieldInfo from pydantic_core import PydanticUndefined +ROOT_DIR = Path(__file__).parent.parent.parent.parent + TEST_TEMPLATE = """\n\n@parametrize( "params", [ @@ -43,9 +45,9 @@ def find_extensions(filter_chart: Optional[bool] = True): filter_ext = ["tests", "__pycache__"] if filter_chart: filter_ext.append("charting") - extensions = [x for x in Path("openbb_platform/extensions").iterdir() if x.is_dir()] + extensions = [x for x in (ROOT_DIR / "extensions").iterdir() if x.is_dir()] extensions.extend( - [x for x in Path("openbb_platform/obbject_extensions").iterdir() if x.is_dir()] + [x for x in (ROOT_DIR / "obbject_extensions").iterdir() if x.is_dir()] ) extensions = [x for x in extensions if x.name not in filter_ext] return extensions diff --git a/openbb_platform/tests/test_pyproject_toml.py b/openbb_platform/tests/test_pyproject_toml.py index 7012b0797dc..c4c6e908fc8 100644 --- a/openbb_platform/tests/test_pyproject_toml.py +++ b/openbb_platform/tests/test_pyproject_toml.py @@ -2,13 +2,16 @@ import glob import os +from pathlib import Path import toml +ROOT_DIR = Path(__file__).parent.parent + def test_optional_packages(): """Ensure only required extensions are built and versions respect pyproject.toml""" - data = toml.load("openbb_platform/pyproject.toml") + data = toml.load(ROOT_DIR / "pyproject.toml") dependencies = data["tool"]["poetry"]["dependencies"] extras = data["tool"]["poetry"]["extras"] all_packages = extras["all"] @@ -32,7 +35,7 @@ def test_optional_packages(): def test_default_package_files(): """Ensure only required extensions are built and versions respect pyproject.toml""" - data = toml.load("openbb_platform/pyproject.toml") + data = toml.load(Path(ROOT_DIR / "pyproject.toml")) dependencies = data["tool"]["poetry"]["dependencies"] package_files = glob.glob("openbb_platform/openbb/package/*.py") |