-
Notifications
You must be signed in to change notification settings - Fork 1
/
tasks.py
61 lines (51 loc) · 1.34 KB
/
tasks.py
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
import os
import shutil
from pathlib import Path
from invoke import task
ROOT_FOLDER = Path(__file__).parent.absolute()
ATEST_OUTPUT = ROOT_FOLDER / "atest" / "output"
DIST_DIR = ROOT_FOLDER / "dist"
RUFF_CACHE = ROOT_FOLDER / ".ruff_cache"
PYTEST_CACHE = ROOT_FOLDER / ".pytest_cache"
MYPY_CACHE = ROOT_FOLDER / ".mypy_cache"
BUILD_DIR = ROOT_FOLDER / "build"
@task
def lint(ctx, fix=False):
in_ci = os.getenv("GITHUB_WORKFLOW")
print("Run mypy:")
ctx.run("mypy --exclude .venv .")
print("Run black:")
black_cmd = ["black", "."]
if in_ci:
black_cmd.insert(1, "--check")
ctx.run(" ".join(black_cmd))
print("Run ruff:")
ruff_cmd = "ruff check "
if fix:
ruff_cmd = f"{ruff_cmd} --fix"
ctx.run(ruff_cmd)
print(f"Lint Robot files {'in ci' if in_ci else ''}")
cmd = ["robotidy", "atest"]
if in_ci:
cmd.insert(1, "--check")
cmd.insert(1, "--diff")
ctx.run(" ".join(cmd))
@task
def utest(ctx):
ctx.run("python -m pytest .")
@task
def atest(ctx):
ctx.run("python -m robot -L debug --outputdir atest/output -P . atest")
@task
def clean(ctx):
for target in [
DIST_DIR,
ATEST_OUTPUT,
RUFF_CACHE,
PYTEST_CACHE,
MYPY_CACHE,
BUILD_DIR,
]:
print(target)
if target.exists():
shutil.rmtree(target)