From fde97753d771a02d7624d590e93b629ff3bd53f2 Mon Sep 17 00:00:00 2001 From: Mateusz Szostok Date: Fri, 2 Aug 2024 08:54:09 +0200 Subject: [PATCH] Support custom AsyncAPI owners --- .github/scripts/maintainers/index.js | 27 ++++++++++++++--------- .github/workflows/update-maintainers.yaml | 2 +- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/scripts/maintainers/index.js b/.github/scripts/maintainers/index.js index 3597d15e0..be32d8da5 100644 --- a/.github/scripts/maintainers/index.js +++ b/.github/scripts/maintainers/index.js @@ -33,26 +33,33 @@ function getCommaSeparatedInputList(list) { ); } +function splitByWhitespace(line) { + return line.trim().split(/\s+/); +} + function extractGitHubUsernames(codeownersContent, core) { - if (!codeownersContent) { - return []; - } + if (!codeownersContent) return []; const uniqueOwners = new Set(); for (const line of codeownersContent.split("\n")) { - // extract any data that is before the '#' char and trim whitespace - const trimmedLine = line.split("#")[0].trim(); + // split by '#' to process comments separately + const [ownersLine, comment = ""] = line.split("#"); + + // 1. Check AsyncAPI custom owners + const triagers = comment.split(/docTriagers:|codeTriagers:/)[1] + if (triagers) { + const owners = splitByWhitespace(triagers) + owners.forEach(owner => uniqueOwners.add(owner)) + } - // split by whitespace to get the owners - const owners = trimmedLine.split(/\s+/); + // 2. Check GitHub native codeowners + const owners = splitByWhitespace(ownersLine); // the 1st element is the file location, we don't need it, so we start with 2nd item for (const owner of owners.slice(1)) { if (!owner.startsWith("@") || owner.includes("/")) { - core.warning( - `Skipping '${owner}' as emails and teams are not supported yet`, - ); + core.warning(`Skipping '${owner}' as emails and teams are not supported yet`); continue; } uniqueOwners.add(owner.slice(1)); // remove the '@' diff --git a/.github/workflows/update-maintainers.yaml b/.github/workflows/update-maintainers.yaml index 9af53e49d..858eb02aa 100644 --- a/.github/workflows/update-maintainers.yaml +++ b/.github/workflows/update-maintainers.yaml @@ -13,7 +13,7 @@ on: - '.github/workflows/update-maintainers.yaml' schedule: - - cron: "0 0 * * MON" # Runs at 10:00 AM UTC every Monday. + - cron: "0 10 * * SUN" # Runs at 10:00 AM UTC every Sunday. workflow_dispatch: