-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from invoke import Collection, Program | ||
from . import make | ||
from . import tasks | ||
|
||
namespace = Collection() | ||
namespace.add_task(tasks.test) | ||
namespace.add_task(tasks.serve) | ||
namespace.add_collection(Collection.from_module(make)) | ||
program = Program(namespace = namespace) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import sys | ||
|
||
import invoke | ||
|
||
from . import tasks | ||
|
||
|
||
@invoke.task | ||
def clean(context): | ||
"""Delete builds and compiled python files.""" | ||
|
||
info(clean) | ||
|
||
context.run("rm -rf build dist") | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
benjello
Member
|
||
context.run("find . -name '*.pyc' | xargs rm -f") | ||
|
||
|
||
@invoke.task | ||
def check_syntax_errors(context): | ||
"""Compile python files to check for syntax errors.""" | ||
|
||
info(check_syntax_errors) | ||
|
||
context.run("python -m compileall -q .") | ||
|
||
|
||
@invoke.task | ||
def check_style(context): | ||
"""Run linters to check for syntax and style errors.""" | ||
|
||
info(check_style) | ||
|
||
context.run("flake8 openfisca_core openfisca_web_api") | ||
|
||
|
||
@invoke.task | ||
def format_style(context): | ||
"""Run code formatters to correct style errors.""" | ||
|
||
info(format_style) | ||
|
||
context.run("autopep8 openfisca_core openfisca_web_api") | ||
|
||
|
||
@invoke.task | ||
def check_types(context): | ||
"""Run static type checkers for type errors.""" | ||
|
||
info(check_types) | ||
|
||
context.run("mypy openfisca_core openfisca_web_api") | ||
|
||
|
||
@invoke.task | ||
def test(context, workers = None): | ||
"""Run openfisca-core tests.""" | ||
|
||
info(test) | ||
|
||
path = context.run("git ls-files 'tests/*.py'", hide = "out").stdout | ||
sys.argv = sys.argv[0:1] + ["test"] + path.split() | ||
tasks.test(context, path) | ||
|
||
|
||
@invoke.task | ||
def api(context): | ||
"""Serve the openfisca Web API.""" | ||
|
||
sys.argv[1] = "serve" | ||
|
||
tasks.serve( | ||
context, | ||
"openfisca_country_template", | ||
"openfisca_extension_template", | ||
) | ||
|
||
def info(func): | ||
doc = func.__doc__.split('\n')[0] | ||
print(f"[⚙] {doc}..") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import os | ||
import sys | ||
|
||
import invoke | ||
|
||
from openfisca_core.scripts import openfisca_command | ||
from openfisca_core.scripts.run_test import main as _test | ||
from openfisca_web_api.scripts.serve import main as _serve | ||
|
||
@invoke.task( | ||
help = { | ||
"path": "Paths (files or directories) of tests to execute.", | ||
}, | ||
) | ||
def test(_, path, workers = None): | ||
"""Run OpenFisca tests. | ||
Examples: | ||
$ openfica test "$(git ls-files 'tests/**/*.py')" | ||
""" | ||
|
||
# Pseudo-implementation of `openfisca test` | ||
sys.argv = sys.argv[0:2] + path.split() | ||
_test(openfisca_command.get_parser()) | ||
|
||
|
||
@invoke.task( | ||
optional = ["extensions"], | ||
help = { | ||
"country-package": "Country package to use.", | ||
"extensions": "Extensions to load.", | ||
}, | ||
) | ||
def serve(_, country_package, extensions = None): | ||
"""Run the OpenFisca Web API. | ||
Examples: | ||
$ openfica serve --country-package openfisca_country_template | ||
""" | ||
|
||
# Pseudo-implementation of `openfisca serve` | ||
_serve(openfisca_command.get_parser()) |
1 comment
on commit fcf7def
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way @benoit-cty this could be an inspiration for the pure-python parallelism: https://github.com/PyCQA/flake8/blob/281f3f8b43106023bf3fb160666384394031a9fd/src/flake8/checker.py
Does it work on Windows ?