|
| 1 | +#!/usr/bin/env sh |
| 2 | +# SPDX-FileCopyrightText: Sudo Apt Holdings LLC |
| 3 | +# SPDX-License-Identifier: Apache-2.0 |
| 4 | +# |
| 5 | +# The release half of the gate. Added after slice 062, for a defect the gate could not see: |
| 6 | +# `Plug.Builder` calls a plug's `init/1` at COMPILE TIME when MIX_ENV=prod and escapes what it |
| 7 | +# returns into the endpoint, so an anonymous function there breaks the release build and nothing |
| 8 | +# else. `mix gate` runs in MIX_ENV=test, where `init/1` is called per request, so every gate was |
| 9 | +# green over a tree whose release could not compile; the three-OS `package` workflow found it at |
| 10 | +# the tag, which is after approval (slice 062 NOTES, F5). |
| 11 | +# |
| 12 | +# Three commands, each for a class the one before it cannot see: |
| 13 | +# |
| 14 | +# 1. the tree compiles in prod — compile-time differences (the defect above) |
| 15 | +# 2. the release assembles — the release's application list and boot scripts |
| 16 | +# 3. the release evaluates its config — config/runtime.exs's `config_env() == :prod` |
| 17 | +# branch, 116 lines that nothing else in the gate |
| 18 | +# or in CI ever executes |
| 19 | +# |
| 20 | +# What it does NOT prove, said plainly: nothing here builds a Burrito binary, loads a NIF under |
| 21 | +# musl (slice 013's mdex finding), builds the Tauri shell, or runs on macOS or Windows. That is |
| 22 | +# the `package` workflow's job and it stays the `package` workflow's job. |
| 23 | +# |
| 24 | +# POSIX sh, like scripts/plan_check.sh, and like it not run on a Windows developer's machine. |
| 25 | +# The gate invokes it as `cmd env ERL_AFLAGS= ./scripts/prod_check.sh`: on the FIPS leg it runs |
| 26 | +# outside FIPS mode, because compiling prod builds the dependencies and `tokenizers` fetches a |
| 27 | +# precompiled NIF over TLS, which OTP's ssl cannot do in the mode. Compiling for release is not |
| 28 | +# a FIPS property; the FIPS properties are `mix test --trace test/fips`, which stays in the mode. |
| 29 | +set -eu |
| 30 | +cd "$(dirname "$0")/.." |
| 31 | + |
| 32 | +build_root="${MIX_BUILD_ROOT:-_build}" |
| 33 | +rel="$build_root/prod/rel/headless/bin/headless" |
| 34 | + |
| 35 | +echo "== 1. the tree compiles in prod ==" |
| 36 | +MIX_ENV=prod mix compile --warnings-as-errors |
| 37 | + |
| 38 | +echo "== 2. the headless release assembles ==" |
| 39 | +# Assets are not deployed here: this step is about the release's own assembly, and |
| 40 | +# `mix assets.deploy` is the packaging workflow's concern. |
| 41 | +MIX_ENV=prod mix release headless --overwrite --quiet |
| 42 | + |
| 43 | +echo "== 3. the release evaluates its runtime configuration ==" |
| 44 | +# `eval` runs the release's config providers, so config/runtime.exs's prod branch is executed |
| 45 | +# with no environment prepared for it, which is how a packaged binary is first started. |
| 46 | +"$rel" eval 'IO.puts("prod boot config ok")' |
| 47 | + |
| 48 | +echo "prod_check: PASS" |
0 commit comments