Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Update first responders notifier for repo label rename (#61402)

Lenaa736da2a8096
diff --git a/.github/workflows/slack_notify_first_responders.yml b/.github/workflows/slack_notify_first_responders.yml
index c8d970451dd..a15c7b9c0f0 100644
--- a/.github/workflows/slack_notify_first_responders.yml
+++ b/.github/workflows/slack_notify_first_responders.yml
@@ -8,9 +8,9 @@ permissions:
contents: read
env:
- PRIORITY_LABELS: '["priority:P0", "priority:P1"]'
+ SEVERITY_LABELS: '["severity:S0", "severity:S1"]'
REPRODUCIBLE_LABEL: 'state:reproducible'
- FREQUENCY_LABELS: '["frequency:always", "frequency:common"]'
+ REACH_LABELS: '["reach:all users", "reach:many users"]'
MARKER_REACTION: 'eyes'
jobs:
@@ -47,10 +47,10 @@ jobs:
# Ignore labels outside the trifecta so unrelated later edits don't re-fire.
TRIGGER_LABELS=$(jq -cn \
- --argjson priority "$PRIORITY_LABELS" \
+ --argjson severity "$SEVERITY_LABELS" \
--arg repro "$REPRODUCIBLE_LABEL" \
- --argjson freq "$FREQUENCY_LABELS" \
- '$priority + [$repro] + $freq')
+ --argjson reach "$REACH_LABELS" \
+ '$severity + [$repro] + $reach')
if ! echo "$TRIGGER_LABELS" | jq -e --arg l "$LABEL_NAME" 'index($l) != null' > /dev/null; then
echo "Added label '$LABEL_NAME' is not in the trigger set, skipping"
@@ -61,12 +61,12 @@ jobs:
# The webhook's issue.labels snapshot is racy under bulk apply; read live.
ISSUE_LABELS_JSON=$(api -f "https://api.github.com/repos/$GH_REPO/issues/$ISSUE_NUMBER/labels?per_page=100" | jq '[.[].name]')
- MATCHED_PRIORITY=$(echo "$ISSUE_LABELS_JSON" | jq -r --argjson priority "$PRIORITY_LABELS" 'map(select(. as $x | $priority | index($x) != null)) | first // ""')
+ MATCHED_SEVERITY=$(echo "$ISSUE_LABELS_JSON" | jq -r --argjson severity "$SEVERITY_LABELS" 'map(select(. as $x | $severity | index($x) != null)) | first // ""')
HAS_REPRO=$(echo "$ISSUE_LABELS_JSON" | jq --arg l "$REPRODUCIBLE_LABEL" 'index($l) != null')
- HAS_FREQ=$(echo "$ISSUE_LABELS_JSON" | jq --argjson freq "$FREQUENCY_LABELS" 'any(.[]; . as $x | $freq | index($x) != null)')
+ HAS_REACH=$(echo "$ISSUE_LABELS_JSON" | jq --argjson reach "$REACH_LABELS" 'any(.[]; . as $x | $reach | index($x) != null)')
- if [ -z "$MATCHED_PRIORITY" ] || [ "$HAS_REPRO" != "true" ] || [ "$HAS_FREQ" != "true" ]; then
- echo "Combination not yet satisfied (priority=$MATCHED_PRIORITY, reproducible=$HAS_REPRO, frequency=$HAS_FREQ), skipping"
+ if [ -z "$MATCHED_SEVERITY" ] || [ "$HAS_REPRO" != "true" ] || [ "$HAS_REACH" != "true" ]; then
+ echo "Combination not yet satisfied (severity=$MATCHED_SEVERITY, reproducible=$HAS_REPRO, reach=$HAS_REACH), skipping"
echo "should_notify=false" >> "$GITHUB_OUTPUT"
exit 0
fi
@@ -96,9 +96,9 @@ jobs:
REACTION_ID=$(echo "$REACTION_BODY" | jq -r '.id')
LABELS=$(echo "$ISSUE_LABELS_JSON" | jq -r 'join(", ")')
- echo "Confirmed high-frequency $MATCHED_PRIORITY, notifying"
+ echo "Confirmed high-reach $MATCHED_SEVERITY, notifying"
{
- echo "notify_reason=confirmed $MATCHED_PRIORITY"
+ echo "notify_reason=confirmed $MATCHED_SEVERITY"
echo "issue_labels=$LABELS"
echo "reaction_id=$REACTION_ID"
echo "should_notify=true"
diff --git a/script/github-label-issues-to-triage.py b/script/github-label-issues-to-triage.py
deleted file mode 100755
index 9a7274a4aa3..00000000000
--- a/script/github-label-issues-to-triage.py
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/usr/bin/env python3
-"""Add `state:needs triage` label to open GitHub issues of types Bug and Crash
-if they're missing area, priority, or frequency labels. Don't touch issues
-with an assignee or another `state:` label.
-
-Requires `requests` library and a GitHub access token with "Issues (write)"
-permission passed as an environment variable. Was used as a quick-and-dirty
-one-off-bulk-operation script to surface older untriaged issues in the `zed`
-repository. Leaving it here for reference only; there's no error handling or
-guardrails, you've been warned.
-"""
-
-import itertools
-import logging
-import os
-
-import requests
-
-
-logging.basicConfig(level=logging.INFO)
-log = logging.getLogger(__name__)
-
-GITHUB_API_BASE_URL = "https://api.github.com"
-REPO_OWNER = "zed-industries"
-REPO_NAME = "zed"
-GITHUB_TOKEN = os.getenv("GITHUB_TOKEN")
-HEADERS = {
- "Authorization": f"token {GITHUB_TOKEN}",
- "Accept": "application/vnd.github+json"
-}
-REQUIRED_LABELS_PREFIXES = ["area:", "priority:", "frequency:"]
-NEEDS_TRIAGE_LABEL = "state:needs triage"
-
-
-def get_open_issues(repo, issue_type):
- """Get open issues of certain type(s) via GitHub's REST API."""
- issues = []
- issues_url = f"{GITHUB_API_BASE_URL}/repos/{REPO_OWNER}/{repo}/issues"
-
- log.info("Start fetching open issues from the GitHub API.")
- params = {
- "state": "open",
- "type": issue_type,
- "page": 1,
- "per_page": 100, # worked fine despite the docs saying 30
- }
- while True:
- response = requests.get(issues_url, headers=HEADERS, params=params)
- response.raise_for_status()
- issues.extend(response.json())
- log.info(f"Fetched the next page, total issues so far: {len(issues)}.")
-
- # is there a next page?
- link_header = response.headers.get('Link', '')
- if 'rel="next"' not in link_header:
- break
- params['page'] += 1
-
- log.info("Done fetching issues.")
- return issues
-
-
-def is_untriaged(issue):
- issue_labels = [label['name'] for label in issue['labels']]
- # don't want to overwrite existing state labels
- no_state_label = not any(label.startswith('state:') for label in issue_labels)
- # we want at least one label for each of the required prefixes
- has_all_required_labels = all(
- any(label.startswith(prefix) for label in issue_labels)
- for prefix in REQUIRED_LABELS_PREFIXES
- )
- # let's also assume if we managed to assign an issue it's triaged enough
- no_assignee = not issue['assignee']
- return no_state_label and no_assignee and not has_all_required_labels
-
-
-def label_issues(issues, label):
- for issue in issues:
- log.debug(f"Processing issue {issue['number']}.")
- api_url_add_label = f"{GITHUB_API_BASE_URL}/repos/{REPO_OWNER}/{REPO_NAME}/issues/{issue['number']}/labels"
- add_response = requests.post(
- api_url_add_label, headers=HEADERS, json={"labels": [label]}
- )
- add_response.raise_for_status()
- log.info(f"Added label '{label}' to issue {issue['title']}.")
-
-
-if __name__ == "__main__":
- open_bugs = get_open_issues(REPO_NAME, "Bug")
- open_crashes = get_open_issues(REPO_NAME, "Crash")
- untriaged_issues = filter(
- is_untriaged, itertools.chain(open_bugs, open_crashes))
- label_issues(untriaged_issues, label=NEEDS_TRIAGE_LABEL)