fix: Add documentation
This commit is contained in:
parent
f162eb6cf9
commit
9171978035
7 changed files with 75 additions and 19 deletions
|
@ -1,4 +1,6 @@
|
|||
defmodule MashConfig do
|
||||
@behaviour Mash.Config
|
||||
|
||||
import Mash.Helpers
|
||||
|
||||
def jobs do
|
||||
|
@ -7,7 +9,7 @@ defmodule MashConfig do
|
|||
name: :test,
|
||||
run: mix("test")
|
||||
},
|
||||
%{name: :credo, run: mix("credo", ["--all"])}
|
||||
%{name: :credo, run: mix("credo", ["--all"])},
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
9
LICENSE
Normal file
9
LICENSE
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2023 Mythic Insight
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
51
README.md
51
README.md
|
@ -1,11 +1,8 @@
|
|||
# Mash
|
||||
|
||||
**TODO: Add description**
|
||||
Mash is a dead simple tool for defining and running CI pipelines in Elixir.
|
||||
|
||||
## Installation
|
||||
|
||||
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
|
||||
by adding `mash` to your list of dependencies in `mix.exs`:
|
||||
Add mash to your dependencies like so:
|
||||
|
||||
```elixir
|
||||
def deps do
|
||||
|
@ -15,7 +12,45 @@ def deps do
|
|||
end
|
||||
```
|
||||
|
||||
Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
|
||||
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
|
||||
be found at <https://hexdocs.pm/mash>.
|
||||
## 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:
|
||||
|
||||
```elixir
|
||||
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
|
||||
|
||||
```shell
|
||||
mix mash
|
||||
```
|
||||
|
||||
## Full Documentation
|
||||
|
||||
Full documentation is available on [HexDocs](https://hexdocs.pm/mash).
|
||||
|
|
10
lib/mash.ex
10
lib/mash.ex
|
@ -1,11 +1,3 @@
|
|||
defmodule Mash do
|
||||
@moduledoc """
|
||||
Documentation for `Mash`.
|
||||
"""
|
||||
|
||||
def run() do
|
||||
Enum.map(Mash.Config.jobs(), fn %{run: run} ->
|
||||
run.()
|
||||
end)
|
||||
end
|
||||
@moduledoc File.read!("README.md")
|
||||
end
|
||||
|
|
|
@ -7,6 +7,8 @@ defmodule Mash.Config do
|
|||
|
||||
alias Mash.Job
|
||||
|
||||
@callback jobs() :: [%{name: atom(), run: function()}]
|
||||
|
||||
def start_link() do
|
||||
case Agent.start_link(&compile_config_module!/0, name: __MODULE__) do
|
||||
{:error, {:already_started, pid}} ->
|
||||
|
|
12
mix.exs
12
mix.exs
|
@ -7,7 +7,16 @@ defmodule Mash.MixProject do
|
|||
version: "0.1.0",
|
||||
elixir: "~> 1.14",
|
||||
start_permanent: Mix.env() == :prod,
|
||||
deps: deps()
|
||||
deps: deps(),
|
||||
docs: [
|
||||
main: "Mash"
|
||||
],
|
||||
source_url: "https://gitlab.com/mythic-insight/mash",
|
||||
package: [
|
||||
description: "A dead simple tool for defining and running CI pipelines in Elixir.",
|
||||
licenses: ["MIT"],
|
||||
links: %{"Gitlab" => "https://gitlab.com/mythic-insight/mash"}
|
||||
]
|
||||
]
|
||||
end
|
||||
|
||||
|
@ -21,6 +30,7 @@ defmodule Mash.MixProject do
|
|||
# Run "mix help deps" to learn about dependencies.
|
||||
defp deps do
|
||||
[
|
||||
{:ex_doc, "~> 0.30.4", only: :dev},
|
||||
{:credo, "~> 1.7"}
|
||||
# {:dep_from_hexpm, "~> 0.3.0"},
|
||||
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
|
||||
|
|
6
mix.lock
6
mix.lock
|
@ -1,6 +1,12 @@
|
|||
%{
|
||||
"bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"},
|
||||
"credo": {:hex, :credo, "1.7.0", "6119bee47272e85995598ee04f2ebbed3e947678dee048d10b5feca139435f75", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "6839fcf63d1f0d1c0f450abc8564a57c43d644077ab96f2934563e68b8a769d7"},
|
||||
"earmark_parser": {:hex, :earmark_parser, "1.4.33", "3c3fd9673bb5dcc9edc28dd90f50c87ce506d1f71b70e3de69aa8154bc695d44", [:mix], [], "hexpm", "2d526833729b59b9fdb85785078697c72ac5e5066350663e5be6a1182da61b8f"},
|
||||
"ex_doc": {:hex, :ex_doc, "0.30.4", "e8395c8e3c007321abb30a334f9f7c0858d80949af298302daf77553468c0c39", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "9a19f0c50ffaa02435668f5242f2b2a61d46b541ebf326884505dfd3dd7af5e4"},
|
||||
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
|
||||
"jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"},
|
||||
"makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"},
|
||||
"makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"},
|
||||
"makeup_erlang": {:hex, :makeup_erlang, "0.1.2", "ad87296a092a46e03b7e9b0be7631ddcf64c790fa68a9ef5323b6cbb36affc72", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f3f5a1ca93ce6e092d92b6d9c049bcda58a3b617a8d888f8e7231c85630e8108"},
|
||||
"nimble_parsec": {:hex, :nimble_parsec, "1.3.1", "2c54013ecf170e249e9291ed0a62e5832f70a476c61da16f6aac6dca0189f2af", [:mix], [], "hexpm", "2682e3c0b2eb58d90c6375fc0cc30bc7be06f365bf72608804fb9cffa5e1b167"},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue