[project]
name = "par-run"
version = "0.3.0"
description = "Parallel command runner"
license = "MIT"
authors = [
    { name = "Naz Quadri", email = "naz.quadri@gmail.com" }
]
classifiers = [
    'Development Status :: 4 - Beta',
    'Intended Audience :: Developers',
    'License :: OSI Approved :: MIT License',
    'Natural Language :: English',
    'Programming Language :: Python :: 3',
    'Programming Language :: Python :: 3.9',
    'Programming Language :: Python :: 3.10',
    'Programming Language :: Python :: 3.11',
    'Programming Language :: Python :: 3.12',
]
dependencies = [
    "pydantic>=2.0.0",
    "tomlkit>=0.12.4",
    "typer>=0.9.0",
    "rich>=13.0.0",
]
readme = "README.md"
requires-python = ">= 3.9"

[project.urls]
Homepage = "https://github.com/nazq/par-run"
Documentation = "https://github.com/nazq/par-run"
Repository = "https://github.com/nazq/par-run"
Issues = "https://github.com/nazq/par-run/issues"
Changelog = "https://github.com/nazq/par-run"

[project.optional-dependencies]
web = [
    "fastapi>=0.100.0",
    "uvicorn[standard]>=0.29.0",
    "jinja2>=3.0.0",
    "psutil>=5.9.0",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.rye]
managed = true
dev-dependencies = [
    "bump-my-version>=0.19.3",
    "httpx>=0.27.0",
    "ipython>=8.18.1",
    "mypy>=1.9.0",
    "pytest>=8.1.1",
    "pytest-asyncio>=0.23.6",
    "pytest-benchmark>=4.0.0",
    "pytest-cov>=5.0.0",
    "pytest-mock>=3.14.0",
    "pytest-random-order>=1.1.1",
    "ruff>=0.3.4",
    "twine>=5.0.0",
    "types-toml>=0.10.8.20240310",
    "types-psutil>=5.9.5.20240316",
]

[project.scripts]
"par-run" = "par_run.cli:cli_app"


[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.wheel]
packages = [
    "src/par_run",
    "static",
    "templates",
]

[tool.bumpversion]
current_version = "0.3.0"
commit = true
tag = true
tag_name = "{new_version}"
tag_message = "Version {new_version}"
message = "Bump version: {current_version} → {new_version}"
allow_dirty = true
parse = """(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"""
serialize = [
    "{major}.{minor}.{patch}"
]

[[tool.bumpversion.files]]
filename = "src/par_run/__init__.py"

[[tool.bumpversion.files]]
filename = "pyproject.toml"

[tool.ruff]
line-length = 120
indent-width = 4
target-version = "py39"

[tool.ruff.lint]
extend-select = [
    'Q',
    'B',
    'UP',
    'I',
    'F',
    'PTH',
    'PIE',
    'TID',
    'ERA',
    'ARG',
    'PL',
    #'ANN',
    'SIM',
    'PERF',
    'T20',
]
extend-ignore = ["S101", "FA100"]

[tool.ruff.lint.isort]
known-first-party = ["par_run"]


[tool.pytest.ini_options]
addopts = "--cov src --cov-report html:.reports/html --cov-report term --random-order -p no:warnings -v"
minversion = "8.0"
pythonpath = ["src", "py_tests"]
testpaths = "py_tests"
pythonfiles = "test_*.py"


[tool.par-run]
desc = "par-run from pyproject.toml"

[[tool.par-run.groups]]
name = "Formatting"
desc = "Code formatting commands."
timeout = 5
retries = 3 
cont_on_fail = true # default is false
serial = false # default is false

  [[tool.par-run.groups.commands]]
  name = "ruff_fmt"
  exec = "ruff format src py_tests"
  # Define an empty extras using standard table notation, or simply omit it if it's always empty

  [[tool.par-run.groups.commands]]
  name = "ruff_fix"
  exec = "ruff check --fix src py_tests"
  # Define an empty extras using standard table notation, or simply omit it if it's always empty


[[tool.par-run.groups]]
name = "Quality"
desc = "Code Quality Tools. No code mutation"
timeout = 5
retries = 3
cont_on_fail = true # default is false

  [[tool.par-run.groups.commands]]
  name = "ruff_lint"
  exec = "ruff check src py_tests"
  # extras omitted as it's empty

  [[tool.par-run.groups.commands]]
  name = "mypy"
  exec = "mypy src"
  setenv = {NODE_ENV = "production", ENABLE_LOGS = "true"}

  [[tool.par-run.groups.commands]]
  name = "pytest"
  exec = "pytest py_tests"
  setenv = {NODE_ENV = "production", ENABLE_LOGS = "true"}


[[tool.par-run.groups]]
name = "ENV"
desc = "Code Quality Tools. No code mutation"
timeout = 5
retries = 3
cont_on_fail = true # default is false


  [[tool.par-run.groups.commands]]
  name = "full_env"
  exec = "env"
  setenv = {MY_VAR = "production", ENABLE_LOGS = "true"}

  [[tool.par-run.groups.commands]]
  name = "my_var"
  exec = "echo \"MY_VAR=$MY_VAR\", \"ENABLE_LOGS=$ENABLE_LOGS\""
  setenv = {MY_VAR = "production", ENABLE_LOGS = "true"}


[[tool.par-run.groups]]
name = "Serial"
desc = "Must run serially"
timeout = 5
retries = 3
cont_on_fail = true # default is false
serial = true

  [[tool.par-run.groups.commands]]
  name = "sleep then create file"
  exec = "sleep 2 && touch /tmp/test.pr"

  [[tool.par-run.groups.commands]]
  name = "try delete file"
  exec = "rm /tmp/test.pr"
