mash/README.md
2023-08-10 09:14:45 +00:00

1.6 KiB

Mash is a dead simple tool for defining and running CI pipelines in Elixir.

Installation

Add mash to your dependencies like so:

def deps do
  [
    {:mash, "~> 0.1.0"}
  ]
end

Configuring pipelines

To configure your job pipeline, create a .mash.exs file at the root of your project containing a module which implements a jobs/0 function:

defmodule MashConfig do
  import Mash.Helpers

  def jobs do
    [
      %{
        name: :test,
        run: mix("test")
      },
      %{
        name: :credo, 
        run: mix("credo", ["--all"])
      },
    ]
  end
end

Each entry in the jobs list must, at a minimum, have two keys:

  • :name -- the name of the job which must be a unique atom
  • :run -- a function which defines the work for the job to do. We recommend using the helper functions from Mash.Helpers to define your run function, as they ensure that your function handles setup and teardown correctly for many common scenarios, e.g.:
    • Mash.Helpers.mix(task_name, args) -- execute a mix task with the given task_name and args.
    • Mash.Helpers.shell(command, args) -- run an executable/script named command with args.
    • Mash.Helpers.fun(fn -> ... end) -- execute the Elixir function given. This function must return :ok or {:ok, value} to indicate success, or return {:error, error} or raise to indicate job failure.

Optionally, a job may also contain a key needs whose value is an array of other jobs that must pass before this job will be run.

Running

mix mash

Full Documentation

Full documentation is available on HexDocs.