-
Notifications
You must be signed in to change notification settings - Fork 3.2k
108 lines (96 loc) · 3.73 KB
/
linting.yml
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
name: General Linting
env:
OPENBB_ENABLE_QUICK_EXIT: true
OPENBB_LOG_COLLECT: false
OPENBB_USE_PROMPT_TOOLKIT: false
OPENBB_FILE_OVERWRITE: true
PIP_DEFAULT_TIMEOUT: 100
on:
pull_request:
types: [opened, synchronize, edited]
push:
branches:
- "feature/*"
- "hotfix/*"
- "release/*"
merge_group:
types: [checks_requested]
# Cancel previous runs that are not yet completed.
concurrency:
group: ${{ github.event_name }}-${{ github.repository }}-${{ github.ref }}
cancel-in-progress: true
jobs:
code-linting:
name: General Code Linting
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4.1.1 # 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.9
uses: actions/setup-python@v4
with:
python-version: "3.9"
architecture: x64
- name: Get changed files in openbb_terminal and openbb_platform for PR
if: github.event_name == 'pull_request'
run: |
# "Checking PR diff"
echo "terminal_files=$(git diff --name-only origin/${{ github.base_ref }}...${{ github.head_ref }} | grep 'openbb_terminal/.*\.py$' | xargs)" >> $GITHUB_ENV
echo $terminal_files
echo "platform_files=$(git diff --name-only origin/${{ github.base_ref }}...${{ github.head_ref }} | grep 'openbb_platform/.*\.py$' | grep -v 'openbb_platform/openbb/package' | grep -v 'integration' | grep -v 'tests' | xargs)" >> $GITHUB_ENV
echo $platform_files
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-linting-${{ hashFiles('**/poetry.lock') }}
restore-keys: ${{ runner.os }}-linting-${{ hashFiles('**/poetry.lock') }}
- run: |
pip install openbb-devtools
pip install types-pytz types-requests types-termcolor types-tabulate types-PyYAML types-python-dateutil types-setuptools types-six
- run: bandit -x ./tests -r . || true
- run: black --diff --check .
- run: codespell --ignore-words=.codespell.ignore --skip="$(tr '\n' ',' < .codespell.skip | sed 's/,$//')" --quiet-level=2
- run: ruff .
- run: |
# Run linters for openbb_terminal
if [ -n "${{ env.terminal_files }}" ]; then
mypy --ignore-missing-imports ${{ env.terminal_files }}
pylint terminal.py ${{ env.terminal_files }}
else
echo "No Python files changed in openbb_terminal"
fi
- run: |
# Run linters for openbb_platform
if [ -n "${{ env.platform_files }}" ]; then
# Add mypy to this part of the linting workflow once we're ready
pylint ${{ env.platform_files }}
else
echo "No Python files changed in openbb_platform"
fi
markdown-link-check:
name: Markdown Linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Check out the code
- name: Lint Code Base
uses: docker://avtodev/markdown-lint:v1
with:
args: "./*.md ./changelogs/*.md ./openbb_terminal/**/*.md ./discordbot/**/*.md"
json-yaml-validate:
name: JSON Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: json-yaml-validate
id: json-yaml-validate
uses: GrantBirki/json-yaml-validate@v2.0.0
with:
exclude_file: json_validate_exclude.txt