-
Notifications
You must be signed in to change notification settings - Fork 0
DSL Patterns
Leonard Ramminger edited this page Aug 9, 2026
·
1 revision
Reusable patterns for common build.lua designs.
beez.config(require("config"))
local function env_or(key, default)
local value = beez.env(key)
if value == nil then
return default
end
return value
end
local BUILD_TYPE = env_or("BUILD_TYPE", "Release")
local BUILD_DIR = "build/" .. BUILD_TYPEUse locals when many steps share the same paths or flags.
Pattern for lint, format-check, or analyze tools that run per source file:
configure_step("lint", {
patterns = { "src/**/*.cpp" },
lint_rev = "1",
})
step({
name = "lint",
phase = "qa",
scope = "default",
mutate = { "src/**/*.cpp" },
run = function(ctx)
local config = ctx.get_config()
local files = ctx.glob(config.patterns)
local failed = 0
for _, path in ipairs(files) do
if ctx.file_success_cached(path) then
goto continue
end
local job = ctx:spawn({
name = "lint-" .. path,
cmd = "clang-tidy " .. path,
})
local code = ctx:wait(job)
if code ~= 0 then
ctx.record_file_cache_miss(path)
failed = failed + 1
else
ctx.cache_file_success(path)
end
::continue::
end
return failed > 0 and 1 or 0
end,
})Key points:
-
lint_revin config: bump when tool config changes -
mutateon step: marks files the step touches (ordering + semantics) -
record_file_cache_miss/cache_file_success: track per-file state - Workers: parallel lint per file
Minimal project without Lua callbacks:
step({
name = "configure",
phase = "build",
scope = "default",
run = "cmake -B build",
})
step({
name = "compile",
phase = "build",
scope = "default",
run = "cmake --build build",
})
order("configure", "compile")
workflow("build", {
{ phase = "build", scope = "default" },
})
task("clean", "rm -rf build")Add input/output globs when you want step caching.
When you do not need phase grouping:
task("ci", {
{ name = "configure" },
{ name = "compile" },
{ name = "test" },
})Sequential only. For parallel phase+scope blocks, use a workflow.
Keep build.lua readable:
config.lua
return {
cache = { path = ".cache" },
env = { vars = { BUILD_TYPE = "Release" } },
}build.lua
beez.config(require("config"))
-- steps, workflows, tasks ...When a QA tool changes but sources do not, bump a revision in step config:
configure_step("format", { format_rev = "2" })
configure_step("lint", { lint_rev = "3" })This invalidates success cache entries that depend on config fingerprint.
local CXX_PATTERNS = {
"src/**/*.cpp",
"include/**/*.hpp",
}
configure_step("lint", { patterns = CXX_PATTERNS })
configure_step("format", { patterns = CXX_PATTERNS })| Need | Use |
|---|---|
| One shell command | task("x", "cmd") |
| Fixed step chain | task("x", { ... }) |
| Phase groups + parallel scopes | workflow() |
| Per-file incremental tool | Lua callback + success cache |
| Parallel shell in one step |
ctx:spawn / ctx:wait_all
|
| Skip unchanged build steps |
input / output on shell steps |
- First Pipeline - tutorial
- Configure Step - config merge rules
- Caching
Quick Reference · Glossary · FAQ
- Fundamentals
- Core Concepts
- Project Layout
- First Pipeline
- Phases and Scopes
- How Phases and Scopes Work
- Selecting with Phases and Scopes
- Designing Phases and Scopes
- Parallel Execution and Dependencies
- Configuration
- Configuration Overview
- Global User Config
- Project Config
- Environment Variables
- Performance Settings
- Cache Settings
- Config Reference
- CLI
- CLI Overview
- Running Targets
- Filtering by Phase
- Running a Single Step
- Listing Entities
- Output and Logging Flags
- Cache and Maintenance Flags
- Meta and Utility Commands
-
Project Scaffolding —
beez --init(embedded Tempify) - CLI Flag Reference
- Lua DSL
- DSL Overview
- Plugin System — Plugins, Config DSL, Standard-Workflows
- Step Declaration
- Task Declaration
- Workflow Declaration
- Order Declaration
- Configure Step
- ReqPack Declaration
- Beez API
- Step Context
- DSL Patterns
- Caching
- Caching Overview
- Step Cache
- Success Cache
- Glob Metadata Cache
- Artifact Patterns
- Cache Keys and Invalidation
- Cache Storage and Maintenance
- Caching Troubleshooting
- UI and Output
- Output Modes
- Progress and Animation
- Colors and Themes
- Run Summaries
- Logging and Log Files
- Development and Contribution
- Building and Setup
- Repository Layout
- Testing
- Code Quality
- Feature Development Workflow
- Submitting Changes