fix: enforce triage author only on issue arrival
This commit is contained in:
parent
cbb0fb5eee
commit
a811da8b4f
3 changed files with 28 additions and 18 deletions
|
|
@ -7,4 +7,7 @@ runs:
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
LABELS_CONF: ${{ github.workspace }}/.github/labels.conf
|
LABELS_CONF: ${{ github.workspace }}/.github/labels.conf
|
||||||
|
EVENT_NAME: ${{ github.event_name }}
|
||||||
|
EVENT_ACTION: ${{ github.event.action }}
|
||||||
|
EVENT_ISSUE: ${{ github.event.issue.number }}
|
||||||
run: bash "$GITHUB_ACTION_PATH/issueflow-reconcile.sh"
|
run: bash "$GITHUB_ACTION_PATH/issueflow-reconcile.sh"
|
||||||
|
|
|
||||||
|
|
@ -143,24 +143,7 @@ last_issue_activity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
reconcile_issue() {
|
reconcile_issue() {
|
||||||
local n="$1" author triage=false decision refs states age assignees open_pr=false remove="" label owners
|
local n="$1" decision refs states age assignees open_pr=false label owners
|
||||||
author="$(jq -r '.user.login' <<<"$ISSUE_JSON")"
|
|
||||||
is_triage_actor "$author" && triage=true
|
|
||||||
decision="$(author_decision "$triage" <<<"$ISSUE_LABELS")"
|
|
||||||
if [ "$decision" = ADD_NEEDS_TRIAGE ]; then
|
|
||||||
for label in epic "${QUEUE_LABELS[@]}"; do
|
|
||||||
has_issue_label "$label" && remove="$remove,$label"
|
|
||||||
done
|
|
||||||
remove="${remove#,}"
|
|
||||||
if [ -n "$remove" ]; then
|
|
||||||
run gh issue edit "$n" -R "$REPO" --add-label needs-triage --remove-label "$remove" >/dev/null
|
|
||||||
else
|
|
||||||
run gh issue edit "$n" -R "$REPO" --add-label needs-triage >/dev/null
|
|
||||||
fi
|
|
||||||
log "#$n: needs-triage (opened by $author)"
|
|
||||||
ISSUE_LABELS=needs-triage
|
|
||||||
fi
|
|
||||||
|
|
||||||
decision="$(queue_decision <<<"$ISSUE_LABELS")"
|
decision="$(queue_decision <<<"$ISSUE_LABELS")"
|
||||||
case "$decision" in
|
case "$decision" in
|
||||||
ADD_NEEDS_TRIAGE)
|
ADD_NEEDS_TRIAGE)
|
||||||
|
|
@ -219,12 +202,35 @@ reconcile_issue() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reconcile_opened_issue() {
|
||||||
|
local n="$1" author triage=false labels remove="" label
|
||||||
|
ISSUE_JSON="$(gh api "repos/$REPO/issues/$n")"
|
||||||
|
jq -e 'has("pull_request") | not' <<<"$ISSUE_JSON" >/dev/null || return
|
||||||
|
author="$(jq -r '.user.login' <<<"$ISSUE_JSON")"
|
||||||
|
is_triage_actor "$author" && triage=true
|
||||||
|
labels="$(jq -r '.labels[].name' <<<"$ISSUE_JSON")"
|
||||||
|
[ "$(author_decision "$triage" <<<"$labels")" = ADD_NEEDS_TRIAGE ] || return
|
||||||
|
for label in epic "${QUEUE_LABELS[@]}"; do
|
||||||
|
grep -qxF "$label" <<<"$labels" && remove="$remove,$label"
|
||||||
|
done
|
||||||
|
remove="${remove#,}"
|
||||||
|
if [ -n "$remove" ]; then
|
||||||
|
run gh issue edit "$n" -R "$REPO" --add-label needs-triage --remove-label "$remove" >/dev/null
|
||||||
|
else
|
||||||
|
run gh issue edit "$n" -R "$REPO" --add-label needs-triage >/dev/null
|
||||||
|
fi
|
||||||
|
log "#$n: needs-triage (opened by $author)"
|
||||||
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local owner name
|
local owner name
|
||||||
REPO="${REPO:?set REPO to owner/name}"
|
REPO="${REPO:?set REPO to owner/name}"
|
||||||
LABELS_CONF="${LABELS_CONF:-.github/labels.conf}"
|
LABELS_CONF="${LABELS_CONF:-.github/labels.conf}"
|
||||||
load_issueflow_config "$LABELS_CONF"
|
load_issueflow_config "$LABELS_CONF"
|
||||||
NOW="$(date +%s)"
|
NOW="$(date +%s)"
|
||||||
|
if [ "${EVENT_NAME:-}" = issues ] && [ "${EVENT_ACTION:-}" = opened ]; then
|
||||||
|
reconcile_opened_issue "${EVENT_ISSUE:?set EVENT_ISSUE for issues:opened}"
|
||||||
|
fi
|
||||||
owner="${REPO%%/*}"
|
owner="${REPO%%/*}"
|
||||||
name="${REPO#*/}"
|
name="${REPO#*/}"
|
||||||
OPEN_PR_ISSUES="$(gh api graphql --paginate -f owner="$owner" -f name="$name" -f query='
|
OPEN_PR_ISSUES="$(gh api graphql --paginate -f owner="$owner" -f name="$name" -f query='
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ check "unreadable blocker is flagged" 0 "FLAG_UNPARSEABLE" blocked_decision "12"
|
||||||
check "triage-authored ready issue is accepted" 0 "KEEP" author_decision true <<<"ready"
|
check "triage-authored ready issue is accepted" 0 "KEEP" author_decision true <<<"ready"
|
||||||
check "outside author receives needs-triage" 0 "ADD_NEEDS_TRIAGE" author_decision false <<<"ready"
|
check "outside author receives needs-triage" 0 "ADD_NEEDS_TRIAGE" author_decision false <<<"ready"
|
||||||
check "outside author already marked needs-triage is stable" 0 "KEEP" author_decision false <<<"needs-triage"
|
check "outside author already marked needs-triage is stable" 0 "KEEP" author_decision false <<<"needs-triage"
|
||||||
|
check "later sweep accepts a normalized outside-authored issue" 0 "KEEP" queue_decision <<<"ready"
|
||||||
|
|
||||||
# Invariant 5: completed epics get one nudge; incomplete/unparseable do not.
|
# Invariant 5: completed epics get one nudge; incomplete/unparseable do not.
|
||||||
epic_refs="$(epic_references <<< $'- [ ] #3 first\n- [x] #2 done\nplain #8')"
|
epic_refs="$(epic_references <<< $'- [ ] #3 first\n- [x] #2 done\nplain #8')"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue