Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion scripts/compliance-audit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ check_required_workflows() {
fi_content=$(gh_api "repos/$ORG/$repo/contents/.github/workflows/feature-ideation.yml" --jq '.content' 2>/dev/null || echo "")
if [ -n "$fi_content" ]; then
fi_decoded=$(echo "$fi_content" | base64 -d 2>/dev/null || echo "")
if [ -n "$fi_decoded" ] && feature_ideation_context_is_placeholder "$fi_decoded"; then
if [ -n "$fi_decoded" ] && feature_ideation_context_is_placeholder "$fi_decoded" \
&& ! repo_is_placeholder_context_exempt "$repo"; then
add_finding "$repo" "ci-workflows" "feature-ideation-placeholder-context" "warning" \
"\`feature-ideation.yml\` is present but its \`project_context\` is still the seed template placeholder (\`TODO:\`/\`Example:\`) — replace it with a real per-repo project description so weekly ideation runs on real context" \
"standards/ci-standards.md#required-workflows"
Expand All @@ -247,6 +248,30 @@ feature_ideation_context_is_placeholder() {
grep -qE '^[[:space:]]*(TODO: Replace this with a description of the project|Example: "ProjectX)' <<< "$decoded"
}

# Repos exempt from the feature-ideation-placeholder-context finding (Epic #850,
# Story D). For a normal repo a still-placeholder project_context is a real
# warning — weekly ideation would run on "TODO". repo-template is the exception:
# its feature-ideation seed KEEPS the placeholder on purpose, because it IS the
# seed new repos copy and customise, so flagging it is a false positive. Codified
# as a registry (not an inlined magic string) so further per-repo exemptions are
# data, extended here rather than by editing check_required_workflows.
readonly PLACEHOLDER_CONTEXT_EXEMPT_REPOS=(
repo-template
)

# repo_is_placeholder_context_exempt <repo> -> 0 if <repo> is exempt from the
# feature-ideation-placeholder-context finding, non-zero otherwise. Pure (exact
# match against PLACEHOLDER_CONTEXT_EXEMPT_REPOS). An empty repo name is never
# exempt.
repo_is_placeholder_context_exempt() {
local repo="$1" r
[ -n "$repo" ] || return 1
for r in "${PLACEHOLDER_CONTEXT_EXEMPT_REPOS[@]}"; do
[ "$r" = "$repo" ] && return 0
done
return 1
}

# ---------------------------------------------------------------------------
# Check: Action SHA pinning
# ---------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,49 @@ EOF
[ "$status" -ne 0 ]
}

# ---------------------------------------------------------------------------
# repo-template exemption (Epic #850, Story D).
#
# repo-template's feature-ideation seed keeps the TODO:/Example: placeholder on
# purpose — it IS the seed new repos customise, so its context is *correct* while
# still-placeholder. The audit must therefore NOT raise
# feature-ideation-placeholder-context against repo-template. The exemption is
# codified as a registry + pure predicate so future per-repo exemptions are data,
# not inlined magic strings.
# ---------------------------------------------------------------------------

is_placeholder_exempt() {
run bash -c 'source "$1" >/dev/null 2>&1; repo_is_placeholder_context_exempt "$2"' \
_ "$SCRIPT" "$1"
}

@test "repo-template is exempt from the placeholder-context finding" {
is_placeholder_exempt "repo-template"
[ "$status" -eq 0 ]
}

@test "a normal fleet repo is NOT exempt from the placeholder-context finding" {
is_placeholder_exempt "markets"
[ "$status" -ne 0 ]
}

@test "the empty repo name is NOT exempt" {
is_placeholder_exempt ""
[ "$status" -ne 0 ]
}

@test "the placeholder-context exemption registry is defined and lists repo-template" {
run bash -c 'source "$1" >/dev/null 2>&1; printf "%s\n" "${PLACEHOLDER_CONTEXT_EXEMPT_REPOS[@]}"' _ "$SCRIPT"
[ "$status" -eq 0 ]
grep -qx 'repo-template' <<< "$output"
}

@test "check_required_workflows guards the placeholder finding with the exemption predicate" {
run bash -c 'source "$1" >/dev/null 2>&1; declare -f check_required_workflows' _ "$SCRIPT"
[ "$status" -eq 0 ]
grep -q 'repo_is_placeholder_context_exempt' <<< "$output"
}

# ---------------------------------------------------------------------------
# REQUIRED_WORKFLOWS now includes all three promoted workflows (org-wide).
# ---------------------------------------------------------------------------
Expand Down
Loading