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

GHA add comments to prework issue 4820 #6873

Open
wants to merge 10 commits into
base: gh-pages
Choose a base branch
from

Conversation

partapparam
Copy link
Member

@partapparam partapparam commented May 21, 2024

Fixes #4820

What changes did you make?

  • The following event/activity types are set up to trigger the workflow

    • issues: opened, assigned, unassigned, closed as completed, or closed as not planned
      • Updated issue-trigger.yml file with new job Add-Comment-To-Prework-Issue
    • issue_comment: created
      • Created issue-comment-trigger.yaml file and created new job Add-Comment-To-Prework-Issue
    • pull_request: opened, closed
      • Updated pull-request-trigger.yaml file with new job Add-Comment-To-Prework-Issue
    • pull_request_review: submitted
      • Created pull-request-review-trigger.yaml file and created new job Add-Comment-To-Prework-Issue
    • pull_request_review_comment: created
      • Created pull-request-review-comment-trigger.yaml file and created new job Add-Comment-To-Prework-Issue
  • Created prework-issue-reusable-workflow folder in github-actions

  • Added files to github-actions/utils folder

  • Created prework-issue-comment-reusable-workflow.yaml with the following steps:

    • Determine the contributor generating the event/activity:
      • Created get-activity-detail.js
    • Search for an issue with a "prework" label that is assigned to the contributor
      • Created get-prework-issue.js and get-issue-by-label.js
    • If the prework issue is closed, reopen it
      • Created update-prework-issue-status.js and reopen-issue.js
    • If the above issue is reopened, move it in the "In Progress" column
      • Created update-issue-project-card.js
    • Add a comment to the prework issue describing the event/activity
      • Created add-prework-issue-comment.js

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

  • To create a GitHub Action that will be triggered by GitHub issue, issue_comment, pull_request, pull_request_review and pull_request_review_comment events and will post comments to the developer's pre-work issue describing the developer's activities.

Notes

  • Folder structure
    • I tried to follow the HFLA Github Actions guide with creating the new folders
    • The new triggers call a Reusable Workflow, all jobs to accomplish the required work are in this workflow.
    • The files required by the prework-issue-comment-reusable-workflow.yaml are located in the github-actions/prework-issue-reusable-workflow folder
  • For testing purposes, I added permissions: issues: write but I believe this is not required in this repo. I can remove once tested by the reviewer.
  • HFLA Project Board (number: 7) - In Progress Column value is hard coded.
    • I decided to provide the ProjectCardId rather than use an additional step to query the API.
    • For testing, you will need to update the ProjectCardId to your local project board and use the below query to fetch from the GraphQL API.
query{
   repository(owner: "hackforla", name: "website") {
     projects(first: 10) {
       nodes {
         name
         number
         id
         columns(first: 10) {
           __typename
           nodes {
             name
             id
           }
         }
       }
     }
   }
 }

@HackforLABot HackforLABot added this to PR Needs review (Automated Column, do not place items here manually) in Project Board May 21, 2024
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 partapparam-gha-add-comments-4820 gh-pages
git pull https://github.com/partapparam/website.git gha-add-comments-4820

@github-actions github-actions bot added role: back end/devOps Tasks for back-end developers Status: Updated No blockers and update is ready for review Feature: Onboarding/Contributing.md size: 5pt Can be done in 19-30 hours Complexity: Extra Large labels May 21, 2024
@@ -0,0 +1,136 @@
// Import modules
var fs = require("fs")

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused variable fs.
@partapparam partapparam marked this pull request as ready for review May 21, 2024 19:23
@jphamtv
Copy link
Member

jphamtv commented May 30, 2024

Hey @marioantonini, when you have a moment please add your ETA and availability. Thanks!

@partapparam
Copy link
Member Author

Hey @marioantonini @jphamtv any update on this PR? I'm hoping to get some feedback and close it so I can work on more issues. Thank you!

@marioantonini
Copy link
Member

@partapparam @jphamtv Totally missed this, will get to it today.

@t-will-gillis t-will-gillis self-requested a review June 16, 2024 20:14
Copy link
Member

@t-will-gillis t-will-gillis left a comment

Choose a reason for hiding this comment

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

Hey @partapparam Thanks for working on this issue! Great job so far- I started testing in my own repo. These are my comments so far:
For a test Pull Request:

  • In pull-request-trigger.yml , line 70, the section of the if statement github.event_name == 'pull_request' is able to be removed since the yml is triggered by the pull request, e.g. line 70 can be if: ${{ github.event.action == 'opened' || github.event.action == 'closed' }}

  • In prework-issue-comment-reusable-workflow.yaml, the workflow failed right away because of the "if" statements in the "script" - I think you can get around this by placing your "if" statements at the head of each step, in front of "name" - I made some edits and got through this snag

    Screenshot 2024-06-16 210059
  • When prework-issue-comment-reusable-workflow.yaml calls get-activity-detail.js, the workflow get snagged because on line 23, the event is "pull_request_target" rather than on "pull_request".

  • I tweaked this and the following run was snagged on the next step "Get prework issue" - though I am not sure why yet.

  • Also, in the "Move issue" step, the workflow got snagged by "const" as shown:

    Screenshot 2024-06-16 211730

  • I know that the original issue requested all of the conditions you are checking for. When this is running we can check for certain however I think that some of the conditions are overlapping each other. We can look at this later....

  • FYI, CodeQL has flagged an "Unused variable" in get-activity-details.js see above and in "Files changed"

Thanks again

Project Board automation moved this from PR Needs review (Automated Column, do not place items here manually) to test-pending-approval (Automated Column, do not place items here manually) Jun 17, 2024
@ExperimentsInHonesty ExperimentsInHonesty added the Feature: Refactor GHA Refactoring GitHub actions to fit latest architectural norms label Jul 2, 2024
@t-will-gillis
Copy link
Member

From our previous conversation on Slack:
You might have seen the Sunset Notice on the Project Board. GitHub is discontinuing Projects (classic) and before August Hack for LA needs to migrate to the Projects Beta. After talking with Bonnie and the team, doing some testing, and checking the calendar, we have decided that the Website is going to migrate to the new Projects Beta on Monday, June 24th.

Sorry for the short notice- this is happening very quickly. Each of you have currently submitted a PR that involves GitHub Actions and wanted to let you know that we will need to hold off merging any new GHAs until after the migration. To make this interesting, also need to let you know that after migration, any of the existing API calls using a ‘column’ reference will no longer work because Projects Beta is not structured the same- the new term is ‘status’ and it is not interchangeable. Some other REST API endpoints that will be deprecated soon are here.

So for all of you, after migration your workflows will need to be tested using Projects Beta. If you already installed Projects (classic) on your repo you can migrate to Projects Beta for early testing. (FYI after migrating you can reopen Projects (classic)- but do that immediately if you want to keep it because that option disappeared for me after a day.)

For any workflows that currently involve moving an issue to or from a ‘column’, this should be doable using GraphQL, ProjectV2, and Status. (I have not done this yet- still learning!) And/or we can discuss other options.

Finally, one last thing I notice is that for all of you there are parts of your issue that overlap with the other two’s issues. As one example, all three of your issues include posting messages to a member’s “Pre-work Checklist”. Unfortunately, this should have been caught earlier so that each issue was worked on after the other was completed, so that you would not each have a different solution to the same problem. (I could also be wrong and maybe there will not be any conflicts.)

@t-will-gillis
Copy link
Member

From 6/24 Slack
Hey everyone- we have migrated to Projects Beta. As I mentioned before we made revisions to all workflows that previously involved 'columns' including removing all workflow jobs that used the alex-page automation since these no longer work. "Issue Trigger", "Pull Request Trigger", and "Schedule-Friday" plus related js files had the biggest changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Complexity: Extra Large Feature: Onboarding/Contributing.md 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 Status: Updated No blockers and update is ready for review
Projects
Status: test-pending-approval (Automated Column, do not place items here manually)
Project Board
  
test-pending-approval (Automated Colu...
Development

Successfully merging this pull request may close these issues.

Create GHA to add comments to prework issues documenting issues events
5 participants