Composable build tool inspired by Nox, Make & cargo-make
Rox gives you the ability to build your own devtools CLI using YAML files. Tasks and Pipelines are dynamically added to the CLI as subcommands at runtime. The flexibility of rox
intends to makes it easier for dev teams to standardize their workflows without writing endless "glue" scripts.
The subcommands and their help messages are automatically populated at runtime from the name
and description
of each task
.
See gameslog for an example of usage in a real project.
Rox can be installed via binaries provided with each release here. As an alternative, it can also be installed via cargo
with cargo install rox-cli
.
Rox requires that a roxfile.yml
exists in the directory where the command is run. This is typically the root directory of the repo.
Version Requirements are used to ensure that any required CLI tool matches your specified version requirements.
```yaml versionrequirements: - command: "docker version --format {{.Client.Version}}" # Output: 20.10.23 minimumversion: "20.10.7" maximum_version: "21.0.0"
File Requirements ensure that certain expected files are present.
```yaml file_requirements: - path: "Cargo.toml"
Templates allow you to specify templated commands that can be reused by tasks
. Values are injected positionally. These are intended to facilitate code reuse and uniformity across similar but different commands.
yaml
templates:
- name: docker_build
command: "docker build {path} -t rox:{image_tag}"
symbols: ["{path}", "{image_tag}"]
Tasks are discrete units of execution. They're intended to be single shell commands that can then be composed via pipelines
. They are also able to leverage templates
by specifying one with uses
and injecting values with values
.
```yaml tasks: - name: build-prod description: "Build the application dockerfile" uses: docker_build values: [".", "latest"]
Pipelines are the canonical way to chain together multiple tasks into a single unit of execution. They also support parallel execution with the -p
flag but it is up to the user to ensure that the tasks can be safely executed in parallel.
yaml
pipelines:
- name: example-pipeline
description: Composes a few tasks
tasks: ["task-a", "task-b", "task-c"]
Now that we've seen each individual piece of the Rox puzzle, we can put them all together into a full roxfile
.
```yaml versionrequirements: - command: "docker version --format {{.Client.Version}}" minimumversion: "20.10.7" maximum_version: "21.0.0"
filerequirements: - path: ".env" createifnotexists: true
templates: - name: dockerbuild command: "docker build {path} -t rox:{imagetag}" symbols: ["{path}", "{image_tag}"]
pipelines: - name: build-all description: "Build a release artifact binary and Docker image" tasks: ["build-release-binary", "build-release-image"]
tasks:
# Docker-related - name: build-local description: "Build the application dockerfile" uses: docker_build values: [".", "local"]
name: build-prod description: "Build the application dockerfile" uses: docker_build values: [".", "latest"]
name: "clippy-ci" description: "Run Clippy with a non-zero exit if warnings are found." command: "cargo clippy -- -D warnings"
name: fmt command: "cargo fmt"
name: test command: "cargo test" description: "Run tests"
name: build-release-binary description: "Build a release binary with cargo." command: "cargo build --release"
name: build-release-image description: "Build a production image for Docker." command: "docker build . -t rox:latest"
name: secret_task description: "This task isn't callable directly from the CLI, but is available to pipelines!" hide: true
```
The following are command-line examples for running rox
with various flags and subcommands.
Show Tasks/Pipelines:
sh
rox task
sh
rox pl
https://github.com/ThomasLaPiana/rox/assets/5105354/2041522d-4cb2-4c96-9655-c1802fdf16c8
Run a Task:
sh
rox task build-binary
https://github.com/ThomasLaPiana/rox/assets/5105354/9f152b3b-8a65-4409-af5c-da029c3e8ae4
Run a Pipeline:
sh
rox pl ci
https://github.com/ThomasLaPiana/rox/assets/5105354/02d99bc6-0dc1-4c33-a753-2868043c4d43
Run a Pipeline in Parallel:
sh
rox pl -p build-release-all
Rox
is released by running cargo release
locally.
Steps to Release:
main
cargo install cargo-release
(if not already installed)cargo release [major|minor|patch] --execute
- Updates the Cargo.toml
, commits and pushes the change, and then publishes the crate to cargo release tag --execute
- Creates a git tag with the same version as the Cargo.toml
cargo release push --execute
- Pushes the git tag