Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: check for non-labeled issues #32707

Merged
merged 41 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4104c3b
chore: check for non-labeled issues
ph1l1pF Nov 24, 2024
da8a59a
Merge branch 'main' into chore/label-checker-action
ph1l1pF Nov 25, 2024
b9188de
chore: exclude correct label
ph1l1pF Nov 26, 2024
f5e65b9
Merge branch 'chore/label-checker-action' of https://github.com/ph1l1…
ph1l1pF Nov 26, 2024
ca07c8e
chore: change to test repo
ph1l1pF Nov 26, 2024
2ae5cf1
chore: change to real repo
ph1l1pF Nov 26, 2024
dee72fe
chore: fix label creation part
ph1l1pF Nov 26, 2024
28ff834
Merge branch 'main' into chore/label-checker-action
ph1l1pF Nov 26, 2024
3c62064
change job name
ph1l1pF Nov 27, 2024
8c9d44e
change job description
ph1l1pF Nov 27, 2024
1e81be2
Update docs/development/issue-labeling.md
ph1l1pF Nov 27, 2024
8b3b16a
change issue title
ph1l1pF Nov 27, 2024
d8c7ef6
change issue title
ph1l1pF Nov 27, 2024
9cab5eb
change comment
ph1l1pF Nov 27, 2024
24e95b9
change comment
ph1l1pF Nov 27, 2024
9bf4dc1
change comment
ph1l1pF Nov 27, 2024
32acc38
change comment
ph1l1pF Nov 27, 2024
a3cbdaf
change comment
ph1l1pF Nov 27, 2024
31bffc2
change comment
ph1l1pF Nov 27, 2024
50a6829
change comment
ph1l1pF Nov 27, 2024
5f49419
change comment
ph1l1pF Nov 27, 2024
fa5936a
change comment
ph1l1pF Nov 27, 2024
529512d
fix typo
ph1l1pF Nov 27, 2024
39e91bb
improve comment
ph1l1pF Nov 27, 2024
e869a33
change comment
ph1l1pF Nov 27, 2024
9f23f1c
change label description
ph1l1pF Nov 27, 2024
176556f
improve comment
ph1l1pF Nov 27, 2024
92c0343
add point
ph1l1pF Nov 27, 2024
f91c9a6
add point to sentence
ph1l1pF Nov 27, 2024
9f5fbf4
add point to sentence
ph1l1pF Nov 27, 2024
d390eb0
rename sh script
ph1l1pF Nov 27, 2024
add3a49
rename script
ph1l1pF Nov 27, 2024
5a73611
rename action file
ph1l1pF Nov 27, 2024
39e0cf5
chore: find issue by title and author-type instead of special label
ph1l1pF Dec 13, 2024
8fc9891
chore: remove unnecessary label
ph1l1pF Dec 13, 2024
c1813e1
chore: remove non-existing label from meta-issue
ph1l1pF Dec 14, 2024
ba034dc
Update docs/development/issue-labeling.md
ph1l1pF Dec 16, 2024
869eee1
Update tools/find-issues-with-missing-labels.sh
ph1l1pF Dec 16, 2024
ed0653c
Update tools/find-issues-with-missing-labels.sh
ph1l1pF Dec 16, 2024
4ec5b2d
chore: use permissions per job
ph1l1pF Dec 16, 2024
833dc23
Merge branch 'chore/label-checker-action' of https://github.com/ph1l1…
ph1l1pF Dec 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/check-unlabeled-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'Check unlabeled issues'
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved

on:
schedule:
# Run every Sunday at midnight
- cron: '0 0 * * 0'

permissions:
issues: write

jobs:
check-unlabeled-issues:
runs-on: ubuntu-latest

env:
GH_TOKEN: ${{ github.token }}

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Check for unlabeled issues
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved
run: bash ./tools/check-unlabeled-issues.sh
1 change: 1 addition & 0 deletions .github/workflows/label-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ jobs:
- uses: dessant/label-actions@102faf474a544be75fbaf4df54e73d3c515a0e65 # v4.0.1
with:
github-token: ${{ github.token }}
exclude-any-issue-labels: ['Label check action']
8 changes: 8 additions & 0 deletions docs/development/issue-labeling.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,11 @@ Add a label `auto:retry-latest` to any Discussion where the user should retry th
</details>

Apply the `self-hosted` label when an issue is applicable only to users who self-administer their own bot.

## Automated label report

We have a GitHub Action that checks if we're using the correct labels on our issues.

The action runs once a week and checks for issues without the proper labels.

If the action finds any issues missing labels, it creates a new issue with the missing labels and details the issues found so any collaborator can label them accordingly.
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved
78 changes: 78 additions & 0 deletions tools/check-unlabeled-issues.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/bash
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved

# When the repository labels are changed (i.e dropped a label, added a label, etc), you should make the same change to the lists below.
# For example, if the repository added a "type:task" type label, then add "-label:type:task" to the TYPE_LABELS_FILTER.
TYPE_LABELS_FILTER='-label:type:bug -label:type:feature -label:type:docs -label:type:refactor -label:type:help'

PRIORITY_LABELS_FILTER='-label:priority-1-critical -label:priority-2-high -label:priority-3-medium -label:priority-4-low'

HAS_ISSUES_MISSING_LABELS=false

ISSUE_BODY="# Label check action\n"

REPO='renovatebot/renovate'

ISSUE_TITLE="Found other non-labled issues"
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved

for FILTER in "$TYPE_LABELS_FILTER" "$PRIORITY_LABELS_FILTER"; do
# Extract the label type from the filter
LABEL_TYPE=$(echo "$FILTER" | cut -d ':' -f 2 | cut -d '-' -f 1)

# Fetch issues filtered by the label type
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved
ISSUES_MISSING_LABEL=$(gh issue list --repo $REPO --limit 100000 -s open -S "$FILTER" --json "number,title") || { echo "Failed to fetch issues without $LABEL_TYPE labels"; exit 1; }
# filter out issue with title the label action issue itself
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved
ISSUES_MISSING_LABEL=$(echo "$ISSUES_MISSING_LABEL" | jq --arg title "$ISSUE_TITLE" 'map(select(.title != $title))')

if [ "$ISSUES_MISSING_LABEL" != "[]" ]; then
HAS_ISSUES_MISSING_LABELS=true

# Format the output to be a list of issue numbers
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved
FORMATTED_OUTPUT=$(echo "$ISSUES_MISSING_LABEL" | jq -r '.[].number' | sed 's/^/- #/')

# Count the number of issues to determine if it's singular or plural
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved
ISSUE_COUNT=$(echo "$ISSUES_MISSING_LABEL" | jq '. | length')
ISSUE_SINGULAR_PLURAL=$(if [ "$ISSUE_COUNT" -eq 1 ]; then echo "issue"; else echo "issues"; fi)

# Append the list of issues to the new issue body
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved
ISSUE_BODY="$ISSUE_BODY## Found $ISSUE_COUNT $ISSUE_SINGULAR_PLURAL missing \`$LABEL_TYPE:\` labels:\n$FORMATTED_OUTPUT\n"
fi
done

if [ "$HAS_ISSUES_MISSING_LABELS" = false ]; then
echo "Found no issues with missing labels. Exixting the action."
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved
exit 0
fi

LABEL_CHECK_ACTION="Label check action"

# check if label "Label check action" exists
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved
LABEL_CHECKACTION_EXISTS=$(gh label list --repo $REPO | grep "$LABEL_CHECK_ACTION" || true) || { echo "Failed to fetch existing label"; exit 1; }
if [ -z "$LABEL_CHECKACTION_EXISTS" ]; then
echo "Label '$LABEL_CHECK_ACTION' does not exist. Will create it."
# Create a new label "Label check action"
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved
gh label create "$LABEL_CHECK_ACTION" --description "This label is used for the issue that lists invalid issues." --repo $REPO || { echo "Failed to create label"; exit 1; }
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved
fi

LABEL_CHECK_ISSUE_EXISTS=$(gh search issues --label "$LABEL_CHECK_ACTION" --repo $REPO --json number) || { echo "Failed to fetch existing label check issue"; exit 1; }
ISSUE_NUMBER=$(echo "$LABEL_CHECK_ISSUE_EXISTS" | jq -r '.[].number')

if [ -z "$ISSUE_NUMBER" ]; then

# Create a new issue with the list of issues
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved
gh issue create --repo $REPO --label "$LABEL_CHECK_ACTION" --title "$ISSUE_TITLE" --body "$(echo -e "$ISSUE_BODY")" || { echo "Failed to create issue"; exit 1; }
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved
else
# Update the existing issue with the list of issues
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved
gh issue edit "$ISSUE_NUMBER" --repo $REPO --title "$ISSUE_TITLE" --body "$(echo -e "$ISSUE_BODY")" || { echo "Failed to update issue"; exit 1; }
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved

# Reopen the issue
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved
gh issue reopen "$ISSUE_NUMBER" --repo $REPO || { echo "Failed to reopen issue"; exit 1; }
fi

# Provide an output in the action itself
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved
echo -e "$ISSUE_BODY"

# Fail the action if there are issues missing the correct labels
ph1l1pF marked this conversation as resolved.
Show resolved Hide resolved
echo "Found issues missing labels. Please check the issue(s) above."

exit 1