damccorm commented on a change in pull request #16898:
URL: https://github.com/apache/beam/pull/16898#discussion_r813267514



##########
File path: scripts/ci/pr-bot/shared/githubUtils.ts
##########
@@ -0,0 +1,96 @@
+/*
+ * 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 { Octokit } = require("@octokit/rest");
+const { REPO_OWNER, REPO } = require("./constants");
+
+export function getGitHubClient() {
+  let githubToken = process.env["GITHUB_TOKEN"];
+  if (!githubToken) {
+    throw new Error(
+      "No github token provided - process.env['GITHUB_TOKEN'] must be set."
+    );
+  }
+  return new Octokit({ auth: githubToken });
+}
+
+export async function addPrComment(pullNumber: number, body: string) {
+  const githubClient = getGitHubClient();
+  await githubClient.rest.issues.createComment({
+    owner: REPO_OWNER,
+    repo: REPO,
+    issue_number: pullNumber,
+    body: body,
+  });
+}
+
+export async function nextActionReviewers(
+  pullNumber: number,
+  existingLabels: any[]

Review comment:
       Done - I think there are places in this work where it won't be 
beneficial to avoid any though (specifically dealing with GitHub payloads which 
aren't typed on their own). This one is probably fine though.

##########
File path: scripts/ci/pr-bot/shared/githubUtils.ts
##########
@@ -0,0 +1,96 @@
+/*
+ * 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 { Octokit } = require("@octokit/rest");
+const { REPO_OWNER, REPO } = require("./constants");
+
+export function getGitHubClient() {
+  let githubToken = process.env["GITHUB_TOKEN"];

Review comment:
       I'd actually vote to keep it as is. The env check is cheap, and this is 
the only place we ever access it. Not storing it in any persistent state has 
the advantage of making it very obvious that we're not accidentally leaking it 
anywhere.

##########
File path: scripts/ci/pr-bot/shared/constants.ts
##########
@@ -0,0 +1,30 @@
+/*
+ * 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 path = require("path");
+
+export const REPO_OWNER = "apache";
+export const REPO = "beam";
+export const PATH_TO_CONFIG_FILE = path.join(
+  __dirname,
+  "../../../../../.github/REVIEWERS.yml"

Review comment:
       I didn't want to do that since I don't think there's a consistent way to 
get the repo root from both GitHub actions and locally, and I'd like this 
constant to be valid in both cases.




-- 
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]


Reply via email to