mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-10 04:36:40 +00:00
Move lifecycle filtering into discover-server-apps.sh so only lifecycle-eligible web-app-* and web-svc-* roles are discovered. This prevents invalid per-app deploy tests where applications are excluded later during inventory generation, causing "not present in inventory" errors. - Filter invokable roles by server prefixes - Apply lifecycle_filter blacklist using TESTED_LIFECYCLES - Always emit valid JSON for CI matrix generation https://chatgpt.com/share/695fd936-0ee4-800f-a57f-2d7995e15ba0
58 lines
1.7 KiB
Bash
Executable File
58 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Discovers invokable server apps from inside the running infinito container.
|
|
# Output: JSON array, e.g. ["web-app-foo","web-svc-bar"]
|
|
#
|
|
# Requires:
|
|
# - docker compose stack running (profile "ci") with service "infinito"
|
|
# - jq installed on the runner
|
|
#
|
|
# Lifecycle gating:
|
|
# - Uses TESTED_LIFECYCLES (space or comma-separated)
|
|
# - Default: "alpha beta rc stable"
|
|
|
|
# 1) Get invokable roles from container (one per line)
|
|
invokable="$(
|
|
docker compose --profile ci exec -T infinito \
|
|
python3 -m cli.meta.applications.invokable \
|
|
| sed -e 's/[[:space:]]\+$//' -e '/^$/d'
|
|
)"
|
|
|
|
# 2) Keep only server apps
|
|
filtered="$(printf "%s\n" "${invokable}" | grep -E '^(web-app-|web-svc-)' || true)"
|
|
|
|
# 3) Convert to JSON array
|
|
apps_json="$(
|
|
printf "%s\n" "${filtered}" \
|
|
| jq -R -s -c 'split("\n") | map(select(length>0))'
|
|
)"
|
|
|
|
# 4) Apply lifecycle gating (blacklist mode: exclude roles NOT in tested lifecycles)
|
|
tested="${TESTED_LIFECYCLES:-alpha beta rc stable}"
|
|
tested="${tested//,/ }"
|
|
tested="$(printf "%s\n" "${tested}" | xargs)"
|
|
|
|
# lifecycle_filter prints role names space-separated (or nothing)
|
|
exclude_txt="$(
|
|
docker compose --profile ci exec -T infinito \
|
|
sh -lc "python3 -m cli.meta.roles.lifecycle_filter blacklist ${tested} || true"
|
|
)"
|
|
|
|
exclude_json="$(
|
|
printf "%s\n" "${exclude_txt}" \
|
|
| tr ' ' '\n' \
|
|
| sed -e 's/[[:space:]]\+$//' -e '/^$/d' \
|
|
| jq -R -s -c 'split("\n") | map(select(length>0))'
|
|
)"
|
|
|
|
# Remove excluded roles from apps_json
|
|
apps_json="$(
|
|
jq -c --argjson excl "${exclude_json}" \
|
|
'map(select(. as $a | ($excl | index($a)) | not))' \
|
|
<<< "${apps_json}"
|
|
)"
|
|
|
|
# Always output valid JSON
|
|
printf "%s\n" "${apps_json}"
|