Pipeline mini-project (tutorial)¶
This tutorial is a lightweight, CI-friendly walkthrough for “step-based” automation in Incan.
Prerequisite: Install, build, and run.
Goal¶
Write a small program that:
- defines a step-like function with typed inputs/outputs
- returns typed failures (
Result) - can be tested and run deterministically
Step 1: Create a file¶
Create this small project layout:
my_project/
├── pipeline_step.incn
└── tests/
└── test_pipeline_step.incn
Run the commands below from my_project/ (this matters for module resolution).
Create pipeline_step.incn:
"""
A tiny step-style function that validates input and returns a typed error.
"""
def normalize_name(name: str) -> Result[str, str]:
if len(name.strip()) == 0:
return Err("name must not be empty")
return Ok(name.strip().lower())
def main() -> None:
result = normalize_name(" Alice ")
match result:
case Ok(value): println(f"ok: {value}")
case Err(e): println(f"err: {e}")
Step 2: Run it¶
incan run pipeline_step.incn
No-install fallback
If you did not run make install, you can still run the incan binary directly:
- from the repository root:
./target/release/incan ...
- or via an absolute path (from anywhere):
/absolute/path/to/incan run path/to/file.incn
Step 3: Test it¶
Create tests/test_pipeline_step.incn:
from ..pipeline_step import normalize_name
from testing import assert_eq
def test_normalize_name_ok() -> None:
assert_eq(normalize_name(" Alice "), Ok("alice"))
def test_normalize_name_err() -> None:
assert_eq(normalize_name(" "), Err("name must not be empty"))
Run:
incan test tests/
Next¶
- Typed errors: Error Handling
- Multi-file layouts: Imports and modules (how-to)
- CI entrypoint: CI & automation
- Contributing CI entrypoints (repo): CI & automation (repository)