84 lines
1.3 KiB
Markdown
84 lines
1.3 KiB
Markdown
# Task Automation
|
|
|
|
One entry point for all dev workflows — so you don't have to remember long commands or teach them to teammates.
|
|
|
|
## Tools by Language
|
|
|
|
| Language | Recommended | Alternatives |
|
|
|---|---|---|
|
|
| Python | `invoke` | make, tox |
|
|
| JavaScript/TS | `npm scripts`, `turbo` | nx |
|
|
| Go | `make`, `task` | mage |
|
|
| C++ | `cmake`, `make` | ninja |
|
|
|
|
## Python — `invoke`
|
|
|
|
Define tasks in `tasks.py`:
|
|
|
|
```python
|
|
from invoke import task
|
|
|
|
@task
|
|
def lint(c):
|
|
c.run("ruff check . && mypy .")
|
|
|
|
@task
|
|
def test(c):
|
|
c.run("pytest")
|
|
|
|
@task
|
|
def ci(c, lint=True, test=True):
|
|
if lint:
|
|
lint(c)
|
|
if test:
|
|
test(c)
|
|
```
|
|
|
|
```bash
|
|
invoke lint
|
|
invoke test
|
|
invoke ci
|
|
```
|
|
|
|
## Make (universal fallback)
|
|
|
|
Works everywhere, no install needed.
|
|
|
|
```makefile
|
|
.PHONY: lint test ci
|
|
|
|
lint:
|
|
ruff check . && mypy .
|
|
|
|
test:
|
|
pytest
|
|
|
|
ci: lint test
|
|
```
|
|
|
|
```bash
|
|
make ci
|
|
```
|
|
|
|
## JavaScript — npm scripts
|
|
|
|
```json
|
|
{
|
|
"scripts": {
|
|
"lint": "biome check .",
|
|
"test": "vitest run",
|
|
"ci": "npm run lint && npm run test"
|
|
}
|
|
}
|
|
```
|
|
|
|
```bash
|
|
npm run ci
|
|
```
|
|
|
|
## Tips
|
|
|
|
- Keep task names consistent across projects (`lint`, `test`, `ci`, `build`)
|
|
- Tasks should call your other tools — they're orchestration, not implementation
|
|
- `make` is the lowest common denominator; use it when portability matters
|