mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-05 00:42:19 +00:00
[V5] openbb-core: 100% Test Coverage (#7484)
* increase test coverage to exercise 100% of the testable code path in openbb-core * model_fields syntax cleanup * set the environment variable for CI runs * run codeql on v5 branch * more CI env setup * cleanup redundant files * ruff * dedupe workflow trigger * some windows coverage missing * ubuntu integration test job * more windows coverage * test_reference_generator * test_docstring_generator * remove line no references from test function docstrings * clean useless comments from test files * fix polars type check * fix test_obbject * fix test_obbject
This commit is contained in:
4
.github/workflows/codeql.yml
vendored
4
.github/workflows/codeql.yml
vendored
@@ -13,11 +13,11 @@ name: "CodeQL Advanced"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "develop", "PR-review", "gh-pages", "main" ]
|
||||
branches: [ "develop", "PR-review", "gh-pages", "main", "v5" ]
|
||||
paths-ignore:
|
||||
- 'cookiecutter/**'
|
||||
pull_request:
|
||||
branches: [ "develop", "PR-review", "gh-pages", "main" ]
|
||||
branches: [ "develop", "PR-review", "gh-pages", "main", "v5" ]
|
||||
paths-ignore:
|
||||
- 'cookiecutter/**'
|
||||
schedule:
|
||||
|
||||
80
.github/workflows/test-openbb-core.yml
vendored
80
.github/workflows/test-openbb-core.yml
vendored
@@ -13,9 +13,6 @@ on:
|
||||
branches:
|
||||
- develop
|
||||
- v5
|
||||
- 'feature/**'
|
||||
- 'hotfix/**'
|
||||
- 'release/**'
|
||||
paths:
|
||||
- 'openbb_platform/core/**'
|
||||
- 'openbb_platform/extensions/devtools/**'
|
||||
@@ -37,6 +34,9 @@ jobs:
|
||||
test:
|
||||
name: Test (${{ matrix.os }} / Python ${{ matrix.python_version }})
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
OPENBB_ALLOW_ON_COMMAND_OUTPUT: "True"
|
||||
OPENBB_ALLOW_MUTABLE_EXTENSIONS: "True"
|
||||
permissions:
|
||||
contents: read
|
||||
strategy:
|
||||
@@ -72,16 +72,80 @@ jobs:
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -e ".[pandas]"
|
||||
pip install pytest pytest-cov pytest-asyncio httpx
|
||||
pip install pytest pytest-cov pytest-asyncio httpx coverage[toml]
|
||||
|
||||
- name: Run unit tests
|
||||
run: |
|
||||
pytest tests --cov=openbb_core --cov-report=term-missing --cov-report=xml
|
||||
pytest tests \
|
||||
--cov=openbb_core \
|
||||
--cov-config=.coveragerc \
|
||||
--cov-report=term-missing \
|
||||
--cov-report=xml:coverage-unit.xml
|
||||
|
||||
- name: Upload coverage artifact
|
||||
- name: Upload unit-test coverage artifact
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openbb-core-coverage-${{ matrix.os }}-py${{ matrix.python_version }}
|
||||
path: openbb_platform/core/coverage.xml
|
||||
name: openbb-core-coverage-unit-${{ matrix.os }}-py${{ matrix.python_version }}
|
||||
path: openbb_platform/core/coverage-unit.xml
|
||||
if-no-files-found: ignore
|
||||
|
||||
integration:
|
||||
name: Integration (ubuntu / py3.13)
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
env:
|
||||
OPENBB_ALLOW_ON_COMMAND_OUTPUT: "True"
|
||||
OPENBB_ALLOW_MUTABLE_EXTENSIONS: "True"
|
||||
permissions:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||
|
||||
- name: Install Python 3.13
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.13"
|
||||
cache: "pip"
|
||||
|
||||
- name: Install openbb-core (with pandas extra) and test deps
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -e ".[pandas]"
|
||||
pip install pytest pytest-cov pytest-asyncio httpx coverage[toml]
|
||||
|
||||
- name: Enable subprocess coverage (sitecustomize shim)
|
||||
run: |
|
||||
# `coverage.process_startup()` only fires in child interpreters when
|
||||
# both COVERAGE_PROCESS_START is set AND a sitecustomize.py on
|
||||
# sys.path calls it. Drop the shim into site-packages so every
|
||||
# `python` subprocess spawned by the integration suite (including
|
||||
# the one that runs `openbb-build`) is instrumented.
|
||||
python -c "import sysconfig, pathlib; \
|
||||
p = pathlib.Path(sysconfig.get_paths()['purelib']) / 'sitecustomize.py'; \
|
||||
p.write_text('import coverage\ncoverage.process_startup()\n'); \
|
||||
print('wrote', p)"
|
||||
|
||||
- name: Run integration tests with subprocess coverage
|
||||
env:
|
||||
COVERAGE_PROCESS_START: ${{ github.workspace }}/openbb_platform/core/.coveragerc
|
||||
COVERAGE_FILE: .coverage.integration
|
||||
run: |
|
||||
# Run pytest directly. Child interpreters are instrumented via
|
||||
# COVERAGE_PROCESS_START + sitecustomize and write parallel
|
||||
# `.coverage.*` files in CWD.
|
||||
pytest integration -m integration -v
|
||||
coverage combine
|
||||
coverage report --rcfile=.coveragerc
|
||||
coverage xml --rcfile=.coveragerc -o coverage-integration.xml
|
||||
|
||||
- name: Upload integration coverage artifact
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openbb-core-coverage-integration
|
||||
path: openbb_platform/core/coverage-integration.xml
|
||||
if-no-files-found: ignore
|
||||
|
||||
Reference in New Issue
Block a user