From b28a3fd32404aa12d82daa4cb918a54131c048d3 Mon Sep 17 00:00:00 2001 From: Aetherinox Date: Sat, 12 Oct 2024 17:57:51 -0700 Subject: [PATCH] ci: refactor issues and label workflows --- .github/workflows/issues-scan.yml | 14 ++-- .github/workflows/issues-stale.yml | 105 +++++++++++++++------------- .github/workflows/labels-create.yml | 8 +-- 3 files changed, 66 insertions(+), 61 deletions(-) diff --git a/.github/workflows/issues-scan.yml b/.github/workflows/issues-scan.yml index e125ddb..959ce3b 100644 --- a/.github/workflows/issues-scan.yml +++ b/.github/workflows/issues-scan.yml @@ -1,11 +1,11 @@ # # -# @parent : github workflow -# @desc : pull request autoscan -# scans all of the files related to a particular pull request -# if the code in the files being submitted contains code that is forbidden, -# a report is generated and posted as a comment in the PR. -# @author : Aetherinox -# @url : https://github.com/Aetherinox +# @type github workflow +# @desc pull request autoscan +# scans all of the files related to a particular pull request +# if the code in the files being submitted contains code that is forbidden, +# a report is generated and posted as a comment in the PR. +# @author Aetherinox +# @url https://github.com/Aetherinox # # name: "🎫 Issues › Scan" diff --git a/.github/workflows/issues-stale.yml b/.github/workflows/issues-stale.yml index 029b6b4..1c0af17 100644 --- a/.github/workflows/issues-stale.yml +++ b/.github/workflows/issues-stale.yml @@ -1,8 +1,13 @@ # # -# @parent : github workflow -# @desc : checks each issue / PR for a valid label -# @author : Aetherinox -# @url : https://github.com/Aetherinox +# @type github workflow +# @desc creates repository labels if they are not yet installed +# issues marked as stale after 30 days, given tag Status 𐄂 Stale +# inactive issues closed after 180 days, given tag Status 𐄂 Locked +# inactive pr closed after 365 days, given tag Status 𐄂 Locked +# issues marked stale after 30 days, given tag Status 𐄂 Stale +# issues marked closed 7 days after being marked stale, given tag Status 𐄂 Autoclosed +# @author Aetherinox +# @url https://github.com/Aetherinox # # This Github action must be activated manually. This workflow script will do the # following: @@ -270,9 +275,9 @@ jobs: Change last number ( 36 = hours ) */ - const expireAfterMs = 1000 * 60 * 60 * 36; // milliseconds ( 36 hours ) - const curtime = new Date( ).getTime( ); // 1711471510629 - const issues = await github.rest.issues.listForRepo( { owner: context.repo.owner, repo: context.repo.repo, state: 'open' } ); + const expireAfterMs = 1000 * 60 * 60 * 36; // milliseconds ( 36 hours ) + const curtime = new Date( ).getTime( ); // 1711471510629 + const issues = await github.rest.issues.listForRepo( { owner: context.repo.owner, repo: context.repo.repo, state: 'open' } ); console.log( ` 📦── Found ${issues.data.length} open issues` ); @@ -338,7 +343,7 @@ jobs: Label > Bugs */ - const bug_bIncWordT = bug_words.some( s => s.includes( iss_title_lc ) || iss_title_lc.includes( s ) ); + const bug_bIncWordT = bug_words.some( s => s.includes( iss_title_lc ) || iss_title_lc.includes( s ) ); /* Find regex based phrases @@ -347,9 +352,9 @@ jobs: https://regex101.com/r/Z99Gnq/2 */ - const bug_findWordList = /^\b(?:I?\s*have\s*(?:a|an)\s*(?:issue|problem|bug))|(?:will\s*not\s*work)|(?:it\s*is\s*(?:broken|broke|stuck))|(?:found\s*(?:an?|the)\s*(?:bug|issue))|(?:can\s*I\s*fix\s*the\s*(?:bug|issue))|(?:(?:does not|doesn'?t|don'?t|won'?t|can'?t|can\s?not|will\s*not)\s*(?:work|load|function))|(?:it\s*(?:will\s?not|won'?t|can\s?not|can'?t))\s*(?:get|find)\s*the\s*(?:website|site|webpage|page)|(?:the\s*(?:window|frame)\s*is\s*(?:blank|white|empty|missing))\b$/igm; - const bug_bFoundMatchTitle = Boolean( bug_findWordList.test( iss_title ) ); - const bug_bFoundMatchBody = Boolean( bug_findWordList.test( iss_body ) ); + const bug_findWordList = /^\b(?:I?\s*have\s*(?:a|an)\s*(?:issue|problem|bug))|(?:will\s*not\s*work)|(?:it\s*is\s*(?:broken|broke|stuck))|(?:found\s*(?:an?|the)\s*(?:bug|issue))|(?:can\s*I\s*fix\s*the\s*(?:bug|issue))|(?:(?:does not|doesn'?t|don'?t|won'?t|can'?t|can\s?not|will\s*not)\s*(?:work|load|function))|(?:it\s*(?:will\s?not|won'?t|can\s?not|can'?t))\s*(?:get|find)\s*the\s*(?:website|site|webpage|page)|(?:the\s*(?:window|frame)\s*is\s*(?:blank|white|empty|missing))\b$/igm; + const bug_bFoundMatchTitle = Boolean( bug_findWordList.test( iss_title ) ); + const bug_bFoundMatchBody = Boolean( bug_findWordList.test( iss_body ) ); /* Do not change a title if the item starts with a PR: # @@ -358,8 +363,8 @@ jobs: https://regex101.com/r/JOrqbN/1 */ - const bug_findPRTitle = /^PR\s?#?(?:[0-9]*:)/igm; - const bug_bFoundPRTitle = Boolean( bug_findPRTitle.test( iss_title ) ); + const bug_findPRTitle = /^PR\s?#?(?:[0-9]*:)/igm; + const bug_bFoundPRTitle = Boolean( bug_findPRTitle.test( iss_title ) ); /* - Check if issue title matches the issue label "Bug:" @@ -377,11 +382,11 @@ jobs: // Rename title to contain Bug: if ( author !== `${{ env.BOT_NAME_DEPENDABOT }}` && !bug_bFoundPRTitle && !iss_title_lc.startsWith( bug_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( feat_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( urgn_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( road_tag.toLowerCase( ) ) ) { - const title = issue.title; - let title_new = title.replace( /^\s?bug\s*(.*?)\b/gi, '' ); - title_new = title.replace( /^\s?fail\s*(.*?)\b/gi, '' ); - title_new = title.replace( /^\s?issue\s*(.*?)\b/gi, '' ); - iss_title = `${ bug_tag } ${ title_new }`; + const title = issue.title; + let title_new = title.replace( /^\s?bug\s*(.*?)\b/gi, '' ); + title_new = title.replace( /^\s?fail\s*(.*?)\b/gi, '' ); + title_new = title.replace( /^\s?issue\s*(.*?)\b/gi, '' ); + iss_title = `${ bug_tag } ${ title_new }`; } await github.rest.issues.update( @@ -395,7 +400,7 @@ jobs: Label > Features */ - const feat_bIncWordT = feat_words.some( s => s.includes( iss_title_lc ) || iss_title_lc.includes( s ) ); + const feat_bIncWordT = feat_words.some( s => s.includes( iss_title_lc ) || iss_title_lc.includes( s ) ); /* Find regex based phrases @@ -404,7 +409,7 @@ jobs: https://regex101.com/r/fR1Hm6/1 */ - const feat_findWordList = /^(?:(?:request|include|see)\s*(?:an?|the?)\s*(?:feature|addon|addition|plugin))|(?:(?:add|see|get)\s*support\s*(?:for|with|of))|(?:can\s*we\s*get\s*(?:the|a)\s*(?:ability|feature))|(?:💡 Feature:)$/igm; + const feat_findWordList = /^(?:(?:request|include|see)\s*(?:an?|the?)\s*(?:feature|addon|addition|plugin))|(?:(?:add|see|get)\s*support\s*(?:for|with|of))|(?:can\s*we\s*get\s*(?:the|a)\s*(?:ability|feature))|(?:💡 Feature:)$/igm; const feat_bFoundMatchTitle = Boolean( feat_findWordList.test( iss_title ) ); const feat_bFoundMatchBody = Boolean( feat_findWordList.test( iss_body ) ); @@ -434,12 +439,12 @@ jobs: // Rename title to contain Feature: if ( author !== `${{ env.BOT_NAME_DEPENDABOT }}` && !feat_bFoundPRTitle && !iss_title_lc.startsWith( bug_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( feat_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( urgn_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( road_tag.toLowerCase( ) ) ) { - const title = issue.title; - let title_new = title.replace( /^\s?feature\s*(.*?)\b/gi, '' ); - title_new = title.replace( /^\s?request\s*(.*?)\b/gi, '' ); - title_new = title.replace( /^\s?add(.*?)\s?feature\s*(.*?)\b/gi, '' ); - title_new = title.replace( /^\s?add(.*?)\s?support\s*(.*?)\b/gi, '' ); - iss_title = `${ feat_tag } ${ title_new }`; + const title = issue.title; + let title_new = title.replace( /^\s?feature\s*(.*?)\b/gi, '' ); + title_new = title.replace( /^\s?request\s*(.*?)\b/gi, '' ); + title_new = title.replace( /^\s?add(.*?)\s?feature\s*(.*?)\b/gi, '' ); + title_new = title.replace( /^\s?add(.*?)\s?support\s*(.*?)\b/gi, '' ); + iss_title = `${ feat_tag } ${ title_new }`; } await github.rest.issues.update( @@ -453,7 +458,7 @@ jobs: Label > Urgent */ - const urgn_bIncWordT = urgn_words.some( s => s.includes( iss_title_lc ) || iss_title_lc.includes( s ) ); + const urgn_bIncWordT = urgn_words.some( s => s.includes( iss_title_lc ) || iss_title_lc.includes( s ) ); /* Find regex based phrases @@ -462,9 +467,9 @@ jobs: https://regex101.com/r/eE9tJX/2 */ - const urgn_findWordList = /(?:(?:this)?is\s*a?n?\s*?(?:emergency|urgent|important|vital|acute|crucial|grave|pressing|serious|top.?priority|high.?priority))|(?:reply|respond|answer|write|address)\s*(?:immediate|quick|asap|urgent|now|fast|(?:as)?\s*(?:soon|quick|immediate|fast))(?:ly)?|(?:need\s*(?:help|support|fixed|answer|reply|response)!)|(?:emergency|critical|urgen(?:t|cy)|high.?priority)/igm; - const urgn_bFoundMatchTitle = Boolean( urgn_findWordList.test( iss_title ) ); - const urgn_bFoundMatchBody = Boolean( urgn_findWordList.test( iss_body ) ); + const urgn_findWordList = /(?:(?:this)?is\s*a?n?\s*?(?:emergency|urgent|important|vital|acute|crucial|grave|pressing|serious|top.?priority|high.?priority))|(?:reply|respond|answer|write|address)\s*(?:immediate|quick|asap|urgent|now|fast|(?:as)?\s*(?:soon|quick|immediate|fast))(?:ly)?|(?:need\s*(?:help|support|fixed|answer|reply|response)!)|(?:emergency|critical|urgen(?:t|cy)|high.?priority)/igm; + const urgn_bFoundMatchTitle = Boolean( urgn_findWordList.test( iss_title ) ); + const urgn_bFoundMatchBody = Boolean( urgn_findWordList.test( iss_body ) ); /* Do not change a title if the item starts with a PR: # @@ -492,13 +497,13 @@ jobs: // Rename title to contain Urgent: if ( author !== `${{ env.BOT_NAME_DEPENDABOT }}` && !urgn_bFoundPRTitle && !iss_title_lc.startsWith( bug_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( feat_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( urgn_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( road_tag.toLowerCase( ) ) ) { - const title = issue.title; - let title_new = title.replace( /^\s?emergency\s*(.*?)\b/gi, '' ); - title_new = title.replace( /^\s?urgent\s*(.*?)\b/gi, '' ); - title_new = title.replace( /^\s?urgency\s*(.*?)\b/gi, '' ); - title_new = title.replace( /^\s?important\s*(.*?)\b/gi, '' ); - title_new = title.replace( /^\s?critical\s*(.*?)\b/gi, '' ); - iss_title = `${ urgn_tag } ${ title_new }`; + const title = issue.title; + let title_new = title.replace( /^\s?emergency\s*(.*?)\b/gi, '' ); + title_new = title.replace( /^\s?urgent\s*(.*?)\b/gi, '' ); + title_new = title.replace( /^\s?urgency\s*(.*?)\b/gi, '' ); + title_new = title.replace( /^\s?important\s*(.*?)\b/gi, '' ); + title_new = title.replace( /^\s?critical\s*(.*?)\b/gi, '' ); + iss_title = `${ urgn_tag } ${ title_new }`; } await github.rest.issues.update( @@ -522,9 +527,9 @@ jobs: https://regex101.com/r/ucajBZ/1 */ - const road_findWordList = /#\s*Summary[\S\s]+#\s*(?:Proposal|Objective)[^\]]+/igm; - const road_bFoundMatchTitle = Boolean( road_findWordList.test( iss_title ) ); - const road_bFoundMatchBody = Boolean( road_findWordList.test( iss_body ) ); + const road_findWordList = /#\s*Summary[\S\s]+#\s*(?:Proposal|Objective)[^\]]+/igm; + const road_bFoundMatchTitle = Boolean( road_findWordList.test( iss_title ) ); + const road_bFoundMatchBody = Boolean( road_findWordList.test( iss_body ) ); /* Do not change a title if the item starts with a PR: # @@ -533,8 +538,8 @@ jobs: https://regex101.com/r/JOrqbN/1 */ - const road_findPRTitle = /^PR\s?#?(?:[0-9]*:)/igm; - const road_bFoundPRTitle = Boolean( road_findPRTitle.test( iss_title ) ); + const road_findPRTitle = /^PR\s?#?(?:[0-9]*:)/igm; + const road_bFoundPRTitle = Boolean( road_findPRTitle.test( iss_title ) ); /* - Check if issue title matches the issue label "Roadmap:" @@ -552,13 +557,13 @@ jobs: // Rename title to contain Roadmap: if ( author !== `${{ env.BOT_NAME_DEPENDABOT }}` && !road_bFoundPRTitle && !iss_title_lc.startsWith( bug_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( feat_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( urgn_tag.toLowerCase( ) ) && !iss_title_lc.startsWith( road_tag.toLowerCase( ) ) ) { - const title = issue.title; - let title_new = title.replace( /^\s?emergency\s*(.*?)\b/gi, '' ); - title_new = title.replace( /^\s?urgent\s*(.*?)\b/gi, '' ); - title_new = title.replace( /^\s?urgency\s*(.*?)\b/gi, '' ); - title_new = title.replace( /^\s?important\s*(.*?)\b/gi, '' ); - title_new = title.replace( /^\s?critical\s*(.*?)\b/gi, '' ); - iss_title = `${ road_tag } ${ title_new }`; + const title = issue.title; + let title_new = title.replace( /^\s?emergency\s*(.*?)\b/gi, '' ); + title_new = title.replace( /^\s?urgent\s*(.*?)\b/gi, '' ); + title_new = title.replace( /^\s?urgency\s*(.*?)\b/gi, '' ); + title_new = title.replace( /^\s?important\s*(.*?)\b/gi, '' ); + title_new = title.replace( /^\s?critical\s*(.*?)\b/gi, '' ); + iss_title = `${ road_tag } ${ title_new }`; } await github.rest.issues.update( @@ -617,7 +622,7 @@ jobs: I am a bot reaching out to you with an automated response. stale-issue-label: 'Status 𐄂 Stale' - close-issue-label: 'Status 𐄂 ' + close-issue-label: 'Status 𐄂 Autoclosed' exempt-issue-labels: 'feature,Type ◦ Feature,bug,Type ◦ Bug' days-before-stale: 30 days-before-close: 7 diff --git a/.github/workflows/labels-create.yml b/.github/workflows/labels-create.yml index f56a6a2..69bc882 100644 --- a/.github/workflows/labels-create.yml +++ b/.github/workflows/labels-create.yml @@ -1,8 +1,8 @@ # # -# @parent : github workflow -# @desc : manually activated workflow to create issue labels -# @author : Aetherinox -# @url : https://github.com/Aetherinox +# @type github workflow +# @desc manually activated workflow to create issue labels +# @author Aetherinox +# @url https://github.com/Aetherinox # # This Github action must be activated manually. This workflow script will do the # following: