Command line automation tool in pure Python
- Describe jobs as tables/dictionaries in a config file called 'detox' (choose between .toml, .yaml or .json format).
(Put the config inside the root directory of your project)
# detox.toml
[test]
description = "test project"
dependencies = ["pytest", "pytest-cov"]
commands = "pytest -vv --disable-warnings -s --cache-clear"
# detox.yaml
test:
description: test project
dependencies:
- pytest
- pytest-cov
commands:
- pytest -vv --disable-warnings -s --cache-clear
- description and dependencies could be optional but not commands
# detox.toml
[no-deps]
commands = "echo 'Hello world'"
(in json)
"no-deps": {
"commands": "echo 'Hello world'"
}
- dependencies and commands could be strings or (in case of more than one) a list of strings
# detox.toml
commands = ["ruff check --fix", "ruff format --line-length=100 ."]
# detox.yaml
commands:
- ruff check --fix
- ruff format --line-length=100 .
- You could provide a [run] table inside the config file with a 'suite' - list of selected jobs to run
[run]
suite = ["lint", "format", "test"]
"run": {
"suite": [
"lint",
"format",
"test",
"no-deps"
]
}
- Run the tool in the terminal with a simple 'detox' command
$ detox
(logs omitted...)
$ All jobs succeeded! ['lint', 'format', 'test']
Detoxing took: 14.088007061000098
- In case of failing jobs you get general stats
(logs omitted...)
$ Unsuccessful detoxing took: 13.532951637999759
Failed jobs: ['format']
Successful jobs: ['lint', 'test']
or
$ Unsuccessful detoxing took: 8.48367640699962
Failed jobs: ['format']
Successful jobs: ['lint']
Skipped jobs: ['test']
- You could run specific jobs in the command line
$ detox -j lint
or a list of jobs
$ detox -j lint format
NB: If there is a 'run' table in the config file the jobs specified in the command line take precedence