Tinfoil.Burrito (tinfoil v0.2.22)

Copy Markdown View Source

Integration with the user's Burrito configuration in mix.exs.

Burrito target names are user-chosen keys in the :releases block:

releases: [
  my_cli: [
    steps: [:assemble, &Burrito.wrap/1],
    burrito: [
      targets: [
        macos:    [os: :darwin, cpu: :x86_64],
        macos_m1: [os: :darwin, cpu: :aarch64],
        linux:    [os: :linux,  cpu: :x86_64]
      ]
    ]
  ]
]

Tinfoil's own target atoms (:darwin_arm64, :linux_x86_64, ...) are abstract. To drive Burrito from CI, tinfoil needs to know what the user called the target with matching [os:, cpu:]. This module reads the releases block from a mix project keyword list and resolves each tinfoil target atom to the user's Burrito target name.

Summary

Functions

Extract the Burrito targets map from a mix project keyword list.

Resolve a single tinfoil target atom to the user's Burrito target name by matching [os:, cpu:] against the user's Burrito config.

Resolve every tinfoil target atom against the user's Burrito targets.

Types

burrito_targets()

@type burrito_targets() :: %{required(atom()) => [os: atom(), cpu: atom()]}

Functions

extract_targets(project, app)

@spec extract_targets(
  keyword(),
  atom()
) :: {:ok, burrito_targets()} | {:error, term()}

Extract the Burrito targets map from a mix project keyword list.

Picks the release whose name matches app. If no release matches by name, falls back to the single release in the block (if exactly one exists). Any other case is an error.

resolve(tinfoil_target, burrito_targets, extras \\ %{})

@spec resolve(Tinfoil.Target.target(), burrito_targets(), Tinfoil.Target.extras()) ::
  {:ok, atom()}
  | {:error,
     {:no_matching_burrito_target, Tinfoil.Target.target(),
      Tinfoil.Target.spec()}}

Resolve a single tinfoil target atom to the user's Burrito target name by matching [os:, cpu:] against the user's Burrito config.

resolve_all(tinfoil_targets, burrito_targets, extras \\ %{})

@spec resolve_all(
  [Tinfoil.Target.target()],
  burrito_targets(),
  Tinfoil.Target.extras()
) ::
  {:ok, %{required(Tinfoil.Target.target()) => atom()}} | {:error, term()}

Resolve every tinfoil target atom against the user's Burrito targets.

Returns {:ok, %{tinfoil_target => burrito_name}} or halts on the first unmatched target and returns the error.