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

Refactor "Issue Trigger" for issue created from "Inactive Members" #7132

Merged

Conversation

t-will-gillis
Copy link
Member

@t-will-gillis t-will-gillis commented Jul 21, 2024

Fixes #7075

What changes did you make?

  • a.) In issue-trigger.yml, added HACKFORLA_GRAPHQL_TOKEN
  • b.) In check-labels.js, added code lines 37-40 to retrieve issue and status field id values, then change issue's status to "Questions / In Review"
  • c.) In post-labels-comment.js, added check at line 38 so that if issue title matches "Hack for LA website bot..." the function returns without adding a comment.
  • d.) Added new status-field-ids.js
  • e.) Added new module mutate-issue-status.js (thank you @moazDev1 )
  • f.) Added new module query-issue-info.js (same!)
  • g.) Throughout, add explicit semi-colons where missing

Why did you make the changes (we will use this info to test)?

  • a.) When using a GraphQL mutation, we need a token with "Project" scopes enabled
  • b.) This restores the behavior of the workflow before migration to Projects Beta
  • c.) The comment is not needed since all labels are present
  • d.) This file added b/c these values will be needed for other functions, and since these ids do not change it makes more sense to have a simple lookup for the value than performing a GraphQL query each time we need a value
  • e.) This file mutates / changes the status of an issue given the issues id value
  • f.) This file returns an issue's given its issue number. Note that this is done in GraphQL b/c the typical REST API for looking up issues does not seem to return the correct id value
  • g.) Did this to anticipate and avoid Code QL alerts

Screenshots of Proposed Changes Of The Website (if any, please do not screen shot code changes)

  • No visual changes to website

Notes for Testing

In order to review this PR you will need to have your repo environment set up for testing.

  • See Hack for LA's GitHub Actions (revised doc). This document should be mostly up to date still, but if you run into problems let us know

  • To find your own id values to use while testing:

    query findStatusSubfieldIds ($login: String!, $projNum: Int!, $fieldName: String!   ) {
      user(login: $login) {
        projectV2(number: $projNum) {
          id
          field(name:$fieldName) { 
            ... on ProjectV2SingleSelectField { 	
            id options{ 
                id
                name
                ... on ProjectV2SingleSelectFieldOption {
                  id
                }
              } 
            }
          }
        }
      }
    }
    

    and in the 'Variables' section underneath, replace for your GitHub login and project number:

    {
      "login":"<replace with yours>",
      "projNum": <replace with yours>,
      "fieldName": "Status"
    }
    
    • Next, create a new issue and give it the title "The Hack for LA website bot removed me"
    • A successful test will result in the issue receiving five labels including Complexity: Small, Feature: Administrative, ready for dev leads, role: dev leads, and size: 0.25pt. Additionally, the issue will be moved to the status of "Questions / In Review"
  • Successful run of "Issue Trigger"

  • Issue created Yours will not look exactly like this...

authorize workflow for 'project' scope with GRAPHQL token
add GraphQL query for issue and status field ids then mutate, also add explicit semi-colons (to avoid CodeQL) and standardize spaces
capitalize GitHub
primarily added line so if title of issue matches "Hack for LA Website Bot...", skip posting comment (not needed)
adding explicit semi-colons
adding status field id numbers
fix mapping values
Copy link

Want to review this pull request? Take a look at this documentation for a step by step guide!


From your project repository, check out a new branch and test the changes.

git checkout -b t-will-gillis-refactor-issue-trigger-7075 gh-pages
git pull https://github.com/t-will-gillis/website.git refactor-issue-trigger-7075

@github-actions github-actions bot added role: back end/devOps Tasks for back-end developers Complexity: Large Feature: Board/GitHub Maintenance Project board maintenance that we have to do repeatedly Feature: Refactor GHA Refactoring GitHub actions to fit latest architectural norms size: 5pt Can be done in 19-30 hours Feature: API Coding requires using an API labels Jul 21, 2024
Remove correlation of statusValues with actual names
revert to original
Adding reference key with actual status names
corrected function comments
added ref link to octokit rest api
@moazDev1 moazDev1 self-requested a review July 25, 2024 08:10
@moazDev1
Copy link
Member

Availability: Sat - Mon 6 PM - 10 PM
ETA: 8/1

Copy link
Member

@moazDev1 moazDev1 left a comment

Choose a reason for hiding this comment

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

Hey @t-will-gillis, thanks for working on this issue and making this clear description of what you have done!

I created a couple of issues and everything worked perfectly for me. Issues including the title "Hack for LA Website Bot" automatically added the required labels, and other issues with missing labels triggered a comment asking to add the missing labels.

I just have a question regarding line 40 in check-labels.js:

mutateIssueStatus(github, context, itemId, newStatusValue);

Dones't this function need await before it since it's async? I know it works which's surprising but just want to mentioned that. Otherwise, everything looks perfect for me.

Added 'await' to call to `mutateIssueStatus`
Refactor line 38, refactor some console.log()
revert console.log() two locations
@t-will-gillis
Copy link
Member Author

t-will-gillis commented Jul 31, 2024

Thanks @moazDev1! I added await as you suggested

@t-will-gillis t-will-gillis requested a review from moazDev1 July 31, 2024 22:23
Copy link
Member

@moazDev1 moazDev1 left a comment

Choose a reason for hiding this comment

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

Thank you @t-will-gillis, everything looks perfect for me.

Keep going!

@t-will-gillis t-will-gillis merged commit 9a6384a into hackforla:gh-pages Aug 2, 2024
3 checks passed
@t-will-gillis t-will-gillis deleted the refactor-issue-trigger-7075 branch August 2, 2024 17:18
@t-will-gillis
Copy link
Member Author

Thank you for reviewing this, @moazDev1!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Complexity: Large Feature: API Coding requires using an API Feature: Board/GitHub Maintenance Project board maintenance that we have to do repeatedly Feature: Refactor GHA Refactoring GitHub actions to fit latest architectural norms role: back end/devOps Tasks for back-end developers size: 5pt Can be done in 19-30 hours
Projects
Development

Successfully merging this pull request may close these issues.

Post PBB migration: Refactor "Issue Trigger"
2 participants