Temper.Env (temper v0.1.0)

Copy Markdown View Source

Boundary module that gathers run context data from the real world: git, CI environment variables, the system clock and the runtime.

gather/1 returns a plain map suitable for Temper.RunContext.new/1. All side effects live here so the core stays pure; every lookup degrades gracefully (no git, no repository, no CI) to nil values rather than raising.

Summary

Types

Options for gather/1.

Functions

Gathers environment data into a plain map for Temper.RunContext.new/1.

Types

option()

@type option() :: {:cd, Path.t()}

Options for gather/1.

Functions

gather(opts \\ [])

@spec gather([option()]) :: map()

Gathers environment data into a plain map for Temper.RunContext.new/1.

The map always contains :run_id (fresh 16-byte random hex), :at (UTC ISO 8601, second precision), :elixir, :otp, :partition (from MIX_TEST_PARTITION), :ci, :sha, :dirty and :branch.

Git data prefers the CI provider's environment variables (e.g. GITHUB_SHA) over shelling out, since CI checkouts are clean by construction. Outside CI it runs git rev-parse/git status in opts[:cd] (default: the current directory) and returns nil values outside a repository or without git installed.

The ExUnit :seed is intentionally absent — only the formatter knows it, and merges it into this map itself.