stav 0.2.0

A statically typed, eager and total configuration language
Documentation
---
source: crates/stav/tests/format.rs
expression: formatted
---
## Kinds of jobs.
type Kind = build | test | deploy
type Step =
  | shell(script: Str, shell: Str = "/bin/sh")
  | upload(path: Path, bucket: Str)
  | notify(channel: Str, mention: List<Str> = [], quiet: Bool = false, retries: Int where 0..=5 = 0)
struct Job {
  ## What the job does.
  kind:            Kind = build
  steps:           List<Step> = []
  timeout_seconds: Int where 1..=86400 = 3600
  env:             Map<Str, Str> = {}
}
struct Root { jobs: Map<Str, Job> = {} block job }
fn shell(script: Str) -> Step = Step.shell(script = script)
fn retries(kind: Kind) -> Int = match kind {
  build  => 1
  test   => 2
  deploy => 0
}
fn tag(name: Str, n: Int) -> Str =
  let prefix = if n > 0 { "v" } else { "dev-" },
      padded = if n < 10 { "0#{n}" } else { "#{n}" }
  in "#{prefix}#{name}-#{padded}"
job lint { kind = test, steps = [shell("tool lint --strict")] }
job release {
  kind  = deploy
  steps = [
    shell("tool build --release"),
    Step.upload(path = ./target/release/tool, bucket = "artifacts"),
    Step.notify(channel = "#releases"),
  ]
}