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 minimizeIssueComments() in "Schedule Friday" to avoid secondary rate limit #7562

Open
6 tasks
t-will-gillis opened this issue Oct 4, 2024 · 1 comment
Labels
Complexity: Medium Feature: Refactor GHA Refactoring GitHub actions to fit latest architectural norms Ready for Prioritization role: back end/devOps Tasks for back-end developers size: 5pt Can be done in 19-30 hours

Comments

@t-will-gillis
Copy link
Member

t-will-gillis commented Oct 4, 2024

Overview

For each of the scheduled runs of "Schedule Friday" since Sept. 13th, the workflow has failed due to the minimizeIssueComments() function exceeding GitHub's secondary rate limit. We need to make changes to the workflow to avoid this error.

Details

Upon review of the September 13th workflow logs, it can be shown that the automation made GraphQL calls 683 times in order to minimize these comments. Since most of these comments have already been closed by an earlier run of this automation, making GraphQL requests to close these already-closed comments is superfluous and contributes to exceeding the rate limit.

Therefore, the proposal is to change the existing limit of closing all comments older than 7 days, to closing comments older than 7 days but more recent than 28 days. This should reduce the total number of comments to process and hopefully will help us to stay under the secondary rate limit.

Action Items

  • Review the "Schedule Friday" workflow logs, starting with the September 13th run, and note the error occurring due to the secondary rate limit.

  • In add-label.js, locate the following code (near lines 190-200), and replace:

      // If this event is more than 7 days old AND this event is a comment by the GitHub Actions Bot, then hide the comment as outdated.
      if (!isMomentRecent(eventObj.created_at, sevenDayCutoffTime) && eventType === 'commented' && isCommentByBot(eventObj)) { 
        console.log(`Comment ${eventObj.node_id} is outdated (i.e. > 7 days old) and will be minimized.`);
        commentsToBeMinimized.push(eventObj.node_id); // retain node id so its associated comment can be minimized later
      }
    

    with:

      // If this event is more than 7 days but less than 30 days old AND this event is a comment by the GitHub Actions Bot, then hide the comment as outdated.
      if (isMomentRecent(eventObj.created_at, expiredDayCutoffTime) && !isMomentRecent(eventObj.created_at, sevenDayCutoffTime) && eventType === 'commented' && isCommentByBot(eventObj)) { 
        console.log(`Comment ${eventObj.node_id} is outdated (i.e. > 7 days old) and will be minimized.`);
        commentsToBeMinimized.push(eventObj.node_id); // retain node id so its associated comment can be minimized later
      }
    
  • After const inactiveUpdatedByDays = 14;, add new line:

    const expiredDays = 30;
    
  • After const fourteenDayCutoffTime, add new lines:

    const expiredDayCutoffTime = new Date();
    expiredDayCutoffTime.setDate(expiredDayCutoffTime.getDate() - expiredDays);
    
  • Although this issue involves GitHub Actions, testing is not required.

For Merge Team:

Resources/Instructions

@t-will-gillis t-will-gillis added role: back end/devOps Tasks for back-end developers Complexity: Large Feature: Refactor GHA Refactoring GitHub actions to fit latest architectural norms size: 5pt Can be done in 19-30 hours labels Oct 4, 2024
@github-project-automation github-project-automation bot moved this to New Issue Approval in P: HfLA Website: Project Board Oct 4, 2024
@t-will-gillis t-will-gillis added the Draft Issue is still in the process of being created label Oct 4, 2024
@t-will-gillis t-will-gillis self-assigned this Oct 4, 2024
@HackforLABot

This comment was marked as resolved.

@ExperimentsInHonesty ExperimentsInHonesty added this to the 06. Data strategy milestone Oct 7, 2024
@t-will-gillis t-will-gillis removed their assignment Oct 26, 2024
@t-will-gillis t-will-gillis removed the Draft Issue is still in the process of being created label Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Complexity: Medium Feature: Refactor GHA Refactoring GitHub actions to fit latest architectural norms Ready for Prioritization role: back end/devOps Tasks for back-end developers size: 5pt Can be done in 19-30 hours
Projects
Status: New Issue Approval
Development

No branches or pull requests

3 participants