jerryshao commented on code in PR #14778: URL: https://github.com/apache/gravitino/pull/14778#discussion_r4548319185
########## .github/scripts/cve-scan-notify.cjs: ########## @@ -0,0 +1,84 @@ +/* + * 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. + */ +'use strict'; +// Keeps one tracking issue for the scheduled release artifact scan (.github/workflows/cve-scan.yml): +// a failed run opens or updates it, and the first passing scheduled run closes it again. +// The title is the only key, so it must stay stable. Only issues opened by the bot count. +const ISSUE_TITLE = 'Scheduled release artifact scan failed'; +const ISSUE_AUTHOR = 'github-actions[bot]'; +const README_PATH = '.github/trivy/README.md'; +const FAILED_RESULTS = ['failure', 'cancelled']; +// Returns the names of the jobs that did not pass. A run in which no job succeeded verified nothing, +// so it counts as failed with every job listed. +function failedJobs(needs) { + const entries = Object.entries(needs || {}); + const failed = entries.filter(([, job]) => FAILED_RESULTS.includes(job && job.result)).map(([name]) => name); + if (failed.length === 0 && !entries.some(([, job]) => job && job.result === 'success')) { + return entries.map(([name]) => name); + } + return failed.sort(); +} +function parseNeeds(raw) { + const needs = JSON.parse(raw); + if (!needs || typeof needs !== 'object' || Array.isArray(needs)) throw new Error('NEEDS is not a JSON object'); + return needs; +} +async function findOpenIssue({ github, owner, repo }) { + const issues = await github.paginate(github.rest.issues.listForRepo, { owner, repo, state: 'open', per_page: 100 }); Review Comment: This pages through every open issue in the repository on each run, which is slow in a busy repo. Pass the creator filter (the bot login) or a label to listForRepo so only a few issues are fetched. -- 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]
