Cookbook
Qik CLI examples, common command definitions, and useful snippets.
CLI Examples
Watch Repo-Cached Commands
Run All Commands Serially
Check for Warm Cache for Specific Commands
Fail if Commands have Cold Cache
Run Commands Since main Branch
Show Output of Successful and Failed Commands
Cache All Finished Commands
Set the Default Cache
Common Command Definitions
Below are common command definitions. Note that we only provide basic dependencies in the examples. We also recommend to:
- Depend on your requirements file or the tool's PyPI distribution. See depending on distributions.
- Create a global dependency on the Python version.
Linting, Formatting, and Type Checking
Pyright Type Checking
[commands.check-types]
exec = "pyright {module.dir}"
deps = [{type = "module", name = "{module.name}"}]
cache = "repo"
Black Formatting
Flake8 Linting
Ruff Formatting and Linting
[commands.format]
exec = "ruff format {module.dir}"
deps = ["{module.dir}/**.py"]
cache = "repo"
[commands.lint]
exec = "ruff check {module.dir}"
deps = [
"{module.dir}/**.py",
{type = "command", name = "format"},
]
Locking Environments
Pip Tools
[commands.lock]
exec = "pip-compile > requirements.txt"
deps = ["requirements.in"]
artifacts = ["requirements.txt"]
Poetry
Building Documentation
MkDocs
[commands.build-docs]
exec = "mkdocs build"
deps = ["docs/**", "mkdocs.yml"]
artifacts = ["site/**"]
Sphinx
[commands.build-docs]
exec = "cd docs && make html"
deps = ["docs/**"]
artifacts = ["docs/build/**"]
Unit Tests
Pytest
Pytest with Coverage
[commands.test]
exec = "pytest {module.dir} --cov-report xml:{module.name}-coverage.xml"
deps = [{type = "module", name = "{module.name}"}]
artifacts = ["{module.name}-coverage.xml"]
Pytest with Django
In settings.py:
import os
# Ensure parallel runs name the DB based on the worker
DATABASES = {
"default": {
...,
"TEST": {
"NAME": f"test_db_name_{os.environ.get('QIK__WORKER')}"
}
}
}
Generating API Clients
Orval
[commands.generate-api-client]
exec = "python manage.py generate_openapi_spec > openapi.json && npm run orval"
deps = ["backend/**/api/**.py"]
cache = "repo"