Files
OpenBB/.github/workflows/test-unit-openbb-ecb.yml
Danglewood 840658d01f [V5] openbb-ecb: Refactor for V5 and Expand Coverage (#7560)
* refactor openbb-ecb for v5 and expand coverage

* some updates

* tests

* workflow

* remove 3.15 from test matrix

* some more table schema updates

* remove some html chrome on embedded articles

---------

Co-authored-by: deeleeramone <>
2026-09-23 11:57:59 -07:00

170 lines
5.7 KiB
YAML
Vendored

name: 🧪 test openbb-ecb
on:
pull_request:
branches: [develop, main, v5]
paths:
- "openbb_platform/providers/ecb/**"
- ".github/workflows/test-unit-openbb-ecb.yml"
workflow_dispatch:
inputs:
force_cache_rebuild:
description: "Force the build hook to regenerate the ECB cache from live SDMX (ignores actions/cache)."
type: boolean
default: false
permissions:
contents: read
concurrency:
# Cancel in-flight matrix runs when a new commit lands on the same PR.
group: test-openbb-ecb-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build sdist + wheel
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: openbb_platform/providers/ecb
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.11"
- run: python -m pip install --upgrade pip uv
- name: Restore ECB SDMX cache
id: ecb-cache
uses: actions/cache@v5
with:
path: openbb_platform/providers/ecb/openbb_ecb/assets/ecb_cache.json.xz
key: ecb-sdmx-${{ hashFiles('openbb_platform/providers/ecb/openbb_ecb/utils/generate_cache.py') }}
- name: Build sdist + wheel
env:
OPENBB_ECB_FORCE_CACHE_REBUILD: ${{ inputs.force_cache_rebuild == true && '1' || '0' }}
run: uv build --no-sources
- uses: actions/upload-artifact@v5
with:
name: openbb-ecb-dist
path: openbb_platform/providers/ecb/dist/
if-no-files-found: error
retention-days: 7
lint:
name: Lint (ruff + ty)
needs: build
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: openbb_platform/providers/ecb
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.11"
- run: python -m pip install --upgrade pip uv
- uses: actions/download-artifact@v5
with:
name: openbb-ecb-dist
path: openbb_platform/providers/ecb/dist
- name: Seed the cache asset from the built wheel
run: |
WHEEL=$(ls dist/openbb_ecb-*.whl | head -1)
mkdir -p openbb_ecb/assets
python -c "
import sys, zipfile, shutil
wheel = sys.argv[1]
dest = sys.argv[2]
with zipfile.ZipFile(wheel) as z:
with z.open('openbb_ecb/assets/ecb_cache.json.xz') as src, open(dest, 'wb') as out:
shutil.copyfileobj(src, out)
" "$WHEEL" openbb_ecb/assets/ecb_cache.json.xz
ls -la openbb_ecb/assets/ecb_cache.json.xz
- name: Install with uv (resolves openbb-core / devtools via [tool.uv.sources])
# ``uv sync`` reads ``[tool.uv.sources]`` and installs ``openbb-core`` and
# ``openbb-devtools`` editable from the sibling trees (``../../core`` etc.),
# plus the ``dev`` group — which ``uv pip install`` cannot do, since the
# pip layer ignores ``tool.uv.sources`` and would fail to resolve
# ``openbb-core>=2.0.0`` from PyPI until it ships.
run: uv sync --python "3.11"
- name: ruff check
run: uv run ruff check openbb_ecb tests integration hatch_build.py
- name: ruff format --check
run: uv run ruff format --check openbb_ecb tests integration hatch_build.py
- name: ty check
run: uv run ty check openbb_ecb
test:
name: Test (${{ matrix.os }} / Python ${{ matrix.python_version }})
needs: build
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, python_version: "3.10" }
- { os: ubuntu-latest, python_version: "3.11" }
- { os: ubuntu-latest, python_version: "3.12" }
- { os: ubuntu-latest, python_version: "3.13" }
- { os: ubuntu-latest, python_version: "3.14" }
- { os: macos-latest, python_version: "3.10" }
- { os: macos-latest, python_version: "3.14" }
- { os: windows-latest, python_version: "3.10" }
- { os: windows-latest, python_version: "3.14" }
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
working-directory: openbb_platform/providers/ecb
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python_version }}
allow-prereleases: true
- uses: actions/download-artifact@v5
with:
name: openbb-ecb-dist
path: openbb_platform/providers/ecb/dist
- run: python -m pip install --upgrade pip uv
- name: Seed the cache asset from the built wheel
run: |
WHEEL=$(ls dist/openbb_ecb-*.whl | head -1)
mkdir -p openbb_ecb/assets
python -c "
import sys, zipfile, shutil
wheel = sys.argv[1]
dest = sys.argv[2]
with zipfile.ZipFile(wheel) as z:
with z.open('openbb_ecb/assets/ecb_cache.json.xz') as src, open(dest, 'wb') as out:
shutil.copyfileobj(src, out)
" "$WHEEL" openbb_ecb/assets/ecb_cache.json.xz
- name: Install with uv (resolves openbb-core / devtools via [tool.uv.sources])
# ``uv sync`` honors ``[tool.uv.sources]`` (sibling-tree ``openbb-core`` /
# ``openbb-devtools``) and the ``dev`` group; ``uv pip install`` ignores
# sources and would fail to resolve ``openbb-core>=2.0.0`` from PyPI.
run: uv sync --python ${{ matrix.python_version }}
- name: Run unit tests
run: uv run pytest tests --cov=openbb_ecb --cov-report=term-missing --cov-fail-under=100