SayCheezEx - capture the environment at build time

I am releasing SayCheezEx, a library to capture the build time environment in a very simple and concise way.

When I deploy a release, I always want it to embed its own version, Git sha revision, when it was built… all that stuff. An I never remember the exact Git incantations, and sometimes different versions of Git are slightly incompatible on date formatting.

So I just create a module attribute like:

@version cheez! "{:project_version}/{:git_commit_id} {:build_number} on {:build_on}"

And SayCheez takes care of the rest. It can access a set of attributes SayCheezEx — say_cheez_ex v0.2.1 and/or the environment variables, with defaults if they should not be found. It can try multiple items (because sometimes there is a different environment on different CI servers) until one is found.

I mean, it’s not rocket science, but it’s pretty handy.

You can find it on GitHub at GitHub - l3nz/say_cheez_ex: Say Cheez! for Elixir

Comments welcome.

7 Likes

Version 0.2.2 is out, with a major bug fix and a number of new system attributes (thanks @voltone for help!). Some of the attributes are as below:

  build_at: "230411.1538",
  build_at_day: "2023-04-11",
  build_at_full: "2023-04-11.15:38:40",
  build_by: "lenz",
  build_number: "87",
  build_on: "MacBook-Pro.local",
  build_mix_env: "dev",
  git_all: "b204919/230411.1509",
  git_commit_id: "b204919",
  git_commit_id_full: "b2049190312ef810875476398978c2b0387251d3",
  git_date: "2023-04-11.15:09:50",
  git_date_compact: "230411.1509",
  git_last_committer: "Lenz",
  project_full_version: "0.2.1/b204919/230411.1509",
  project_name: "SayCheezEx",
  project_version: "0.2.1",
  sysinfo_arch: "aarch64-apple-darwin22.3.0",
  sysinfo_banner: "Erlang/OTP 25 [erts-13.2] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]",
  sysinfo_beam: "BEAM jit 13.2",
  sysinfo_c_compiler: "gnuc 4.2.1",
  sysinfo_compat: "25",
  sysinfo_driver: "3.3",
  sysinfo_nif: "2.16",
  sysinfo_ptr: "64bit",
  sysinfo_word: "64bit",
  system: "1.14.3/OTP25",
  system_elixir: "1.14.3",
  system_otp: "25",

It is a funny name, but I would consider SEO here as well. If I had the need to find build time capturing on hex I would never find this lib :stuck_out_tongue:

I just did some test searching with keywords on hex.pm and the results appear pretty random. Take a project description, paste it almost verbatim, and you get a ton of other projects.

2 Likes

As a Saturday morning activity, I released a new version (0.3.5) that prints captured values on stdout only when building in environment :prod. This should make logging less noisy.

Version 0.3. introduced Graphviz / PlantUML graphs to be embedded in the project ExDocs - so you can easily create, e.g. diagrams of the inter-dependencies between multiple Gen Servers.