|
1 | | -"""Code quality tasks (linting, formatting, type checking).""" |
| 1 | +"""Code quality tasks (linting, formatting, type checking, testing).""" |
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
|
9 | 9 | if TYPE_CHECKING: |
10 | 10 | from invoke.context import Context |
11 | 11 |
|
| 12 | +from dev.utils import logging_utils |
| 13 | + |
| 14 | + |
| 15 | +@task(name="lint") |
| 16 | +@logging_utils.with_banner() |
| 17 | +def lint(ctx: Context) -> None: |
| 18 | + """Run linting and type checking (no fixes) - for CI.""" |
| 19 | + logging_utils.print_info("Running ruff check...") |
| 20 | + ctx.run("uv run ruff check") |
| 21 | + |
| 22 | + logging_utils.print_info("Running ruff format check...") |
| 23 | + ctx.run("uv run ruff format --check") |
| 24 | + |
| 25 | + logging_utils.print_info("Running ty check...") |
| 26 | + ctx.run("uv run ty check src dev tests") |
| 27 | + |
| 28 | + logging_utils.print_info("Running actionlint...") |
| 29 | + ctx.run("uv run actionlint") |
| 30 | + |
| 31 | + logging_utils.print_success("All checks passed") |
| 32 | + |
12 | 33 |
|
13 | 34 | @task(name="format") |
14 | 35 | def format_and_check(c: Context) -> None: |
15 | | - """Format code using ruff and run type checking.""" |
| 36 | + """Format code using ruff and run type checking - for local dev.""" |
16 | 37 | c.run("uv run ruff check src dev --fix --unsafe-fixes") |
17 | 38 | c.run("uv run ruff format src dev") |
18 | 39 | c.run("uv run ty check src dev") |
19 | 40 | # Verify environment_control package is Python 3.9 compatible |
20 | 41 | c.run("uv run vermin -t=3.9 --eval-annotations --no-tips packages/environment_control/environment_control/") |
| 42 | + |
| 43 | + |
| 44 | +@task(name="test") |
| 45 | +@logging_utils.with_banner() |
| 46 | +def run_tests(ctx: Context, docker_img: str = "webarena-verified:test") -> None: |
| 47 | + """Run tests. |
| 48 | +
|
| 49 | + Args: |
| 50 | + docker_img: Docker image to use for tests. |
| 51 | + """ |
| 52 | + logging_utils.print_info("Building Docker image...") |
| 53 | + ctx.run(f"docker build -t {docker_img} .") |
| 54 | + |
| 55 | + logging_utils.print_info("Running tests...") |
| 56 | + ctx.run( |
| 57 | + f"uv run pytest --webarena-verified-docker-img {docker_img} " |
| 58 | + "--ignore=tests/integration/environment_control/ " |
| 59 | + "--ignore=tests/integration/environments/" |
| 60 | + ) |
| 61 | + |
| 62 | + logging_utils.print_success("All tests passed") |
0 commit comments