Files
computer-playbook/scripts/ci/discover.sh
T
kevinveenbirkenbach 0cad360d29 ci: refactor deploy workflows and make CI build behaviour explicit
- Replace legacy MODE env with TEST_DEPLOY_TYPE across workflows and scripts
- Route CI deploy and discovery through Makefile targets
- Rename deploy-one-app.sh to deploy-app.sh and update all call sites
- Fix Makefile recursion and ensure scripts are executed directly
- Ensure JSON discovery output is clean via silent make target
- Make MISSING_ONLY default true via Makefile
- Respect INFINITO_NO_BUILD in compose up to avoid implicit rebuilds in CI
- Keep explicit build step before compose up for deterministic CI runs
- Improve deploy logging (test_deploy_type instead of mode)

Result:
- Deterministic CI behaviour
- No accidental docker compose rebuilds on up
- Single source of truth for deploy orchestration
- Cleaner env contract between workflows, make, bash and python

https://chatgpt.com/share/69678024-fe38-800f-b877-add46aa55190
2026-01-14 12:37:41 +01:00

96 lines
2.6 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
set -euo pipefail
# Purpose (SRP): Return JSON list of apps based on mode + regex filters.
#
# Inputs via env:
# TEST_DEPLOY_TYPE = server|workstation|universal
# INCLUDE_RE (optional)
# EXCLUDE_RE (optional)
# FINAL_EXCLUDE_RE (optional)
#
# Output:
# JSON array to stdout
TEST_DEPLOY_TYPE="${TEST_DEPLOY_TYPE:-server}"
INCLUDE_RE="${INCLUDE_RE:-}"
EXCLUDE_RE="${EXCLUDE_RE:-}"
FINAL_EXCLUDE_RE="${FINAL_EXCLUDE_RE:-}"
json_nonempty() {
local j="${1:-}"
[[ -n "${j}" ]] || j='[]'
echo "${j}"
}
apply_final_exclude() {
local apps_json="$1"
local final_excl="$2"
if [[ -z "${final_excl}" ]]; then
echo "${apps_json}"
return 0
fi
local txt
txt="$(echo "${apps_json}" | jq -r '.[]' | grep -Ev "${final_excl}" || true)"
printf "%s\n" "${txt}" \
| jq -R -s -c 'split("\n") | map(select(length>0))'
}
discover_simple() {
local include_re="$1"
local exclude_re="$2"
INCLUDE_RE="${include_re}" EXCLUDE_RE="${exclude_re}" scripts/tests/discover-apps.sh
}
case "${TEST_DEPLOY_TYPE}" in
server)
: "${INCLUDE_RE:=^(web-app-|web-svc-)}"
: "${EXCLUDE_RE:=^(web-app-oauth2-proxy)$}"
apps_json="$(discover_simple "${INCLUDE_RE}" "${EXCLUDE_RE}")"
apps_json="$(json_nonempty "${apps_json}")"
;;
workstation)
: "${INCLUDE_RE:=^(desk-|util-desk-)}"
: "${EXCLUDE_RE:=}"
apps_json="$(discover_simple "${INCLUDE_RE}" "${EXCLUDE_RE}")"
apps_json="$(json_nonempty "${apps_json}")"
;;
universal)
# universal = all - (server ∪ workstation)
all_json="$(discover_simple '.*' '')"
all_json="$(json_nonempty "${all_json}")"
server_json="$(discover_simple '^(web-app-|web-svc-)' '^(web-app-oauth2-proxy)$')"
server_json="$(json_nonempty "${server_json}")"
workstation_json="$(discover_simple '^(desk-|util-desk-)' '')"
workstation_json="$(json_nonempty "${workstation_json}")"
apps_json="$(
jq -nc \
--argjson all "${all_json}" \
--argjson server "${server_json}" \
--argjson workstation "${workstation_json}" \
'
def uniq: unique;
def union($a;$b): ($a + $b) | uniq;
def minus($a;$b): $a | map(select(. as $x | ($b | index($x)) | not));
(union($server; $workstation) | uniq) as $covered
| minus($all; $covered)
| unique
'
)"
;;
*)
echo "ERROR: TEST_DEPLOY_TYPE must be server|workstation|universal (got: ${TEST_DEPLOY_TYPE})" >&2
exit 2
;;
esac
apps_json="$(apply_final_exclude "${apps_json}" "${FINAL_EXCLUDE_RE}")"
echo "${apps_json}"