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

Implement triaging helper #4594

Open
BenHenning opened this issue Sep 15, 2022 · 3 comments · May be fixed by #5591
Open

Implement triaging helper #4594

BenHenning opened this issue Sep 15, 2022 · 3 comments · May be fixed by #5591
Assignees
Labels
enhancement End user-perceivable enhancements. Impact: Low Low perceived user impact (e.g. edge cases). Work: Medium The means to find the solution is clear, but it isn't at good-first-issue level yet. Z-ibt Temporary label for Ben to keep track of issues he's triaged.

Comments

@BenHenning
Copy link
Member

BenHenning commented Sep 15, 2022

Is your feature request related to a problem? Please describe.
When triaging, there are specific criteria that must be met to ensure that the issue is properly triaged. Furthermore, it's nice to get quick acknowledgement after filing an issue.

Describe the solution you'd like
A GitHub Action that automatically replies to incoming issues with a message like: "Thanks for filing the issue, we'll be following up shortly to route this to the correct team." Beyond that, the workflow should verify that exactly one open project is assigned to the issue, and that exactly one of each type of these labels is assigned: issue type, work, and impact. If any of these criteria fail to be met, the issue should be automatically labeled with "needs triage." If all of them are met, "needs triage" should be removed.

Describe alternatives you've considered
Manually managing the issues with a search query for issues that need triage, but unfortunately GitHub's search syntax is too limited to actually search for the criteria above. Alternatively we could maintain a "triaged" label, but it'd be nicer to minimize long-term permanent labels.

Additional context
None.

@BenHenning BenHenning added Type: Improvement Impact: Low Low perceived user impact (e.g. edge cases). Z-ibt Temporary label for Ben to keep track of issues he's triaged. labels Sep 15, 2022
@BenHenning
Copy link
Member Author

Another feature that would be nice to have: automatically move issues into "In progress" when someone self-assigns.

@seanlip seanlip added enhancement End user-perceivable enhancements. and removed issue_type_infrastructure labels Mar 28, 2023
@MohitGupta121 MohitGupta121 added the Work: Medium The means to find the solution is clear, but it isn't at good-first-issue level yet. label Jun 8, 2023
@BenHenning BenHenning self-assigned this Jan 30, 2024
@BenHenning BenHenning added this to the 1.0 Global availability milestone Jan 30, 2024
@BenHenning BenHenning assigned BenHenning and unassigned BenHenning Jan 30, 2024
@BenHenning BenHenning added enhancement End user-perceivable enhancements. and removed enhancement End user-perceivable enhancements. labels Jan 30, 2024
@seanlip seanlip removed this from the 1.0 Global availability milestone Sep 4, 2024
@Mayank77maruti
Copy link
Contributor

Mayank77maruti commented Dec 5, 2024

To automate issue triage in your GitHub repository, I have created a workflow file (.github/workflows/issue-triage.yml) and configured it to trigger on issue events like opened or labeled. This workflow automatically comments on new issues, checks for required labels (e.g., bug, Impact: High), and adds or removes a needs-triage label based on label completeness.Also checks for the assigned project team.

name: Issue Triage and Management

on:
  issues:
    types: [opened, labeled]
  issue_assigned:
    types: [assigned]

jobs:
  triage-on-issue-open:
    runs-on: ubuntu-latest
    if: github.event.sender.login != 'github-actions'
    steps:
      - name: Reply to Issue
        uses: peter-evans/issues-comment-action@v2
        with:
          issue-number: ${{ github.event.issue.number }}
          comment: >
            Thanks for filing the issue! We’ll review it shortly and route it to the correct team. 

      - name: Check Labels for Proper Triaging
        id: check-labels
        uses: actions/github-script@v6
        with:
          script: |
            const issue = await github.rest.issues.get({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number
            });

            const labels = issue.data.labels.map(label => label.name);
            const requiredLabels = {
              types: ['bug', 'enhancement', 'good first issue'],
              impacts: ['Impact: High', 'Impact: Medium', 'Impact: Low'],
              work: ['Work: High', 'Work: Medium', 'Work: Low'],
              priorities: ['Priority: Essential', 'Priority: Important', 'Priority: Nice-to-have']
            };

            const hasTypeLabel = labels.some(label => requiredLabels.types.includes(label));
            const hasImpactLabel = labels.some(label => requiredLabels.impacts.includes(label));
            const hasWorkLabel = labels.some(label => requiredLabels.work.includes(label));
            const hasPriorityLabel = labels.some(label => requiredLabels.priorities.includes(label));

            const needsTriage = !(hasTypeLabel && hasImpactLabel && hasWorkLabel && hasPriorityLabel);

            core.setOutput('needs-triage', needsTriage);

      - name: Add Needs Triage Label
        if: steps.check-labels.outputs.needs-triage == 'true'
        uses: actions/labeler@v3
        with:
          labels: needs-triage

      - name: Remove Needs Triage Label
        if: steps.check-labels.outputs.needs-triage == 'false'
        uses: actions/labeler@v3
        with:
          remove: needs-triage
    
       - name: Verify Project Assignment
        uses: actions/github-script@v6
      with:
          script: |
        const projects = await github.rest.issues.listForRepo({
        owner: context.repo.owner,
        repo: context.repo.repo,
        issue_number: context.issue.number,
      });

      const openProjects = projects.data.filter(project => project.state === 'open');
      if (openProjects.length !== 1) {
        throw new Error(`Issue must be assigned to exactly one open project. Found: ${openProjects.length}`);
      }
      console.log(`Valid project assignment: ${openProjects[0].name}`);

@adhiamboperes , @BenHenning Do check this out. Thank you

@adhiamboperes
Copy link
Collaborator

@Mayank77maruti this looks like a good attempt. A few notes:

The issue_assigned trigger is invalid in GitHub Actions. The correct trigger is issues with the assigned type.
The current configuration might fail due to this misstep. The on section should look like this:
yaml

on:
  issues:
    types: [opened, labeled, assigned]

Additionally, have you considered using actions/github-script instead of actions/labeler for dynamic label management (add or remove logic)?

Please create a PR so that we can review this further.

@Mayank77maruti Mayank77maruti linked a pull request Dec 5, 2024 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement End user-perceivable enhancements. Impact: Low Low perceived user impact (e.g. edge cases). Work: Medium The means to find the solution is clear, but it isn't at good-first-issue level yet. Z-ibt Temporary label for Ben to keep track of issues he's triaged.
Development

Successfully merging a pull request may close this issue.

5 participants