Skip to main content

Tasks

jnc includes a cross-platform task runner. Define tasks in your manifest and run them with jnc run. Tasks execute inside the workspace environment with all dependencies available.

Defining tasks

Simple tasks

[tasks]
start = "python main.py"
lint = "ruff check ."
format = "ruff format ."

Tasks with options

Use the table format for more control:
[tasks.test]
cmd = "pytest tests/"
depends-on = ["build"]

[tasks.build]
cmd = "python -m build"

Running tasks

jnc run test
jnc run lint
You can also run arbitrary commands (not just defined tasks):
jnc run python -c "print('hello')"

Task dependencies

Tasks can depend on other tasks. Dependencies run first, in the correct order:
[tasks.build]
cmd = "make build"

[tasks.test]
cmd = "pytest"
depends-on = ["build"]

[tasks.ci]
depends-on = ["lint", "test"]
Running jnc run ci will execute lint and test (and their dependencies) before ci.

Environment-specific tasks

Tasks belong to features, so you can define tasks for specific environments:
[feature.test.tasks]
test = "pytest tests/ -v"

[feature.docs.tasks]
docs = "sphinx-build docs/ docs/_build"
Run them by targeting the environment:
jnc run --environment test test
jnc run --environment docs docs

Platform-specific tasks

Define tasks that only apply on certain platforms:
[target.linux-aarch64.tasks]
setup = "bash setup.sh"

Managing tasks with the CLI

jnc task add start "python main.py"          # Add a task
jnc task add test "pytest" --depends-on build # Add with dependency
jnc task remove start                         # Remove a task
jnc task list                                 # List all tasks
jnc task alias ci lint test                   # Create a task alias