Files
computer-playbook/scripts/github/resolve/pr_affected_roles.sh
T
kevinveenbirkenbachandClaude Opus 4.8 b6e79878fd fix(ci): make 🧩 Subset resolver comply with repo lint rules
The merged subset feature failed test-lint: a .py under scripts/, a local parents[N] PROJECT_ROOT, a direct yaml.safe_load, an uncached read, and narration comments.

- move scripts/meta/resolve/pr/subset_roles.py -> cli.meta.ci.subset_roles (scripts/ is .sh-only); dispatcher invokes it via python -m
- parse via utils.cache.yaml.load_yaml_str; import utils.PROJECT_ROOT
- test invokes the module via -m against real roles; nocheck the tempfile read
- strip narration comments; docs document HOW not WHY

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 00:59:49 +02:00

37 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Resolve the role whitelist for a pull-request CI run and write
# `whitelist` + `roles_only` to GITHUB_OUTPUT. This is the single
# entry point the `detect-affected-roles` job calls; it keeps the
# subset-vs-diff selection logic out of the workflow YAML.
#
# Inputs via env:
# SUBSET_LABELED "true" when the PR carries the '🧩 Subset' label.
# When set, the explicit role list declared in the PR
# body wins, resolved by the cli.meta.ci.subset_roles
# module (strict: it fails the run on
# invalid/empty/unknown roles).
# Otherwise the diff-derived resolver runs unchanged.
# PR_BODY PR body markdown (only read on the subset path).
#
# Outputs (GITHUB_OUTPUT):
# whitelist=<role-id ...|__ALL__>
# roles_only=<true|false>
set -euo pipefail
: "${GITHUB_OUTPUT:?Missing GITHUB_OUTPUT}"
if [[ "${SUBSET_LABELED:-}" == "true" ]]; then
echo "🧩 Subset label present: restricting CI to the roles listed in the PR body."
exec python -m cli.meta.ci.subset_roles
fi
resolved="$(./scripts/meta/resolve/diff/affected_roles.sh)"
echo "Resolver output: ${resolved}"
if [[ "${resolved}" == "__ALL__" ]]; then
printf 'whitelist=__ALL__\nroles_only=false\n' >>"${GITHUB_OUTPUT}"
else
printf 'whitelist=%s\nroles_only=true\n' "${resolved}" >>"${GITHUB_OUTPUT}"
fi