From fb3db798a64982a4987fca5b3779dc8318d1112a Mon Sep 17 00:00:00 2001 From: Luca Lanziani Date: Mon, 1 Jul 2024 17:53:55 +0200 Subject: [PATCH] [chore] add section for components looking for new code owners (#33397) **Description:** Add a section to the weekly report with the list of components looking for code owners based on the `status.codeowners.seeking_new` property of the metadata.yaml file. **Link to tracking Issue:** #31419 **Testing:** ``` act -j get_issues -e <(echo '{"repository": {"owner": {"login": "your-github-username"}}}') -s [GITHUB_TOKEN=](09 i0) ``` --------- Co-authored-by: Curtis Robert Co-authored-by: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> --- .../scripts/generate-weekly-report.js | 54 ++++++++++++++----- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/.github/workflows/scripts/generate-weekly-report.js b/.github/workflows/scripts/generate-weekly-report.js index 8633842738cc..f496418e6997 100644 --- a/.github/workflows/scripts/generate-weekly-report.js +++ b/.github/workflows/scripts/generate-weekly-report.js @@ -190,6 +190,24 @@ async function getIssuesData({octokit, context}) { return stats } +function generateComponentsLookingForOwnersReportSection(lookingForOwners) { + let count = 0 + let section = [] + + // NOTE: the newline after is required for markdown to render correctly + section.push(`
+ Components \n`); + for (const components of Object.values(lookingForOwners)) { + count += Object.keys(components).length + for (const [componentName, metadatafilePath] of Object.entries(components)) { + section.push(`- [ ] [${componentName}](${path.join("../blob/main/", path.dirname(metadatafilePath))}) `) + } + } + + section.push(`
`) + return {count, section} +} + function generateReport({ issuesData, previousReport, componentData }) { const out = [ `## Format`, @@ -228,9 +246,10 @@ function generateReport({ issuesData, previousReport, componentData }) { // generate report for components out.push('\n## Components Report', '
    '); - for (const lbl of Object.keys(componentData)) { + var {byStatus, lookingForOwners} = componentData + for (const lbl of Object.keys(byStatus)) { const section = [``]; - const data = componentData[lbl]; + const data = byStatus[lbl]; const count = Object.keys(data).length; section.push(`
  • ${lbl}: ${count}`); @@ -247,6 +266,11 @@ function generateReport({ issuesData, previousReport, componentData }) { section.push('
  • '); out.push(section.join('\n')); } + + let {count, section} = generateComponentsLookingForOwnersReportSection(lookingForOwners) + out.push(`
  • Seeking new code owners: ${count}`) + out.push(...section) + out.push('
  • ') out.push('
'); const report = out.join('\n'); @@ -387,37 +411,43 @@ function processFiles(files) { } const processStatusResults = (results) => { - const filteredResults = {}; - + const byStatus = {}; + const lookingForOwners = {}; for (const component in results) { for (const name in results[component]) { const { path, data } = results[component][name]; - if (data && data.status && data.status.stability) { + if (data && data.status) { + if (data.status.stability) { const { stability } = data.status; const statuses = ['unmaintained', 'deprecated']; for (const status of statuses) { if (stability[status] && stability[status].length > 0) { - if (!filteredResults[status]) { - filteredResults[status] = {}; + if (!byStatus[status]) { + byStatus[status] = {}; } - filteredResults[status][name] = { path, stability: data.status.stability, component }; + byStatus[status][name] = { path, stability: data.status.stability, component }; } } + } + if (data.status.codeowners && data.status.codeowners.seeking_new) { + if (!(component in lookingForOwners)) { + lookingForOwners[component] = {} + } + lookingForOwners[component][name] = path + } } } } - return filteredResults; + return {byStatus, lookingForOwners}; }; async function processComponents() { const results = findFilesByName(`.`, 'metadata.yaml'); const resultsClean = processFiles(results) - const resultsWithStability = processStatusResults(resultsClean) - return resultsWithStability - + return processStatusResults(resultsClean) } async function main({ github, context }) {