forked from heavy-duty/ceremony
test: pin injected staleness boundary
This commit is contained in:
parent
1030634b09
commit
d0f1a43064
2 changed files with 14 additions and 9 deletions
|
|
@ -95,6 +95,10 @@ claim_decision() { # $1 assignee count, $2 linked open PR, $3 age seconds
|
|||
fi
|
||||
}
|
||||
|
||||
claim_decision_at() { # $1 assignee count, $2 linked open PR, $3 last activity epoch
|
||||
claim_decision "$1" "$2" "$((NOW - $3))"
|
||||
}
|
||||
|
||||
blocked_references() { # body on stdin -> issue numbers, one per line
|
||||
sed -nE 's/.*Blocked by[[:space:]]+//Ip' \
|
||||
| sed -E 's/[.;][[:space:]].*$//' \
|
||||
|
|
@ -175,8 +179,8 @@ reconcile_issue() {
|
|||
if has_issue_label claimed; then
|
||||
assignees="$(jq '.assignees | length' <<<"$ISSUE_JSON")"
|
||||
grep -qxF "$n" <<<"${OPEN_PR_ISSUES:-}" && open_pr=true
|
||||
age=$((NOW - $(last_issue_activity "$n" "$(jq -r '.created_at' <<<"$ISSUE_JSON")")))
|
||||
decision="$(claim_decision "$assignees" "$open_pr" "$age")"
|
||||
age="$(last_issue_activity "$n" "$(jq -r '.created_at' <<<"$ISSUE_JSON")")"
|
||||
decision="$(claim_decision_at "$assignees" "$open_pr" "$age")"
|
||||
case "$decision" in
|
||||
FLAG_UNASSIGNED)
|
||||
ensure_comment "$n" claimed-unassigned \
|
||||
|
|
|
|||
|
|
@ -31,18 +31,19 @@ check "needs-triage plus queue is a conflict" 0 "FLAG_CONFLICT" queue_decision <
|
|||
|
||||
# Invariant 2: claims have an owner and either a PR or recent activity.
|
||||
check "claim with open PR stays claimed" 0 "KEEP" claim_decision 1 true 999999
|
||||
check "claim below stale boundary stays claimed" 0 "KEEP" claim_decision 1 false $((STALE_AFTER - 1))
|
||||
check "claim exactly at stale boundary stays claimed" 0 "KEEP" claim_decision 1 false "$STALE_AFTER"
|
||||
check "claim past stale boundary is reclaimed" 0 "RECLAIM" claim_decision 1 false $((STALE_AFTER + 1))
|
||||
check "unassigned claim is flagged" 0 "FLAG_UNASSIGNED" claim_decision 0 false 60
|
||||
check "quiet unassigned claim is also reclaimed" 0 "RECLAIM" claim_decision 0 false $((STALE_AFTER + 1))
|
||||
# shellcheck disable=SC2016 # expansions belong to the isolated bash -c process
|
||||
check "injected clock is retained" 0 "1700000000" \
|
||||
bash -c 'ISSUEFLOW_NOW=1700000000 source "$1"; printf "%s\n" "$NOW"' _ \
|
||||
check "injected clock: below stale boundary stays claimed" 0 "KEEP" \
|
||||
bash -c 'ISSUEFLOW_NOW=100000 ISSUEFLOW_STALE_HOURS=1 source "$1"; claim_decision_at 1 false 96401' _ \
|
||||
"$ROOT/actions/issueflow-reconcile/issueflow-reconcile.sh"
|
||||
# shellcheck disable=SC2016 # expansions belong to the isolated bash -c process
|
||||
check "injected stale hours set the boundary" 0 "10800" \
|
||||
bash -c 'ISSUEFLOW_STALE_HOURS=3 source "$1"; printf "%s\n" "$STALE_AFTER"' _ \
|
||||
check "injected clock: exact stale boundary stays claimed" 0 "KEEP" \
|
||||
bash -c 'ISSUEFLOW_NOW=100000 ISSUEFLOW_STALE_HOURS=1 source "$1"; claim_decision_at 1 false 96400' _ \
|
||||
"$ROOT/actions/issueflow-reconcile/issueflow-reconcile.sh"
|
||||
# shellcheck disable=SC2016 # expansions belong to the isolated bash -c process
|
||||
check "injected clock: past stale boundary is reclaimed" 0 "RECLAIM" \
|
||||
bash -c 'ISSUEFLOW_NOW=100000 ISSUEFLOW_STALE_HOURS=1 source "$1"; claim_decision_at 1 false 96399' _ \
|
||||
"$ROOT/actions/issueflow-reconcile/issueflow-reconcile.sh"
|
||||
|
||||
# Invariant 3: blocked declarations parse and release only when all close.
|
||||
|
|
|
|||
Loading…
Reference in a new issue