mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-12-01 13:44:16 +00:00
[V5] openbb-bls: Refactor for V5 + Add Many Endpoints (#7518)
* refactor bls for v5, add 100 widgets * some CI fixes * no python 3.15 * fix missing dev group in pyproject.toml * more pyproject fallout * action
This commit is contained in:
191
.github/workflows/publish-openbb-bls.yml
vendored
Normal file
191
.github/workflows/publish-openbb-bls.yml
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
name: 📦 publish openbb-bls
|
||||
|
||||
# Triggers exclusively on the merge of a ``release/openbb-bls-v*`` branch into ``develop``.
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [closed]
|
||||
branches: [develop, v5]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
version-check:
|
||||
name: Verify version bump
|
||||
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/openbb-bls-v')) || github.event_name == 'workflow_dispatch' }}
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
version: ${{ steps.parse.outputs.version }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: openbb_platform/providers/bls
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
ref: develop
|
||||
|
||||
- name: Parse [project].version from pyproject.toml
|
||||
id: parse
|
||||
run: |
|
||||
VERSION=$(grep -m1 -E '^version[[:space:]]*=' pyproject.toml | sed -E 's/^version[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/')
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "::error::Could not parse [project].version from pyproject.toml."
|
||||
exit 1
|
||||
fi
|
||||
echo "Local version: $VERSION"
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Fail if version already exists on PyPI
|
||||
env:
|
||||
VERSION: ${{ steps.parse.outputs.version }}
|
||||
run: |
|
||||
STATUS=$(curl -sS -o /dev/null -w "%{http_code}" "https://pypi.org/pypi/openbb-bls/${VERSION}/json")
|
||||
case "$STATUS" in
|
||||
200)
|
||||
echo "::error::openbb-bls ${VERSION} is already published on PyPI."
|
||||
echo "Bump openbb_platform/providers/bls/pyproject.toml [project].version and re-merge a fresh release branch."
|
||||
exit 1
|
||||
;;
|
||||
404)
|
||||
echo "openbb-bls ${VERSION} is not yet on PyPI — proceeding."
|
||||
;;
|
||||
*)
|
||||
echo "::error::Unexpected status $STATUS from PyPI JSON API. Aborting to avoid a silent skip."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
- name: Verify release branch name matches pyproject version
|
||||
if: github.event_name == 'pull_request'
|
||||
env:
|
||||
VERSION: ${{ steps.parse.outputs.version }}
|
||||
BRANCH: ${{ github.event.pull_request.head.ref }}
|
||||
run: |
|
||||
EXPECTED="release/openbb-bls-v${VERSION}"
|
||||
if [ "$BRANCH" != "$EXPECTED" ]; then
|
||||
echo "::error::Release branch '${BRANCH}' does not match pyproject version '${VERSION}'."
|
||||
echo "Expected branch name: '${EXPECTED}'."
|
||||
echo "Either rename the release branch or update [project].version in pyproject.toml so they agree."
|
||||
exit 1
|
||||
fi
|
||||
echo "Branch '${BRANCH}' matches pyproject version '${VERSION}'."
|
||||
|
||||
build:
|
||||
name: Build sdist + wheel
|
||||
needs: version-check
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
working-directory: openbb_platform/providers/bls
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
ref: develop
|
||||
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.11"
|
||||
|
||||
- run: python -m pip install --upgrade pip uv
|
||||
|
||||
- name: Restore BLS series cache (warming pool for PR workflow)
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: openbb_platform/providers/bls/openbb_bls/assets/bls_cache.zip
|
||||
key: bls-cache-${{ hashFiles('openbb_platform/providers/bls/openbb_bls/utils/generate_cache.py') }}
|
||||
|
||||
- name: Build sdist + wheel (fresh BLS cache)
|
||||
# ``OPENBB_BLS_FORCE_CACHE_REBUILD=1`` makes the build hook
|
||||
# bypass its idempotent skip and regenerate against live
|
||||
# download.bls.gov so the published artifact is always current.
|
||||
env:
|
||||
OPENBB_BLS_FORCE_CACHE_REBUILD: "1"
|
||||
run: uv build --no-sources
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: openbb-bls-dist
|
||||
path: openbb_platform/providers/bls/dist/
|
||||
if-no-files-found: error
|
||||
retention-days: 7
|
||||
|
||||
test:
|
||||
name: Test (${{ matrix.os }} / Python ${{ matrix.python_version }})
|
||||
needs: build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
# Linux: full sweep across every released Python.
|
||||
- { 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" }
|
||||
# macOS + Windows: min and max supported.
|
||||
- { 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/bls
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
ref: develop
|
||||
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: ${{ matrix.python_version }}
|
||||
allow-prereleases: true
|
||||
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: openbb-bls-dist
|
||||
path: openbb_platform/providers/bls/dist
|
||||
|
||||
- run: python -m pip install --upgrade pip uv
|
||||
|
||||
- name: Seed the cache asset from the built wheel
|
||||
run: |
|
||||
WHEEL=$(ls dist/openbb_bls-*.whl | head -1)
|
||||
mkdir -p openbb_bls/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_bls/assets/bls_cache.zip') as src, open(dest, 'wb') as out:
|
||||
shutil.copyfileobj(src, out)
|
||||
" "$WHEEL" openbb_bls/assets/bls_cache.zip
|
||||
|
||||
- name: Install openbb-bls from source (+ dev group)
|
||||
run: |
|
||||
uv pip install --system -e .
|
||||
uv pip install --system --group dev
|
||||
|
||||
- name: Run unit tests
|
||||
run: pytest tests --cov=openbb_bls --cov-report=term-missing
|
||||
|
||||
publish:
|
||||
name: Publish to PyPI
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
id-token: write # required for PyPI OIDC trusted publishing
|
||||
steps:
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: openbb-bls-dist
|
||||
path: dist
|
||||
|
||||
- uses: pypa/gh-action-pypi-publish@release/v1
|
||||
with:
|
||||
packages-dir: dist
|
||||
167
.github/workflows/test-unit-openbb-bls.yml
vendored
Normal file
167
.github/workflows/test-unit-openbb-bls.yml
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
name: 🧪 test openbb-bls
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [develop, main, v5, feature/v5-platform-api]
|
||||
paths:
|
||||
- "openbb_platform/providers/bls/**"
|
||||
- ".github/workflows/test-unit-openbb-bls.yml"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
force_cache_rebuild:
|
||||
description: "Force the build hook to regenerate the BLS cache from live download.bls.gov (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-bls-${{ 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/bls
|
||||
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 BLS series cache
|
||||
id: bls-cache
|
||||
uses: actions/cache@v5
|
||||
with:
|
||||
path: openbb_platform/providers/bls/openbb_bls/assets/bls_cache.zip
|
||||
key: bls-cache-${{ hashFiles('openbb_platform/providers/bls/openbb_bls/utils/generate_cache.py') }}
|
||||
restore-keys: |
|
||||
bls-cache-
|
||||
|
||||
- name: Build sdist + wheel
|
||||
env:
|
||||
OPENBB_BLS_FORCE_CACHE_REBUILD: ${{ inputs.force_cache_rebuild == true && '1' || '0' }}
|
||||
run: uv build --no-sources
|
||||
|
||||
- uses: actions/upload-artifact@v5
|
||||
with:
|
||||
name: openbb-bls-dist
|
||||
path: openbb_platform/providers/bls/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/bls
|
||||
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-bls-dist
|
||||
path: openbb_platform/providers/bls/dist
|
||||
|
||||
- name: Seed the cache asset from the built wheel
|
||||
run: |
|
||||
WHEEL=$(ls dist/openbb_bls-*.whl | head -1)
|
||||
mkdir -p openbb_bls/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_bls/assets/bls_cache.zip') as src, open(dest, 'wb') as out:
|
||||
shutil.copyfileobj(src, out)
|
||||
" "$WHEEL" openbb_bls/assets/bls_cache.zip
|
||||
ls -la openbb_bls/assets/bls_cache.zip
|
||||
|
||||
- name: Install openbb-bls in editable mode (+ dev group)
|
||||
run: |
|
||||
uv pip install --system -e .
|
||||
uv pip install --system --group dev
|
||||
|
||||
- name: ruff check
|
||||
run: ruff check openbb_bls tests integration hatch_build.py
|
||||
|
||||
- name: ruff format --check
|
||||
run: ruff format --check openbb_bls tests integration hatch_build.py
|
||||
|
||||
- name: ty check
|
||||
run: ty check openbb_bls
|
||||
|
||||
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/bls
|
||||
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-bls-dist
|
||||
path: openbb_platform/providers/bls/dist
|
||||
|
||||
- run: python -m pip install --upgrade pip uv
|
||||
|
||||
- name: Seed the cache asset from the built wheel
|
||||
run: |
|
||||
WHEEL=$(ls dist/openbb_bls-*.whl | head -1)
|
||||
mkdir -p openbb_bls/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_bls/assets/bls_cache.zip') as src, open(dest, 'wb') as out:
|
||||
shutil.copyfileobj(src, out)
|
||||
" "$WHEEL" openbb_bls/assets/bls_cache.zip
|
||||
|
||||
- name: Install openbb-bls from source (+ dev group)
|
||||
run: |
|
||||
uv pip install --system -e .
|
||||
uv pip install --system --group dev
|
||||
|
||||
- name: Run unit tests
|
||||
run: pytest tests --cov=openbb_bls --cov-report=term-missing --cov-fail-under=100
|
||||
Reference in New Issue
Block a user