[ 
https://issues.apache.org/jira/browse/BEAM-13925?focusedWorklogId=737799&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-737799
 ]

ASF GitHub Bot logged work on BEAM-13925:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/Mar/22 21:31
            Start Date: 07/Mar/22 21:31
    Worklog Time Spent: 10m 
      Work Description: damccorm commented on a change in pull request #17001:
URL: https://github.com/apache/beam/pull/17001#discussion_r821119491



##########
File path: scripts/ci/pr-bot/findPrsNeedingAttention.ts
##########
@@ -0,0 +1,228 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+const github = require("./shared/githubUtils");
+const commentStrings = require("./shared/commentStrings");
+const { ReviewerConfig } = require("./shared/reviewerConfig");
+const { PersistentState } = require("./shared/persistentState");
+const {
+  BOT_NAME,
+  REPO_OWNER,
+  REPO,
+  PATH_TO_CONFIG_FILE,
+  SLOW_REVIEW_LABEL,
+} = require("./shared/constants");
+
+function hasLabel(pull: any, labelName: string): boolean {
+  const labels = pull.labels;
+  for (const label of labels) {
+    if (label.name.toLowerCase() === labelName.toLowerCase()) {
+      return true;
+    }
+  }
+  return false;
+}
+
+function getTwoWeekdaysAgo(): Date {
+  let twoWeekDaysAgo = new Date(Date.now() - 2 * 24 * 60 * 60 * 1000);
+  const currentDay = new Date(Date.now()).getDay();
+  // If Saturday, sunday, monday, or tuesday, add extra time to account for 
weekend.
+  if (currentDay === 6) {
+    twoWeekDaysAgo.setDate(twoWeekDaysAgo.getDate() - 1);
+  }
+  if (currentDay <= 2) {
+    twoWeekDaysAgo.setDate(twoWeekDaysAgo.getDate() - 2);
+  }
+
+  return twoWeekDaysAgo;
+}
+
+async function isSlowReview(pull: any): Promise<boolean> {
+  if (!hasLabel(pull, "Next Action: Reviewers")) {
+    return false;
+  }
+  const lastModified = new Date(pull.updated_at);
+  const sevenDaysAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
+  if (lastModified.getTime() < sevenDaysAgo.getTime()) {
+    return true;
+  }
+
+  // If it has no comments from a non-bot/author in the last 2 weekdays, 
return true
+  const twoWeekDaysAgo = getTwoWeekdaysAgo();
+  if (lastModified.getTime() < twoWeekDaysAgo.getTime()) {
+    const pullAuthor = pull.user.login;
+    const githubClient = github.getGitHubClient();
+    const comments = (
+      await githubClient.rest.issues.listComments({
+        owner: REPO_OWNER,
+        repo: REPO,
+        issue_number: pull.number,
+      })
+    ).data;
+    for (let i = 0; i < comments.length; i++) {
+      const comment = comments[i];
+      if (
+        comment.user.login !== pullAuthor &&
+        comment.user.login !== BOT_NAME
+      ) {
+        return false;
+      }
+    }
+
+    const reviewComments = (
+      await githubClient.rest.pulls.listReviewComments({
+        owner: REPO_OWNER,
+        repo: REPO,
+        pull_number: pull.number,
+      })
+    ).data;
+    for (let i = 0; i < reviewComments.length; i++) {
+      const comment = reviewComments[i];
+      if (
+        comment.user.login !== pullAuthor &&
+        comment.user.login !== BOT_NAME
+      ) {
+        return false;
+      }
+    }
+
+    return true;
+  }
+
+  return false;
+}
+
+async function assignToNewReviewers(
+  pull: any,
+  reviewerConfig: typeof ReviewerConfig,

Review comment:
       Yeah, it is - if I remove it, `tsc` errors with `'ReviewerConfig' refers 
to a value, but is being used as a type here. Did you mean 'typeof 
ReviewerConfig'?`

##########
File path: scripts/ci/pr-bot/findPrsNeedingAttention.ts
##########
@@ -0,0 +1,228 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+const github = require("./shared/githubUtils");
+const commentStrings = require("./shared/commentStrings");
+const { ReviewerConfig } = require("./shared/reviewerConfig");
+const { PersistentState } = require("./shared/persistentState");
+const {
+  BOT_NAME,
+  REPO_OWNER,
+  REPO,
+  PATH_TO_CONFIG_FILE,
+  SLOW_REVIEW_LABEL,
+} = require("./shared/constants");
+
+function hasLabel(pull: any, labelName: string): boolean {
+  const labels = pull.labels;
+  for (const label of labels) {
+    if (label.name.toLowerCase() === labelName.toLowerCase()) {
+      return true;
+    }
+  }
+  return false;
+}
+
+function getTwoWeekdaysAgo(): Date {
+  let twoWeekDaysAgo = new Date(Date.now() - 2 * 24 * 60 * 60 * 1000);
+  const currentDay = new Date(Date.now()).getDay();
+  // If Saturday, sunday, monday, or tuesday, add extra time to account for 
weekend.
+  if (currentDay === 6) {
+    twoWeekDaysAgo.setDate(twoWeekDaysAgo.getDate() - 1);
+  }
+  if (currentDay <= 2) {
+    twoWeekDaysAgo.setDate(twoWeekDaysAgo.getDate() - 2);
+  }
+
+  return twoWeekDaysAgo;
+}
+
+async function isSlowReview(pull: any): Promise<boolean> {
+  if (!hasLabel(pull, "Next Action: Reviewers")) {
+    return false;
+  }
+  const lastModified = new Date(pull.updated_at);
+  const sevenDaysAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
+  if (lastModified.getTime() < sevenDaysAgo.getTime()) {
+    return true;
+  }
+
+  // If it has no comments from a non-bot/author in the last 2 weekdays, 
return true
+  const twoWeekDaysAgo = getTwoWeekdaysAgo();
+  if (lastModified.getTime() < twoWeekDaysAgo.getTime()) {
+    const pullAuthor = pull.user.login;
+    const githubClient = github.getGitHubClient();
+    const comments = (
+      await githubClient.rest.issues.listComments({
+        owner: REPO_OWNER,
+        repo: REPO,
+        issue_number: pull.number,
+      })
+    ).data;
+    for (let i = 0; i < comments.length; i++) {
+      const comment = comments[i];
+      if (
+        comment.user.login !== pullAuthor &&
+        comment.user.login !== BOT_NAME
+      ) {
+        return false;
+      }
+    }
+
+    const reviewComments = (
+      await githubClient.rest.pulls.listReviewComments({
+        owner: REPO_OWNER,
+        repo: REPO,
+        pull_number: pull.number,
+      })
+    ).data;
+    for (let i = 0; i < reviewComments.length; i++) {
+      const comment = reviewComments[i];
+      if (
+        comment.user.login !== pullAuthor &&
+        comment.user.login !== BOT_NAME
+      ) {
+        return false;
+      }
+    }
+
+    return true;
+  }
+
+  return false;
+}
+
+async function assignToNewReviewers(
+  pull: any,
+  reviewerConfig: typeof ReviewerConfig,
+  stateClient: typeof PersistentState

Review comment:
       Same - `tsc` will throw if I don't do this




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 737799)
    Time Spent: 13h 20m  (was: 13h 10m)

> Automate Reviewer Assignment
> ----------------------------
>
>                 Key: BEAM-13925
>                 URL: https://issues.apache.org/jira/browse/BEAM-13925
>             Project: Beam
>          Issue Type: Improvement
>          Components: beam-community
>            Reporter: Danny McCormick
>            Assignee: Danny McCormick
>            Priority: P2
>          Time Spent: 13h 20m
>  Remaining Estimate: 0h
>
> Right now, we don't have a well defined automated system for staying on top 
> of pull request reviews - we rely on contributors being able to find the 
> correct OWNERS file and committers manually triaging/calling attention to old 
> pull requests. We should add automation driven by GitHub Actions to 
> automatically round robin new PR reviews to a set of contributors, thus 
> balancing the load.
>  
> Design doc here - 
> https://docs.google.com/document/d/1FhRPRD6VXkYlLAPhNfZB7y2Yese2FCWBzjx67d3TjBo/edit#



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to