Skip to content

try using another api for checking#53

Open
kpj2006 wants to merge 11 commits intoAOSSIE-Org:mainfrom
kpj2006:sync-pr-labels
Open

try using another api for checking#53
kpj2006 wants to merge 11 commits intoAOSSIE-Org:mainfrom
kpj2006:sync-pr-labels

Conversation

@kpj2006
Copy link
Contributor

@kpj2006 kpj2006 commented Jan 26, 2026

Summary by CodeRabbit

  • New Features

    • Added a workflow to create and sync repository labels automatically, with per-label logging and a final summary.
  • Chores

    • Pull request labeling revised: maintainers now labeled "org-member"; non-maintainers labeled as first-time or repeat contributors.
    • PR trigger adjusted to a target-aware event; contributor labeling now selects token from environment.
    • Changelog contributor categories updated and logging/messages improved.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 26, 2026

📝 Walkthrough

Walkthrough

Reworked PR-label sync to use collaborator permission checks (admin/maintain → org-member) and classify non‑maintainers as first-time-contributor or repeat-contributor; added a new workflow to create/update repository labels; updated release-drafter contributors to include repeat-contributor and org-member.

Changes

Cohort / File(s) Summary
PR label sync workflow
/.github/workflows/sync-pr-labels.yml
Switched trigger to pull_request_target; refined size-label logic to avoid unnecessary removals and added early-exit when up-to-date; replaced org-membership flow with getCollaboratorPermissionLevel (admins/maintainers → org-member); non‑maintainers classified by commit count as first-time-contributor or repeat-contributor; contributor step uses LABELLER_TOKEN (from EXTERNAL_LABELLER_TOKEN or GITHUB_TOKEN).
Setup labels workflow
/.github/workflows/setup-labels.yml
New workflow to create/sync repository labels (contributor, issue-tracking, file-type, size); paginates existing labels, creates or updates when color/description differ, logs per-label actions, and summarizes created/updated/skipped/failed; triggers: workflow_dispatch and push on workflow file changes to main/master.
Release Drafter config
/.github/release-drafter.yml
Updated Contributors category: replaced external-contributor with repeat-contributor and org-member.

Sequence Diagram(s)

sequenceDiagram
    participant PR as Pull Request
    participant Runner as Actions Runner
    participant API as GitHub API
    participant Repo as Repository Labels

    PR->>Runner: trigger (pull_request_target)
    Runner->>API: getCollaboratorPermissionLevel(author)
    API-->>Runner: permission (admin/maintain | other)
    alt maintainer (admin/maintain)
        Runner->>Repo: add "org-member" label (use LABELLER_TOKEN)
    else non-maintainer
        Runner->>API: fetch commit count for author
        API-->>Runner: commit count
        alt first-time contributor (≤1)
            Runner->>Repo: add "first-time-contributor"
        else repeat contributor
            Runner->>Repo: add "repeat-contributor"
        end
    end
    Runner->>Repo: update PR labels / log result
Loading
sequenceDiagram
    participant Trigger as Manual / Push
    participant Runner as Actions Runner
    participant API as GitHub API
    participant Repo as Repository Labels

    Trigger->>Runner: run setup-labels workflow
    Runner->>API: list existing labels (paginated)
    API-->>Runner: existing labels
    loop for each desired label
        Runner->>API: compare/create/update label (color/description)
        API-->>Runner: created / updated / skipped / failed
    end
    Runner->>Repo: output summary (created/updated/skipped/failed)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • add sync-pr-labels #6: Modifies sync-pr-labels.yml contributor-labeling logic (permission checks, LABELLER_TOKEN usage).
  • add one more label #8: Related adjustments to PR size-labeling logic in sync-pr-labels.yml.
  • add release drafter #4: Updates .github/release-drafter.yml contributor label mappings overlapping contributor-category changes.

Suggested labels

size/M

Suggested reviewers

  • Zahnentferner

Poem

🐰 I hopped through YAML late at night,
Labels aligned, each color just right,
Maintainers crowned, newcomers tracked,
A tidy repo — no label lacked,
I thump my foot and wink with delight.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'try using another api for checking' is vague and does not clearly convey the main purpose of the changes. While the PR does involve API changes (switching to getCollaboratorPermissionLevel and using LABELLER_TOKEN), the title is too generic and unclear to effectively communicate the primary intent. Consider a more descriptive title such as 'Update contributor labeling logic and use getCollaboratorPermissionLevel API' or 'Improve label sync workflow with enhanced contributor detection' to better convey the main changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added size/S and removed size/S labels Jan 26, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/sync-pr-labels.yml (1)

265-277: Fix first‑time contributor threshold (≤1 mislabels prior contributors).

repos.listCommits returns commits from the default branch. When filtering by author: prAuthor, a user with exactly one prior commit will still be mislabeled as first-time due to the <= 1 condition. Use === 0 to detect only users with no prior commits (optionally add per_page: 2 to avoid fetching unnecessary data).

🔧 Proposed fix
-              const commits = await github.rest.repos.listCommits({
+              const commits = await github.rest.repos.listCommits({
                 owner: context.repo.owner,
                 repo: context.repo.repo,
-                author: prAuthor
+                author: prAuthor,
+                per_page: 2
               });
@@
-              if (commits.data.length <= 1) {
+              if (commits.data.length === 0) {
                 contributorLabels.push('first-time-contributor');
               } else {
                 contributorLabels.push('external-contributor');
               }
🤖 Fix all issues with AI agents
In @.github/workflows/sync-pr-labels.yml:
- Around line 281-289: The permission check for labeling maintainers uses the
wrong API value: when calling github.rest.repos.getCollaboratorPermissionLevel
(result stored in permissionLevel) the permission field returns "write" for
maintain-role users, not "maintain", so update the conditional that pushes into
contributorLabels (currently checking ['admin','maintain']) to check for
['admin','write'] instead, or alternatively inspect
permissionLevel.data.role_name if you need to distinguish the actual "maintain"
role; update the if that references permissionLevel.data.permission accordingly
and keep prAuthor and contributorLabels usage intact.

@github-actions github-actions bot added size/S and removed size/S labels Jan 27, 2026
@kpj2006 kpj2006 requested a review from Zahnentferner January 27, 2026 16:27
@github-actions github-actions bot added size/S and removed size/S labels Jan 27, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.github/workflows/sync-pr-labels.yml:
- Around line 281-283: The PR uses non-existent labels: replace
contributorLabels.push('Org-Member') and any usage of 'external-contributor' in
the addLabels call with repository-defined labels (e.g., remove or replace
'Org-Member' with an appropriate existing label, and change
'external-contributor' to 'repeat-contributor'); update the logic around
contributorLabels and isMaintainer in the code that calls addLabels so it only
pushes valid labels (and/or create the 'Org-Member' label in repo config if you
intend to keep that name) to avoid silent failures from addLabels.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @.github/workflows/setup-labels.yml:
- Around line 189-203: Add a failing condition when any label operation failed:
after the existing summary block that references created/updated/skipped/failed,
check if failed > 0 and call core.setFailed(`Label setup failed: ${failed}
operations failed`) to mark the step as failed; keep the existing
success/complete console logs but ensure core.setFailed is invoked when failed >
0 (use the core import and the failed variable present in the script).
- Around line 138-145: The code uses github.rest.issues.listLabelsForRepo which
returns only the first page; replace that call with github.paginate to fetch all
labels (e.g., use github.paginate(github.rest.issues.listLabelsForRepo, { owner:
context.repo.owner, repo: context.repo.repo }) ), then derive existingLabelNames
from the combined result instead of the paged single response; update any uses
of existingLabels/existingLabelNames accordingly so no labels are missed and 422
errors are avoided.

@github-actions github-actions bot removed the size/L label Jan 27, 2026
@github-actions github-actions bot added size/L and removed size/L labels Jan 27, 2026
@github-actions github-actions bot added size/L and removed size/L labels Jan 28, 2026
@github-actions github-actions bot added size/L and removed size/L labels Jan 28, 2026
@github-actions github-actions bot added size/L and removed size/L labels Jan 28, 2026
description: 'JavaScript/TypeScript code changes'
},
{
name: 'python',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all repos contain Python code. Should we really have this label?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub auto-creates a label when we request GitHub bot to apply a label (if we not create that label), but those labels have no descriptions and all use the same color #ededed , see:

image

This setup explicitly defines a small, clean label set with proper descriptions and colors which include common language js, py

The main reason for introducing this workflow was the internal check pointing out the need for a contributor labels:
https://github.com/AOSSIE-Org/Template-Repo/actions/runs/21186875613/job/60943766803?pr=52

Language labels can always be adjusted per repo if needed

and also note that this is execute on workflow_dispatch means you need to manual trigger it for apply

@github-actions github-actions bot added size/L and removed size/L labels Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants