// OxygenHub's pipeline (OxygenFlow, docs in the oxygenflow repository).
// Every push to a bookmark on OxygenHub runs it in Firecracker microVMs on
// Earth; the jobs appear as checks on the change. oxygen and oxygenflow come
// from the pinned subrepos in deps/, which the runner puts in the workspace.
schema-version 1

// The OxygenFlow build image: Rust with rustfmt and clippy, Node, every
// crate of Cargo.lock vendored, and this workspace's dependencies prebuilt
// in /opt/warm/oxygenhub, which .flow/warm-target.sh copies onto a job's
// target disk (oxygenflow/images/rust). Rebuild and re-pin it when
// Cargo.lock changes; until then only the changed crates are compiled.
sandbox "rust" {
    runtime "microvm"
    rootfs "cas://blob/9d76e1aef3ab096c57dfdab6ed2cfb4de1dc70e67ca0e7f299e087f7abb7e61a"
    memory-limit "8GiB"
    cpu-limit 4
    // Tests serve and connect on 127.0.0.1; nothing leaves the guest.
    network "loopback"
}

sandbox "rust-small" {
    runtime "microvm"
    rootfs "cas://blob/9d76e1aef3ab096c57dfdab6ed2cfb4de1dc70e67ca0e7f299e087f7abb7e61a"
    memory-limit "1GiB"
    cpu-limit 1
    network "isolated"
}

job "fmt" {
    sandbox "rust-small"
    // Only this workspace's packages: --all would also check the path
    // dependencies in deps/, which follow their own formatting.
    exec "cargo" "fmt" "--check" "-p" "oxygenhub" "-p" "hub-api" "-p" "oh"
}

job "clippy" {
    sandbox "rust"
    depends-on "fmt"
    mount {
        source "ephemeral://disk"
        target "/src/target"
        size "24GiB"
    }
<<<<<<< oxy conflict 1 of 2, side 1 of 2: change 6532b323 "oxygen and oxygenflow as pinned subrepos in deps/ (make pins moves them), and an OxygenFlow pipeline: fmt of this workspace, then clippy, tests and a release build against the pins"
    env {
        CARGO_INCREMENTAL "0"
    }
======= oxy conflict 1 of 2, side 2 of 2: change bce3997c "CI starts from the build image's prebuilt dependencies"
    exec "sh" ".flow/warm-target.sh" "cargo" "clippy" "--workspace" "--all-targets" "--locked" "--" "-D" "warnings"
>>>>>>> oxy conflict 1 of 2 end
}

job "test" {
    sandbox "rust"
    depends-on "fmt"
    mount {
        source "ephemeral://disk"
        target "/src/target"
        size "24GiB"
    }
<<<<<<< oxy conflict 2 of 2, side 1 of 2: change 6532b323 "oxygen and oxygenflow as pinned subrepos in deps/ (make pins moves them), and an OxygenFlow pipeline: fmt of this workspace, then clippy, tests and a release build against the pins"
    env {
        CARGO_INCREMENTAL "0"
    }
======= oxy conflict 2 of 2, side 2 of 2: change bce3997c "CI starts from the build image's prebuilt dependencies"
    exec "sh" ".flow/warm-target.sh" "cargo" "test" "--workspace" "--locked"
>>>>>>> oxy conflict 2 of 2 end
}

job "build" {
    sandbox "rust"
    depends-on "fmt"
    mount {
        source "ephemeral://disk"
        target "/src/target"
        size "24GiB"
    }
    env {
        CARGO_INCREMENTAL "0"
    }
    exec "sh" ".flow/warm-target.sh" "cargo" "build" "--release" "--locked"
}
