Check pre-commit verison updates
This commit is contained in:
parent
86b3aac9ba
commit
6d576bc02d
21
.github/workflows/ci.yml
vendored
21
.github/workflows/ci.yml
vendored
@ -265,6 +265,21 @@ jobs:
|
|||||||
details: Test Failed
|
details: Test Failed
|
||||||
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
|
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
|
|
||||||
|
mypy_version_check:
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v3
|
||||||
|
with:
|
||||||
|
python-version: 3.9
|
||||||
|
|
||||||
|
- name: pre-commit dependencies
|
||||||
|
run: |
|
||||||
|
pip install pyaml
|
||||||
|
python build_helpers/pre_commit_update.py
|
||||||
|
|
||||||
docs_check:
|
docs_check:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
@ -277,7 +292,7 @@ jobs:
|
|||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v3
|
uses: actions/setup-python@v3
|
||||||
with:
|
with:
|
||||||
python-version: 3.8
|
python-version: 3.9
|
||||||
|
|
||||||
- name: Documentation build
|
- name: Documentation build
|
||||||
run: |
|
run: |
|
||||||
@ -304,7 +319,7 @@ jobs:
|
|||||||
|
|
||||||
# Notify only once - when CI completes (and after deploy) in case it's successfull
|
# Notify only once - when CI completes (and after deploy) in case it's successfull
|
||||||
notify-complete:
|
notify-complete:
|
||||||
needs: [ build_linux, build_macos, build_windows, docs_check ]
|
needs: [ build_linux, build_macos, build_windows, docs_check, mypy_version_check ]
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
@ -325,7 +340,7 @@ jobs:
|
|||||||
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
|
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
needs: [ build_linux, build_macos, build_windows, docs_check ]
|
needs: [ build_linux, build_macos, build_windows, docs_check, mypy_version_check ]
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
|
|
||||||
if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'release') && github.repository == 'freqtrade/freqtrade'
|
if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'release') && github.repository == 'freqtrade/freqtrade'
|
||||||
|
@ -11,6 +11,13 @@ repos:
|
|||||||
rev: "v0.942"
|
rev: "v0.942"
|
||||||
hooks:
|
hooks:
|
||||||
- id: mypy
|
- id: mypy
|
||||||
|
args: [ freqtrade ]
|
||||||
|
additional_dependencies:
|
||||||
|
- types-cachetools==5.0.1
|
||||||
|
- types-filelock==3.2.5
|
||||||
|
- types-requests==2.27.19
|
||||||
|
- types-tabulate==0.8.7
|
||||||
|
- types-python-dateutil==2.8.11
|
||||||
# stages: [push]
|
# stages: [push]
|
||||||
|
|
||||||
- repo: https://github.com/pycqa/isort
|
- repo: https://github.com/pycqa/isort
|
||||||
|
42
build_helpers/pre_commit_update.py
Normal file
42
build_helpers/pre_commit_update.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# File used in CI to ensure pre-commit dependencies are kept uptodate.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
|
||||||
|
pre_commit_file = Path('.pre-commit-config.yaml')
|
||||||
|
require_dev = Path('requirements-dev.txt')
|
||||||
|
|
||||||
|
with require_dev.open('r') as rfile:
|
||||||
|
requirements = rfile.readlines()
|
||||||
|
|
||||||
|
# Extract types only
|
||||||
|
type_reqs = [r.strip('\n') for r in requirements if r.startswith('types-')]
|
||||||
|
|
||||||
|
with pre_commit_file.open('r') as file:
|
||||||
|
f = yaml.load(file, Loader=yaml.FullLoader)
|
||||||
|
|
||||||
|
|
||||||
|
mypy_repo = [repo for repo in f['repos'] if repo['repo']
|
||||||
|
== 'https://github.com/pre-commit/mirrors-mypy']
|
||||||
|
|
||||||
|
hooks = mypy_repo[0]['hooks'][0]['additional_dependencies']
|
||||||
|
|
||||||
|
errors = []
|
||||||
|
for hook in hooks:
|
||||||
|
if hook not in type_reqs:
|
||||||
|
errors.append(f"{hook} is missing in requirements-dev.txt.")
|
||||||
|
|
||||||
|
for req in type_reqs:
|
||||||
|
if req not in hooks:
|
||||||
|
errors.append(f"{req} is missing in pre-config file.")
|
||||||
|
|
||||||
|
|
||||||
|
if errors:
|
||||||
|
for e in errors:
|
||||||
|
print(e)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
sys.exit(0)
|
Loading…
Reference in New Issue
Block a user