Abacn commented on code in PR #24034: URL: https://github.com/apache/beam/pull/24034#discussion_r1018458276
########## .github/workflows/workflows-issues-manager.yml: ########## @@ -0,0 +1,85 @@ +# 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. + +name: Workflows Issues Manager + +on: + workflow_dispatch: + schedule: + - cron: '0 */12 * * *' + push: + branches: ['feat/issues-manager'] Review Comment: what does this branch for? ########## scripts/ci/workflows-issues-manager/constants.js: ########## @@ -0,0 +1,17 @@ +const DEFAULT_K = 5; + +const MIN_RUNS = { Review Comment: I understood this are workflow identifier and the unstable threshold parameter. A more detailed comment string will help to understand. ########## scripts/ci/workflows-issues-manager/index.js: ########## @@ -0,0 +1,130 @@ +const { ISSUES_MANAGER_TAG } = require("./constants.js"); +const { getRepoWorkflows, getRunsForWorkflow } = require("./workflows.js"); +const { getRepoIssues, closeIssue, createIssue} = require("./issues"); + + +const checkConclusions = (conclusions) => { + return ({ conclusion }) => { + return conclusions.includes(conclusion); + }; +}; + +const filterRuns = (runs, conclusions) => { + return runs.filter((run) => conclusions.includes(run.conclusion)); +}; + +const splitWorkflows = async ({ github, context }, workflows) => { + let lastKRuns = []; + let unstable = []; + let stable = []; + let permared = []; + + //TODO: make it parallel + for (const workflow of workflows) { + const { workflow_runs } = await getRunsForWorkflow({ github, context }, workflow); + let filteredRuns = filterRuns(workflow_runs, ["success", "failure", "timed_out"]); + + const output = filteredRuns.map( + ({ id, name, conclusion, event, head_branch }) => `${id} | ${name} | ${conclusion} | ${event} |${head_branch}` + ); + console.log("FILTERED WORKFLOW RUNS", output); + + lastKRuns.push({ + workflow, + filteredRuns, + }); + } + + const isSuccessful = checkConclusions(["success"]); + const isFailure = checkConclusions(["failure", "timed_out"]); + + //TODO: Handle case when filteredRuns is empty + + lastKRuns = lastKRuns.filter(({ filteredRuns }) => filteredRuns.length > 0); + + unstable = lastKRuns.filter(({ filteredRuns }) => filteredRuns.some(isFailure) && !filteredRuns.every(isFailure)); Review Comment: Looks like unstable means the there is at least one flake in last K runs. Wondering if this could flood open issues; or keep closing and open issues. I do not have a mind about the preferred strategy but we could rollout this gradually (first monitor a subset of workflows or so) to see if it works well. ########## .github/workflows/workflows-issues-manager.yml: ########## @@ -0,0 +1,85 @@ +# 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. + +name: Workflows Issues Manager + +on: + workflow_dispatch: + schedule: + - cron: '0 */12 * * *' + push: + branches: ['feat/issues-manager'] + +jobs: + workflows_validation: + name: Workflows Issues Manager + permissions: + contents: write + pull-requests: write + checks: read + issues: read + statuses: read + # Don't run on forks +# if: github.repository == 'apache/beam' Review Comment: (a mark and remove the comment before merge) -- 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]
