bake-cli

Crates.iobake-cli
lib.rsbake-cli
version0.3.0
sourcesrc
created_at2024-02-09 16:48:47.463842
updated_at2024-02-28 21:20:07.110654
descriptionTask runner built to be tastier than `make`
homepagehttps://github.com/trinio-labs/bake
repositoryhttps://github.com/trinio-labs/bake
max_upload_size
id1134141
size200,597
Theo Ribeiro (theoribeiro)

documentation

README

🍪 bake 🍪

Yet another task runner. This time it's tasty.

Bake is a task runner built to be simpler than Make and to satisfy some of the needs of managing dependent build, test and deploy tasks in complex projects. It's capable of running tasks in parallel as well as caching outputs based on each recipe's inputs such as files or environment variables.

Installation

Homebrew

brew install trinio-labs/tap/bake

Cargo

cargo install bake-cli

A bake project

A bake project consists of a root bake.yml configuration file, Cookbooks and Recipes. A Cookbook is a collection of Recipes that share some context while each Recipe is a distinct task that can be run and cached by bake.

A typical project looks like this:


├── foo
│   ├── src
│   │   └── main.rs
│   ├── cargo.toml
│   └── cookbook.yml
├── bar
│   ├── src
│   │   └── index.js
│   ├── package.json
│   └── cookbook.yml
└── bake.yml

Bake is able to quickly scan a directory for cookbook.yml files to find cookbooks in the project. It then builds a dependency graph for all recipes and runs them accordingly.

Cookbooks

Cookbooks contain recipes that usually share the same context. Typically, a cookbook is a package of a monorepo but it is not restricted to that logical separation.

A cookbook can be configured by a cookbook.yml file such as the example below:

name: foo
recipes:
  build:
    inputs:
      - "./src/**/*.rs"
    outputs:
      - "./target/foo"
    run: |
      echo "Building foo"
      ./build.sh
    dependencies:
      - "test"
      - "bar:build"
  test:
    run: |
      cargo test
    inputs:
      - "./src/**/*.rs"
    outputs:
      - lcov.info

A cookbook can contain any number of recipes and in the future will be able to hold common recipe configurations.

Recipes

As seen above, every recipe, at a minimum, must have a run property that defines how to bake it. It can also state which recipes it depends on by using the recipe's full name or partial if they both belong to the same cookbook. A recipe can also specify which files should be considered for caching in the property inputs. Inputs are configured as glob patterns relative to the root of the cookbook.

For a more detailed explanation of the configuration files, please see Configuration.

Baking recipes

By default, bake will run all recipes in all cookbooks if called without any arguments.

If you want to be more granular, you can run bake passing a pattern to filter the recipes to run. The pattern is always in the form <cookbook>:<recipe>.

For example, to run the build recipe from the foo cookbook, run:

bake foo:build

You can also run all recipes in the foo cookbook:

bake foo:

Or all recipes named build in any cookbook:

bake :build

Caching

By default, bake caches runs locally in a directory called .bake/cache. Bake will use the combined hash of all inputs of a recipe, the hash of its dependencies and its run command to create a cache key. This allows for recipes to be cached and only run again if either a dependency or the recipe itself changes. Bake can also be configured to use a remote storage to cache recipes such as S3 or GCS.

For more information on how to configure caching, please see Caching.

Commit count: 0

cargo fmt