-
Notifications
You must be signed in to change notification settings - Fork 171
chore: rename check_advanced_requirement.sh to bot-advanced-check.sh #1341 #1353
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
Merged
exploreriii
merged 8 commits into
hiero-ledger:main
from
akramsdm:issue-1341-rename-advanced-requirements
Jan 8, 2026
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4fa2ace
chore: rename check_advanced_requirement.sh to bot-advanced-check.sh …
akramsdm 0297acc
docs: add changelog entry for script rename #1341
akramsdm 2f5c2a7
Merge branch 'main' into issue-1341-rename-advanced-requirements
akramsdm 5fc46be
Merge branch 'main' into issue-1341-rename-advanced-requirements
akramsdm faffafa
chore: rename check_advanced_requirement.sh to bot-advanced-check.sh …
akramsdm 4aee4c9
chore: remove accidental git file and fix changelog
akramsdm c38d90c
Merge branch 'main' into issue-1341-rename-advanced-requirements
akramsdm e2828ab
Merge branch 'main' into issue-1341-rename-advanced-requirements
akramsdm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| # 1. Define Helper Functions First | ||
| log() { | ||
| echo "[advanced-check] $1" | ||
| } | ||
|
|
||
| # 2. Validate required environment variables | ||
| if [[ -z "${REPO:-}" ]] || [[ -z "${ISSUE_NUMBER:-}" ]] || [[ -z "${GH_TOKEN:-}" ]]; then | ||
| log "ERROR: Required environment variables (REPO, ISSUE_NUMBER, GH_TOKEN) must be set" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # 3. Function to check a single user | ||
| check_user() { | ||
| local user=$1 | ||
| log "Checking qualification for @$user..." | ||
|
|
||
| # Permission exemption | ||
| PERM_JSON=$(gh api "repos/$REPO/collaborators/$user/permission" 2>/dev/null || echo '{"permission":"none"}') | ||
| PERMISSION=$(echo "$PERM_JSON" | jq -r '.permission // "none"') | ||
|
|
||
| if [[ "$PERMISSION" =~ ^(admin|write|triage)$ ]]; then | ||
| log "User @$user is core member ($PERMISSION). Qualification check skipped." | ||
| return 0 | ||
| fi | ||
|
|
||
| # 2. Get counts | ||
| # Using exact repository label names ("Good First Issue" and "intermediate") | ||
| GFI_QUERY="repo:$REPO is:issue is:closed assignee:$user -reason:\"not planned\" label:\"Good First Issue\"" | ||
| INT_QUERY="repo:$REPO is:issue is:closed assignee:$user -reason:\"not planned\" label:\"intermediate\"" | ||
|
|
||
| GFI_COUNT=$(gh api "search/issues" -f q="$GFI_QUERY" --jq '.total_count' || echo "0") | ||
| INT_COUNT=$(gh api "search/issues" -f q="$INT_QUERY" --jq '.total_count' || echo "0") | ||
|
|
||
| # Numeric validation | ||
| if ! [[ "$GFI_COUNT" =~ ^[0-9]+$ ]]; then GFI_COUNT=0; fi | ||
| if ! [[ "$INT_COUNT" =~ ^[0-9]+$ ]]; then INT_COUNT=0; fi | ||
|
|
||
| # Validation Logic | ||
| if (( GFI_COUNT >= 1 )) && (( INT_COUNT >= 1 )); then | ||
| log "User @$user qualified." | ||
| return 0 | ||
| else | ||
| log "User @$user failed. Unassigning..." | ||
|
|
||
| # Tailor the suggestion based on what is missing | ||
| # Links and names now match exact repository labels | ||
| if (( GFI_COUNT == 0 )); then | ||
| SUGGESTION="[Good First Issue](https://github.com/$REPO/labels/Good%20First%20Issue)" | ||
| else | ||
| SUGGESTION="[intermediate issue](https://github.com/$REPO/labels/intermediate)" | ||
| fi | ||
|
|
||
| # Post the message FIRST, then unassign. | ||
| MSG="Hi @$user, I cannot assign you to this issue yet. | ||
| **Why?** | ||
| Advanced issues involve high-risk changes to the core codebase. They require significant testing and can impact automation and CI behavior. | ||
| **Requirement:** | ||
| - Complete at least **1** 'Good First Issue' (You have: **$GFI_COUNT**) | ||
| - Complete at least **1** 'intermediate' issue (You have: **$INT_COUNT**) | ||
| Please check out our **$SUGGESTION** tasks to build your experience first!" | ||
|
|
||
| gh issue comment "$ISSUE_NUMBER" --repo "$REPO" --body "$MSG" | ||
| gh issue edit "$ISSUE_NUMBER" --repo "$REPO" --remove-assignee "$user" | ||
exploreriii marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| fi | ||
| } | ||
|
|
||
| # --- Main Logic --- | ||
|
|
||
| if [[ -n "${TRIGGER_ASSIGNEE:-}" ]]; then | ||
| check_user "$TRIGGER_ASSIGNEE" | ||
| else | ||
| log "Checking all current assignees..." | ||
|
|
||
| # Fetch assignees into a variable first. | ||
| ASSIGNEE_LIST=$(gh issue view "$ISSUE_NUMBER" --repo "$REPO" --json assignees --jq '.assignees[].login') | ||
|
|
||
| if [[ -z "$ASSIGNEE_LIST" ]]; then | ||
| log "No assignees found to check." | ||
| else | ||
| # Use a here-string (<<<) to iterate over the variable safely. | ||
| while read -r user; do | ||
| if [[ -n "$user" ]]; then | ||
| check_user "$user" | ||
| fi | ||
| done <<< "$ASSIGNEE_LIST" | ||
| fi | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.