2019-09-18 17:00:35 -04:00
2019-09-18 11:02:41 -04:00
2019-09-16 12:22:29 -04:00
2019-09-18 12:08:20 -04:00
2019-09-17 14:10:01 -04:00
2019-09-17 23:18:29 -04:00
2019-09-16 12:04:03 -04:00
2019-09-16 09:21:25 -04:00
2019-09-18 11:02:41 -04:00
2019-09-17 23:18:29 -04:00
2019-09-16 12:45:24 -04:00
2019-09-16 08:13:48 -04:00
2019-09-16 08:18:13 -04:00
2019-09-16 08:18:13 -04:00
2019-09-16 08:18:13 -04:00
2019-09-18 17:00:35 -04:00
2019-09-17 17:02:25 -04:00

Automate Workflows—Bootstrap Development Environments—Commit The Tasks (i.e. git)

vanity image

    $ bake, n:
    the s☿rangely familiar task runner.

I love using Makefile for one-off tasks in projects.

The problem with doing this is that you can't use familiar bashisms when doing so, as GNU Make doesn't use the familiar Bash syntax, nor does it allow for simple adhoc use of arbitrary scripting languages (e.g. Python).

This project seeks to bridge all of these worlds into a single entrypoint — ideal for crosslanguage repositories.


 

 


 

What's in the oven?

 

  • A Bakefile, which looks and feels like the good parts of a Makefile.
  • Except, you can write real bash code!
  • Environment variables are explicitly passed or whitelisted (allowed), not inherited from the parent shell.
  • Unlike Makefile, either tabs or 4 spaces can be used.
  • Tasks can be run safely and reliably. Rest assured that scripts are executed from the project root (e.g. location of the Bakefile).
  • See advanced example for further, juicy, details.

Community / Contrib


Installing $ bake

Various *nix Distributions (Python 3.6+):

The primary installation method of bake, today, is via pip:

$ pip3 install bake-cli
Collecting bake-cli
Successfully installed bake-cli-0.2.0 delegator.py-0.1.1 pexpect-4.7.0 ptyprocess-0.6.0

This will always work, but it will not be the default recommendation.

MacOS (Previously known as OS X)

Installation of bake will (soon) be very easy, with Homebrew. The formula needs a subtle adjustment — if you want to help, here's the repo!

$ brew install kennethreitz/-/bake
==> Installing bake from kennethreitz/-
🍺  /usr/local/Cellar/bake/19-09-16: 1,563 files, 16.7MB, built in 11 seconds

Homebrew will be the primary installation target of bake.

🍰

Containers! e.g. Docker.

You an also run bake via Docker! An official image has been made available:

$ docker run kennethreitz/bake                                                                                                                                                                       Wed Sep 18 10:11:01 2019
No Bakefile found!
Usage:  [OPTIONS] [TASK] [ARGUMENTS]...

 $ bake — the strangely familiar taskrunner.

Options:
  -b, --bakefile PATH      The Bakefile to use.
  -l, --list               Lists available tasks (and their dependencies).
  -h, --help               Show this message and exit.
  --shellcheck             Run shellcheck on Bakefile.
  --allow TEXT             Whitelist an environment variable for use.
  --no-deps                Do not run dependent tasks.
  --yes                    Set mediumsecurity prompts to yes.
  --continue               Continue, if a task fails.
  -i, --interactive        Run in interactive mode.
  --insecure               Inherit parent shell's environment variables.
  -s, --silent             Reduce output.
  -e, --environ-json TEXT  Provide environment variables via JSON.
  -j, --json               Output in JSON format (stdout).

---------------

## `$ cat Bakefile`

```make
install: install/node install/python
install/full: install/system install

install/python: @skip:key=Pipfile.lock
    pipenv install
install/node: @skip:key=yarn.lock
    yarn install
install/system: @confirm
    brew install pipenv yarn

python/format:
    black .

utils/argv:
    set -u && echo "$HELLO: $@"

utils/deploy: @confirm:secure
    exit 0

Team & Workflow Management

$ bake install
 + Executing install/node:
 |  yarn install v1.17.3
 |  info No lockfile found.
 |  [1/4] Resolving packages...
 |  [2/4] Fetching packages...
 |  [3/4] Linking dependencies...
 |  [4/4] Building fresh packages...
 |  success Saved lockfile.
 |  Done in 0.05s.
 + Executing install/python:
 |  Installing dependencies from Pipfile.lock (f10bb0)…
 + Executing install:
 + Done.

Skip Steps, Automatically

Because we configured yarn.lock and Pipfile.lock as cache keys, bake will automatically skip the configured steps— only running them when the files are changed!

So, let's run that command again :)

$ bake install
 + Skipping install/node:
 + Skipping install/python.
 + Executing install:
 + Done.

Neat, eh?

Passing Values (Arguments & Parameters)

$ bake utils/argv KEY=VALUE 1 2 3
 + Executing utils/argv:
 |  WORLD: 1 2 3
 + Done.

Added Peace of Mind

$ bake utils/deploy
   What is 10 times 2?: 7
Aborted.

Advanced Usage Sample

advanced screenshot

Fancy, eh?


This repository has been brought to you, with much joy, by Kenneth Reitz.

kr soul icon

As above, so below.

Languages
Python 63.8%
Perl 24.3%
Shell 9.1%
Dockerfile 2.8%