mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 14:10:37 -07:00
chore(automation): ensure status/need-triage is applied and never cleared automatically (#16657)
This commit is contained in:
@@ -4,37 +4,39 @@
|
||||
# Example: ./scripts/batch_triage.sh google-gemini/maintainers-gemini-cli
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
REPO="${1:-google-gemini/gemini-cli}"
|
||||
WORKFLOW="gemini-automated-issue-triage.yml"
|
||||
|
||||
echo "🔍 Searching for open issues in '$REPO' that need triage (missing 'area/' label)..."
|
||||
echo "🔍 Searching for open issues in '${REPO}' that need triage (missing 'area/' label)..."
|
||||
|
||||
# Fetch open issues with number, title, and labels
|
||||
# We fetch up to 1000 issues.
|
||||
ISSUES_JSON=$(gh issue list --repo "$REPO" --state open --limit 1000 --json number,title,labels)
|
||||
ISSUES_JSON=$(gh issue list --repo "${REPO}" --state open --limit 1000 --json number,title,labels)
|
||||
|
||||
# Filter issues that DO NOT have a label starting with 'area/'
|
||||
TARGET_ISSUES=$(echo "$ISSUES_JSON" | jq '[.[] | select(.labels | map(.name) | any(startswith("area/")) | not)]')
|
||||
TARGET_ISSUES=$(echo "${ISSUES_JSON}" | jq '[.[] | select(.labels | map(.name) | any(startswith("area/")) | not)]')
|
||||
|
||||
COUNT=$(echo "$TARGET_ISSUES" | jq '. | length')
|
||||
# Avoid masking return value
|
||||
COUNT=$(jq '. | length' <<< "${TARGET_ISSUES}")
|
||||
|
||||
if [ "$COUNT" -eq 0 ]; then
|
||||
echo "✅ No issues found needing triage in '$REPO'."
|
||||
if [[ "${COUNT}" -eq 0 ]]; then
|
||||
echo "✅ No issues found needing triage in '${REPO}'."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "🚀 Found $COUNT issues to triage."
|
||||
echo "🚀 Found ${COUNT} issues to triage."
|
||||
|
||||
# Loop through and trigger workflow
|
||||
echo "$TARGET_ISSUES" | jq -r '.[] | "\(.number)|\(.title)"' | while IFS="|" read -r number title; do
|
||||
echo "▶️ Triggering triage for #$number: $title"
|
||||
echo "${TARGET_ISSUES}" | jq -r '.[] | "\(.number)|\(.title)"' | while IFS="|" read -r number title; do
|
||||
echo "▶️ Triggering triage for #${number}: ${title}"
|
||||
|
||||
# Trigger the workflow dispatch event
|
||||
gh workflow run "$WORKFLOW" --repo "$REPO" -f issue_number="$number"
|
||||
gh workflow run "${WORKFLOW}" --repo "${REPO}" -f issue_number="${number}"
|
||||
|
||||
# Sleep briefly to be nice to the API
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "🎉 All triage workflows triggered!"
|
||||
echo "🎉 All triage workflows triggered!"
|
||||
@@ -3,40 +3,42 @@
|
||||
# Usage: ./scripts/relabel_issues.sh <old-label> <new-label> [repository]
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
OLD_LABEL="$1"
|
||||
NEW_LABEL="$2"
|
||||
OLD_LABEL="${1}"
|
||||
NEW_LABEL="${2}"
|
||||
REPO="${3:-google-gemini/gemini-cli}"
|
||||
|
||||
if [ -z "$OLD_LABEL" ] || [ -z "$NEW_LABEL" ]; then
|
||||
if [[ -z "${OLD_LABEL}" ]] || [[ -z "${NEW_LABEL}" ]]; then
|
||||
echo "Usage: $0 <old-label> <new-label> [repository]"
|
||||
echo "Example: $0 'area/models' 'area/agent'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "🔍 Searching for open issues in '$REPO' with label '$OLD_LABEL'..."
|
||||
echo "🔍 Searching for open issues in '${REPO}' with label '${OLD_LABEL}'..."
|
||||
|
||||
# Fetch issues with the old label
|
||||
ISSUES=$(gh issue list --repo "$REPO" --label "$OLD_LABEL" --state open --limit 1000 --json number,title)
|
||||
ISSUES=$(gh issue list --repo "${REPO}" --label "${OLD_LABEL}" --state open --limit 1000 --json number,title)
|
||||
|
||||
COUNT=$(echo "$ISSUES" | jq '. | length')
|
||||
# Avoid masking return value
|
||||
COUNT=$(jq '. | length' <<< "${ISSUES}")
|
||||
|
||||
if [ "$COUNT" -eq 0 ]; then
|
||||
echo "✅ No issues found with label '$OLD_LABEL'."
|
||||
if [[ "${COUNT}" -eq 0 ]]; then
|
||||
echo "✅ No issues found with label '${OLD_LABEL}'."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "found $COUNT issues to relabel."
|
||||
echo "found ${COUNT} issues to relabel."
|
||||
|
||||
# Iterate and update
|
||||
echo "$ISSUES" | jq -r '.[] | "\(.number) \(.title)"' | while read -r number title; do
|
||||
echo "🔄 Processing #$number: $title"
|
||||
echo " - Removing: $OLD_LABEL"
|
||||
echo " + Adding: $NEW_LABEL"
|
||||
echo "${ISSUES}" | jq -r '.[] | "\(.number) \(.title)"' | while read -r number title; do
|
||||
echo "🔄 Processing #${number}: ${title}"
|
||||
echo " - Removing: ${OLD_LABEL}"
|
||||
echo " + Adding: ${NEW_LABEL}"
|
||||
|
||||
gh issue edit "$number" --repo "$REPO" --add-label "$NEW_LABEL" --remove-label "$OLD_LABEL"
|
||||
gh issue edit "${number}" --repo "${REPO}" --add-label "${NEW_LABEL}" --remove-label "${OLD_LABEL}"
|
||||
|
||||
echo " ✅ Done."
|
||||
done
|
||||
|
||||
echo "🎉 All issues relabeled!"
|
||||
echo "🎉 All issues relabeled!"
|
||||
@@ -30,9 +30,10 @@
|
||||
set -e -E
|
||||
|
||||
# Load environment variables from .env if it exists
|
||||
if [ -f ".env" ]; then
|
||||
if [[ -f ".env" ]]; then
|
||||
echo "Loading environment variables from .env file..."
|
||||
set -a # Automatically export all variables
|
||||
# shellcheck source=/dev/null
|
||||
source .env
|
||||
set +a
|
||||
fi
|
||||
@@ -49,32 +50,32 @@ STREAM_MODE=false
|
||||
# Parse command line arguments
|
||||
while [[ "$#" -gt 0 ]]; do
|
||||
case $1 in
|
||||
--payload) PAYLOAD_FILE="$2"; shift ;;
|
||||
--model) MODEL_ID="$2"; shift ;;
|
||||
--payload) PAYLOAD_FILE="${2}"; shift ;;
|
||||
--model) MODEL_ID="${2}"; shift ;;
|
||||
--stream) STREAM_MODE=true ;;
|
||||
*) echo "Unknown parameter passed: $1"; usage ;;
|
||||
*) echo "Unknown parameter passed: ${1}"; usage ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Validate inputs
|
||||
if [ -z "$PAYLOAD_FILE" ] || [ -z "$MODEL_ID" ]; then
|
||||
if [[ -z "${PAYLOAD_FILE}" ]] || [[ -z "${MODEL_ID}" ]]; then
|
||||
echo "Error: Missing required arguments."
|
||||
usage
|
||||
fi
|
||||
|
||||
if [ -z "$GEMINI_API_KEY" ]; then
|
||||
if [[ -z "${GEMINI_API_KEY}" ]]; then
|
||||
echo "Error: GEMINI_API_KEY environment variable is not set."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$PAYLOAD_FILE" ]; then
|
||||
echo "Error: Payload file '$PAYLOAD_FILE' does not exist."
|
||||
if [[ ! -f "${PAYLOAD_FILE}" ]]; then
|
||||
echo "Error: Payload file '${PAYLOAD_FILE}' does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# API Endpoint definition
|
||||
if [ "$STREAM_MODE" = true ]; then
|
||||
if [[ "${STREAM_MODE}" = true ]]; then
|
||||
GENERATE_CONTENT_API="streamGenerateContent"
|
||||
echo "Mode: Streaming"
|
||||
else
|
||||
@@ -82,16 +83,18 @@ else
|
||||
echo "Mode: Non-streaming (Default)"
|
||||
fi
|
||||
|
||||
echo "Sending request to model: $MODEL_ID"
|
||||
echo "Using payload from: $PAYLOAD_FILE"
|
||||
echo "Sending request to model: ${MODEL_ID}"
|
||||
echo "Using payload from: ${PAYLOAD_FILE}"
|
||||
echo "----------------------------------------"
|
||||
|
||||
# Make the cURL request. If non-streaming, pipe through jq for readability if available.
|
||||
if [ "$STREAM_MODE" = false ] && command -v jq &> /dev/null; then
|
||||
curl -s -X POST \
|
||||
if [[ "${STREAM_MODE}" = false ]] && command -v jq &> /dev/null; then
|
||||
# Invoke curl separately to avoid masking its return value
|
||||
output=$(curl -s -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
"https://generativelanguage.googleapis.com/v1beta/models/${MODEL_ID}:${GENERATE_CONTENT_API}?key=${GEMINI_API_KEY}" \
|
||||
-d "@${PAYLOAD_FILE}" | jq .
|
||||
-d "@${PAYLOAD_FILE}")
|
||||
echo "${output}" | jq .
|
||||
else
|
||||
curl -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
|
||||
Reference in New Issue
Block a user