mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 00:14:41 +01:00

* chore (ci): improve elm job speed by caching * chore (ci): update ci generator script to be run from any dir * chore: update pre-commit to use local black binary * chore: mypy config skip amalgam generated modules * chore: run-tests.xsh parameterisation use argparser to make this file a cli * feat: use requirements.txt during CI * feat: run black/flake8/mypy during ci from pip-env * chore: mypy version 0.790 fix since the loose pinning on mypy version causes new PRs to fail * refactor: update github actions template remove poetry/environment.yml files
72 lines
1.6 KiB
Python
Executable file
72 lines
1.6 KiB
Python
Executable file
#!/usr/bin/env xonsh
|
|
import argparse
|
|
from typing import List
|
|
|
|
|
|
$RAISE_SUBPROC_ERROR = True
|
|
|
|
|
|
def _replace_args(args:List[str], num:int) -> List[str]:
|
|
return [
|
|
(arg % num) if "%d" in arg else arg
|
|
for arg in args
|
|
]
|
|
|
|
|
|
def test(ns: argparse.Namespace):
|
|
"""Run pytest.
|
|
|
|
Examples
|
|
--------
|
|
`xonsh run-tests.xsh -- --junitxml=junit/test-results.%%d.xml`
|
|
"""
|
|
|
|
run_separately = [
|
|
'tests/test_main.py',
|
|
'tests/test_ptk_highlight.py',
|
|
]
|
|
|
|
ignores = []
|
|
for fname in run_separately:
|
|
ignores.append('--ignore')
|
|
ignores.append(fname)
|
|
|
|
args = ns.args if "arg" in ns else []
|
|
|
|
![pytest @(_replace_args(args, 0)) @(ignores)]
|
|
for index, fname in enumerate(run_separately):
|
|
![pytest @(_replace_args(args, index+1)) @(fname)]
|
|
|
|
|
|
def qa(ns: argparse.Namespace):
|
|
"""QA checks"""
|
|
|
|
echo "---------- Check Black formatter -----------"
|
|
black --check xonsh xontrib
|
|
|
|
echo "---------- Running flake8 ----------"
|
|
python -m flake8
|
|
|
|
echo "---------- Running mypy ----------"
|
|
mypy --version
|
|
mypy xonsh
|
|
|
|
|
|
if __name__ == '__main__':
|
|
parser = argparse.ArgumentParser()
|
|
commands = parser.add_subparsers()
|
|
|
|
test_parser = commands.add_parser('test', help=test.__doc__)
|
|
test_parser.add_argument(
|
|
'pytest_args',
|
|
nargs='*',
|
|
help="arbitrary arguments that gets passed to pytest's invocation."
|
|
" Use %%d to parameterize and prevent overwrite "
|
|
)
|
|
test_parser.set_defaults(func=test)
|
|
|
|
qa_parser = commands.add_parser('qa', help=qa.__doc__)
|
|
qa_parser.set_defaults(func=qa)
|
|
|
|
args = parser.parse_args()
|
|
args.func(args)
|