Skip to content

scripts/nexus-audit.sh - #803

Closed
Aissamohammedi88 wants to merge 1 commit into
python:mainfrom
Aissamohammedi88:patch-1
Closed

Aissamohammedi88 wants to merge 1 commit into
python:mainfrom
Aissamohammedi88:patch-1

Conversation

@Aissamohammedi88

Copy link
Copy Markdown

#!/usr/bin/env bash

═══════════════════════════════════════════════════════════════════════════════

Nexus triage audit — read-only, uses GitHub REST API

Usage : ./nexus-audit.sh <owner/repo> [state]

Deps : curl, jq

═══════════════════════════════════════════════════════════════════════════════

set -euo pipefail

readonly API="https://api.github.com"
readonly UA="Nexus-Triage-Audit/1.0"
TOKEN="${GITHUB_TOKEN:-}"
REPO="${1:?Usage: $0 <owner/repo> [state]}"
STATE="${2:-open}"

[[ -n "$TOKEN" ]] || { echo "GITHUB_TOKEN required" >&2; exit 1; }

gh_get() {
curl -s -H "Accept: application/vnd.github+json"
-H "Authorization: Bearer $TOKEN"
-H "User-Agent: $UA"
--max-time 30
"$API$1"
}

fetch_all() {
local page=1 all="[]"
while (( page <= 10 )); do
local batch
batch=$(gh_get "/repos/$REPO/issues?state=$STATE&per_page=100&page=$page")
local n; n=$(echo "$batch" | jq 'if type == "array" then length else 0 end')
(( n == 0 )) && break
all=$(echo "$all" "$batch" | jq -s 'add')
(( n < 100 )) && break
((page++))
done
echo "$all" | jq '[.[] | select(.pull_request == null)]'
}

issues=$(fetch_all)
total=$(echo "$issues" | jq 'length')

if (( total == 0 )); then
echo "No open issues."
exit 0
fi

no_label=$(echo "$issues" | jq '[.[] | select((.labels | length) == 0)] | length')
no_assignee=$(echo "$issues" | jq '[.[] | select(.assignee == null)] | length')
no_comments=$(echo "$issues" | jq '[.[] | select(.comments == 0)] | length')

one_year_ago=$(date -u -d '1 year ago' +%Y-%m-%dT%H:%M:%SZ 2>/dev/null
|| date -u -v-1y +%Y-%m-%dT%H:%M:%SZ)
stale=$(echo "$issues" | jq --arg d "$one_year_ago"
'[.[] | select(.created_at < $d)] | length')

echo "═══════════════════════════════════════════════════════════════════════════"
echo " NEXUS AUDIT : $REPO (State: $STATE)"
echo "═══════════════════════════════════════════════════════════════════════════"
echo
echo "▶ FACTS"
echo "───────────────────────────────────────────────────────────────────────────"
printf " %-24s %s\n" "Open issues:" "$total"
printf " %-24s %s\n" "Without labels:" "$no_label"
printf " %-24s %s\n" "Without assignee:" "$no_assignee"
printf " %-24s %s\n" "Without any reply:" "$no_comments"
printf " %-24s %s\n" "Stale (> 1 year):" "$stale"
echo
echo " Top labels:"
echo "$issues" | jq -r '
[.[] | .labels[].name]
| group_by(.)
| map({label: .[0], count: length})
| sort_by(-.count) | .[0:5]
| .[] | " - (.label) ((.count))"
'
echo
echo "▶ RECOMMENDATIONS"
echo "───────────────────────────────────────────────────────────────────────────"
(( no_label > 0 )) && echo " [P1] $no_label issue(s) without labels — apply taxonomy."
(( stale > 0 )) && echo " [P1] $stale issue(s) stale (>1y) — close or relabel 'stale'."
(( no_assignee > 0 )) && echo " [P2] $no_assignee issue(s) unassigned — assign maintainer."
(( no_comments > 0 )) && echo " [P2] $no_comments issue(s) unanswered — acknowledge."
echo
echo "▶ OLDEST 5"
echo "───────────────────────────────────────────────────────────────────────────"
echo "$issues" | jq -r '
sort_by(.created_at) | .[0:5] | .[]
| " #(.number) (.created_at | split("T")[0]) (.title[0:70])"
'

@python-cla-bot

python-cla-bot Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@srittau srittau closed this Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants