-
Notifications
You must be signed in to change notification settings - Fork 7.4k
161 lines (145 loc) · 6.06 KB
/
Copy pathlint-openbb-platform.yml
File metadata and controls
161 lines (145 loc) · 6.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: 🧹 General Linting
env:
PIP_DEFAULT_TIMEOUT: 100
on:
pull_request:
types: [opened, synchronize, edited]
paths:
- 'openbb_platform/**'
- '.github/workflows/general-linting.yml'
merge_group:
types: [checks_requested]
concurrency:
group: ${{ github.event_name }}-${{ github.repository }}-${{ github.ref }}
cancel-in-progress: true
jobs:
code-linting:
name: General Code Linting
runs-on: ubuntu-latest
env:
UV_CACHE_DIR: ${{ github.workspace }}/.uv-cache
permissions:
contents: read
steps:
- name: Checkout Code
uses: actions/checkout@v6 # actions/checkout v3.0.2
with:
ref: ${{ github.event.pull_request.head.ref || github.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
fetch-depth: 20
token: ${{ secrets.GITHUB_TOKEN }}
- name: Fetch base branch
run: git fetch --no-tags --depth=20 origin ${{ github.base_ref }}
- name: Setup Python 3.10
uses: actions/setup-python@v6
with:
python-version: "3.10"
architecture: x64
- name: Get changed files in openbb_platform for PR
if: github.event_name == 'pull_request'
run: |
# "Checking PR diff"
echo "diff_files=$(git diff --diff-filter=d --name-only origin/${{ github.base_ref }}...${HEAD_REF} | grep -E '^openbb_platform/.*\.py$' | grep -v 'openbb_platform/core/openbb/package' | grep -v 'integration' | grep -v 'tests' | xargs)" >> $GITHUB_ENV
echo $diff_files
env:
HEAD_REF: ${{ github.head_ref }}
- name: Cache uv (built wheels)
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.uv-cache
key: uv-${{ runner.os }}-py3.10-lint-${{ hashFiles('openbb_platform/**/pyproject.toml', 'cli/pyproject.toml') }}
restore-keys: |
uv-${{ runner.os }}-py3.10-lint-
- name: Install tooling (ruff + ty + codespell)
run: |
python -m pip install --upgrade pip uv
uv pip install --system -e ./openbb_platform/extensions/devtools
- name: Install changed packages (so ty resolves their declared deps)
if: env.diff_files != ''
run: |
# Install each touched package so ty has the package's declared
# third-party deps (pandas-ta, scipy, statsmodels, etc.) available
# for type resolution. Optional cross-package peers (e.g.
# openbb_charting) that aren't installed surface as `warn`-level
# diagnostics under the package ty.toml rather than build errors.
touched=$(echo "${{ env.diff_files }}" | tr ' ' '\n' \
| grep -oE '^(openbb_platform/(extensions|providers|obbject_extensions)|cli)/[^/]+' \
| sort -u)
for pkg in $touched; do
if [ -f "$pkg/pyproject.toml" ]; then
echo "Installing $pkg"
uv pip install --system -e "./$pkg" || echo "skip $pkg (install failed)"
fi
done
- name: Install openbb-core editable (resident, single identity for ty)
run: |
# Install core last and editable so the in-tree source is the resident
# `openbb_core`. A published wheel pulled in as a transitive dep above
# would otherwise shadow it and produce spurious type-identity errors.
uv pip install --system -e "./openbb_platform/core[pandas]" numpy
- name: codespell
run: codespell --ignore-words=.codespell.ignore --skip="$(tr '\n' ',' < .codespell.skip | sed 's/,$//')" --quiet-level=2
- name: ruff + ty (per package, from each package root)
if: env.diff_files != ''
run: |
# ty must run from each package's own root. Invoked from the repo root,
# an in-tree file like openbb_platform/core/openbb_core/app/router.py
# resolves under a different module identity than the installed
# `openbb_core`, yielding false "incompatible type" errors. Grouping
# changed files by their nearest pyproject.toml ancestor makes each
# package its own ty project root, so first-party imports resolve to a
# single identity (matching how the per-package test-unit jobs run ty).
status=0
declare -A pkg_files
for f in ${{ env.diff_files }}; do
dir=$(dirname "$f")
while [ "$dir" != "." ] && [ ! -f "$dir/pyproject.toml" ]; do
dir=$(dirname "$dir")
done
if [ -f "$dir/pyproject.toml" ]; then
pkg_files["$dir"]+="${f#"$dir"/} "
else
echo "::warning::no pyproject.toml ancestor for $f; checking from repo root"
pkg_files["."]+="$f "
fi
done
for pkg in "${!pkg_files[@]}"; do
files=${pkg_files[$pkg]}
echo "::group::Linting $pkg"
(
cd "$pkg"
rc=0
ruff format --check $files || rc=1
ruff check $files || rc=1
ty check $files || rc=1
exit $rc
) || status=1
echo "::endgroup::"
done
exit $status
markdown-link-check:
name: Markdown Linting
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
name: Check out the code
- name: Lint Code Base
uses: docker://avtodev/markdown-lint:v1
with:
ignore: "./openbb_platform/extensions/mcp_server/openbb_mcp_server/skills/**/*.md ./openbb_platform/providers/sec/openbb_sec/utils/STATEMENT_SCHEMA_README.md"
args: "./*.md ./changelogs/*.md ./openbb_platform/**/*.md"
json-yaml-validate:
name: JSON Check
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- name: json-yaml-validate
id: json-yaml-validate
uses: GrantBirki/json-yaml-validate@9bbaa8474e3af4e91f25eda8ac194fdc30564d96 # v4
with:
yaml_exclude_regex: "construct.yaml"
use_gitignore: false