Adds a declarative workflow system where .ontology/workflow.ncl declares
independent layers (commit-fast, ci-standard, ci-exhaustive), each with a
trigger and a set of providers. The generator materialises Woodpecker YAML,
justfile recipes, and pre-commit hook stubs from that single declaration.
Layers form a set, not a chain — no layer depends on another at the
declaration level. Woodpecker steps express fine-grained parallelism
internally (lint → test/docs/build).
Schema and catalog:
- reflection/schemas/workflow.ncl — types, contracts, provider constructors
- reflection/defaults/workflow.ncl — standard Rust/Nushell/Nickel catalog
(14 validations, 4 builds)
Generator (ore workflow generate):
- PreCommit: prints hook fragments for manual merge into .pre-commit-config.yaml
- Woodpecker: writes per-layer YAML with image selection, tool installs,
depends_on chains, and CI-aware command translation
(nu --ide-check → find+xargs; markdownlint-cli2 → node:lts image)
- Justfile: single justfiles/workflow.just aggregated from all Justfile layers
(hoisted out of per-provider loop — was writing N times, now once)
Dispatcher: ore workflow validate|list|generate|diff + ore wf v|l|gen|diff
Cargo/nextest profiles:
- .cargo/config.toml: [profile.ci-test] (debug=0, no-incremental) and
[profile.ci] (line-tables-only) — shared by test + docs hooks to reuse
.rlib artifacts; CI retains actionable backtraces
- .config/nextest.toml: ci-test (fail-fast, no retries) and ci (all failures,
one retry)
Pre-commit: nextest run with --profile ci-test --cargo-profile ci-test;
docs-links hook shares same profile to reuse artifacts
Self-application: ontoref declares its own workflow in .ontology/workflow.ncl
and the generated .woodpecker/ files are the authoritative CI definition
Migration 0014: checks workflow.ncl + both cargo and nextest profiles present
Adoption: reflection/templates/ontology/workflow.ncl stub + install_workflow
confirm in adopt_ontoref form + step 5 in adoption script template
100 lines
4.4 KiB
Text
100 lines
4.4 KiB
Text
let layer_trigger = [|
|
|
'OnCommit, # pre-commit (git) / jjw pre-op check (jj)
|
|
'OnPush, # pre-push (git) / rad patch submit (radicle)
|
|
'OnPR, # pull_request on remote CI
|
|
'OnMainMerge, # push to trunk/main branch
|
|
'OnTag, # semver tag event
|
|
'OnManual, # explicit user/agent trigger
|
|
|] in
|
|
|
|
let validation_kind = [| 'Lint, 'Test, 'Security, 'Compliance, 'Docs |] in
|
|
|
|
let build_kind = [| 'Binary, 'Library, 'Container, 'Docs, 'SBOM |] in
|
|
|
|
let distribution_kind = [| 'CargoRegistry, 'ContainerRegistry, 'Package, 'Artifact |] in
|
|
|
|
# Validation spec — tool invocation, VCS/provider agnostic.
|
|
# The generator translates this into provider-specific syntax.
|
|
let validation_spec = {
|
|
id | String | default = "",
|
|
kind | validation_kind | default = 'Lint,
|
|
tool | String | default = "",
|
|
args | Array String | default = [],
|
|
when | Array String | default = [], # glob patterns; empty = always run
|
|
fail_fast | Bool | default = true,
|
|
cargo_profile | String | default = "", # "" if not applicable
|
|
} in
|
|
|
|
# Build spec — artifact production, VCS/provider agnostic.
|
|
let build_spec = {
|
|
id | String | default = "",
|
|
kind | build_kind | default = 'Binary,
|
|
tool | String | default = "",
|
|
args | Array String | default = [],
|
|
cargo_profile | String | default = "",
|
|
target | String | default = "", # cargo target triple; "" = native
|
|
artifacts | Array String | default = [], # expected output paths
|
|
} in
|
|
|
|
# Distribution spec — where to send artifacts after build.
|
|
let distribution_spec = {
|
|
id | String | default = "",
|
|
kind | distribution_kind | default = 'Artifact,
|
|
tool | String | default = "",
|
|
args | Array String | default = [],
|
|
destination | String | default = "",
|
|
} in
|
|
|
|
# A workflow layer is an independent, self-contained set of operations.
|
|
# Layers do NOT depend on each other — they form a set, not a chain.
|
|
# A workspace may activate any combination of layers independently.
|
|
let workflow_layer = {
|
|
id | String | default = "",
|
|
trigger | layer_trigger | default = 'OnManual,
|
|
validations | Array String | default = [], # IDs from the active validations catalog
|
|
builds | Array String | default = [], # IDs from the active builds catalog
|
|
distributions | Array String | default = [], # IDs from the active distributions catalog
|
|
|
|
# Provider implementations enabled for this layer.
|
|
# Each provider generates a different artifact from the same layer declaration.
|
|
# Use the ProviderImpl helpers below to construct typed provider records.
|
|
providers | Array { tag | String, .. } | default = [],
|
|
} in
|
|
|
|
# Complete workflow declaration for a workspace.
|
|
# Workspaces import defaults/workflow.ncl and extend/override as needed.
|
|
let workflow_declaration = {
|
|
layers | Array workflow_layer | default = [],
|
|
validations | { _ | validation_spec } | default = {},
|
|
builds | { _ | build_spec } | default = {},
|
|
distributions | { _ | distribution_spec } | default = {},
|
|
} in
|
|
|
|
# ── Provider constructor helpers ──────────────────────────────────────────────
|
|
# Use these to build the providers array in WorkflowLayer.
|
|
|
|
let mk_pre_commit = fun s => { tag = "PreCommit", stage = s } in
|
|
let mk_woodpecker = fun f => { tag = "Woodpecker", file = f } in
|
|
let mk_github_actions = fun f => { tag = "GithubActions", file = f } in
|
|
let mk_justfile = fun r => { tag = "Justfile", recipe = r } in
|
|
let mk_jjw_wrapper = { tag = "JjwWrapper" } in
|
|
|
|
{
|
|
# Types / contracts — use as field contracts: `field | W.WorkflowLayer`
|
|
LayerTrigger = layer_trigger,
|
|
ValidationKind = validation_kind,
|
|
BuildKind = build_kind,
|
|
DistributionKind = distribution_kind,
|
|
ValidationSpec = validation_spec,
|
|
BuildSpec = build_spec,
|
|
DistributionSpec = distribution_spec,
|
|
WorkflowLayer = workflow_layer,
|
|
WorkflowDeclaration = workflow_declaration,
|
|
|
|
# Provider constructors — use in `providers = [W.pre_commit "pre-commit", ...]`
|
|
pre_commit = mk_pre_commit,
|
|
woodpecker = mk_woodpecker,
|
|
github_actions = mk_github_actions,
|
|
justfile = mk_justfile,
|
|
jjw_wrapper = mk_jjw_wrapper,
|
|
}
|