Juggernaut.Config (Juggernaut v0.4.0)

Copy Markdown View Source

The validated configuration of one project (see the configuration guide).

load/2 reads .juggernaut.exs at the project root (it is optional), validates it, applies the JUGGERNAUT_BASE override and computes the config fingerprint. Every failure is a Juggernaut.Error of type :config (exit 2) naming the file.

The fingerprint is a SHA-256 over the validated options (nested keyword lists sorted, so formatting and key order do not matter), Juggernaut's version, the Elixir and OTP versions and the contents of mix.lock. The JUGGERNAUT_BASE override is not part of it: the base selects which mutants run, not how a mutant is judged.

Summary

Functions

:ok, or a config error naming (never showing) the refused variables.

The fingerprint of validated options and the contents of mix.lock, with Juggernaut's code (Juggernaut.code_id/0, not its version), Elixir's and OTP's.

The option keys of .juggernaut.exs, in documentation order.

Loads the configuration of the project at root. env supplies JUGGERNAUT_BASE.

Names of set, non-empty environment variables matching refuse_env, sorted. Values are never returned.

The pool size: workers, or for :auto min(8, max(1, div(schedulers, worker_schedulers))).

Types

call()

@type call() ::
  {module() | :*, atom()}
  | {module() | :*, atom(), arity()}
  | {module() | :*, atom(), arity(), [non_neg_integer()]}

t()

@type t() :: %Juggernaut.Config{
  arid_calls: [call()],
  base: String.t(),
  cache: boolean(),
  cache_inputs: :tracked | [String.t()],
  connections: [
    budget: :none | pos_integer(),
    per_worker: :auto | pos_integer()
  ],
  core: [String.t() | module()],
  env: [{String.t(), String.t()}],
  exclude: [String.t()],
  file: Path.t() | nil,
  fingerprint: String.t(),
  ignore_prefixes: [String.t()],
  lasting_servers: [module()],
  lasting_supervisors: [atom()],
  no_coverage: :count | :fail,
  operators: :default | :all | [atom()],
  paths: [String.t()],
  raw_calls: [call()],
  refuse_env: :secrets | [String.t()],
  root: Path.t(),
  skip_calls: [call()],
  spares: boolean(),
  strict_ignores: boolean(),
  test_lanes: [
    {:integration,
     tags: [atom()],
     paths: [String.t()],
     timeout: [multiplier: number(), min_ms: pos_integer()]}
  ],
  test_paths: :project | [String.t()],
  thresholds: [core: 0..100, changed: 0..100, per: :file | :run],
  timeout: [multiplier: number(), min_ms: pos_integer()],
  timeouts: :killed | :survived,
  worker_schedulers: pos_integer(),
  worker_setup: :test_alias | [String.t()],
  workers: :auto | pos_integer()
}

Functions

check_env(config, env)

@spec check_env(t(), %{required(String.t()) => String.t()}) ::
  :ok | {:error, Juggernaut.Error.t()}

:ok, or a config error naming (never showing) the refused variables.

fingerprint(opts, lock)

@spec fingerprint(keyword(), binary()) :: String.t()

The fingerprint of validated options and the contents of mix.lock, with Juggernaut's code (Juggernaut.code_id/0, not its version), Elixir's and OTP's.

keys()

@spec keys() :: [atom()]

The option keys of .juggernaut.exs, in documentation order.

load(root, env \\ System.get_env())

@spec load(Path.t(), %{required(String.t()) => String.t()}) ::
  {:ok, t()} | {:error, Juggernaut.Error.t()}

Loads the configuration of the project at root. env supplies JUGGERNAUT_BASE.

refused_env(config, env)

@spec refused_env(t(), %{required(String.t()) => String.t()}) :: [String.t()]

Names of set, non-empty environment variables matching refuse_env, sorted. Values are never returned.

workers(config, schedulers)

@spec workers(t(), pos_integer()) :: pos_integer()

The pool size: workers, or for :auto min(8, max(1, div(schedulers, worker_schedulers))).