Skip to content

Commit

Permalink
Merge pull request #916 from Zero-Fanker/auto-archiving-v2
Browse files Browse the repository at this point in the history
更新自动归档脚本 V2
  • Loading branch information
shuiping233 authored Dec 21, 2024
2 parents 8f9adca + 519925a commit 395f5ad
Show file tree
Hide file tree
Showing 43 changed files with 1,953 additions and 1,799 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/AutoArchiving.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ on:
env:
ARCHIVED_DOCUMENT_PATH: "./修改归档.md"
TARGET_BRANCH: master
ISSUE_OUTPUT_PATH: "./output.json"
ISSUE_OUTPUT_PATH: "./issue_info.json"
ISSUE_REPOSITORY: "外部Issue"
COMMIT_TITLE: "Closed 外部Issue#"
TOKEN: ${{ secrets.GITHUB_TOKEN }}
CI_EVENT_TYPE: ${{ github.event_name }}
# 具体有什么事件类型:https://docs.github.com/zh/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#about-events-that-trigger-workflows
ISSUE_NUMBER: ${{ github.event.issue.number }}
Expand All @@ -74,7 +75,6 @@ jobs:
- name: Processing issue content
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 自动流水线变量
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_STATE: ${{ github.event.issue.state }}
Expand All @@ -90,11 +90,7 @@ jobs:
MANUAL_ISSUE_URL: "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.inputs.issue_number }}"
MANUAL_COMMENTS_URL: "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.inputs.issue_number }}/comments"
run: |
python ./rn_issues_auto_archiving/issue_processor_main.py --config "./config/issue_processor.json"
- name: Archiving closed issues
run: |
python ./rn_issues_auto_archiving/auto_archiving_main.py --config "./config/auto_archiving.json" --failed-record "./归档失败记录.json"
python ./rn_issues_auto_archiving/main.py --config "./config/auto_archiving.json"
- name: Add and commit changes
run: |
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/CheckConfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ on:
push:
branches:
- main
- master
paths:
- '**.json'
- 'config/*.json'
pull_request:
branches:
- main
- master
paths:
- '**.json'
- 'config/*.json'

jobs:
check_config:
Expand Down
73 changes: 63 additions & 10 deletions config/auto_archiving.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,66 @@
{
"rjust_space_width": 60,
"rjust_character": " ",
"table_separator": "|",
"archive_template": "|{table_id}|({issue_type}){issue_title}{rjust_space}[{issue_repository}#{issue_id}] |{introduced_version}|{archive_version}|",
"issue_title_processing_rules": {
"Bug修复": {
"add_prefix": "修复了",
"add_suffix": "的Bug",
"remove_keyword": []
"version_regex": "(\\d\\.\\d{2}\\.\\d{3}[a-zA-Z]?\\d{0,2})",
"introduced_version_reges": [
"[【\\[]发现版本号[】\\]][:\\:]([^\\s\\r\\n【]+)"
],
"issue_type": {
"type_keyword": {
"#Bug#": "Bug修复",
"#BUG#": "Bug修复",
"#bug#": "Bug修复",
"#Bug修复#": "Bug修复",
"#BUG修复#": "Bug修复",
"#bug修复#": "Bug修复",
"#BUG反馈#": "Bug修复",
"#修复#": "Bug修复",
"#建议反馈#": "设定调整",
"#设定建议#": "设定调整",
"#建议#": "设定调整",
"#期望和反馈#": "设定调整",
"#优化#": "设定调整",
"#开发#": "设定引入",
"#研发#": "设定引入",
"#讨论#": "设定调整",
"#功能增强#": "设定调整",
"#功能需求#": "设定调整",
"#功能性提议#": "设定调整",
"#调整#": "设定调整",
"#数据调整#": "设定调整",
"#AI相关#": "设定调整",
"#计划研讨#": "设定调整",
"#工具需求#": "设定调整"
},
"need_introduced_version_issue_type": [
"Bug修复"
],
"label_map": {
"bug": "Bug修复",
"enhancement 优化或建议": "设定调整",
"task 任务": "设定引入"
}
},
"archive_necessary_labels": [
"resolved 已解决"
],
"archive_version_reges_for_comments": [
"{version_regex}测试通过",
"已验证[,,]版本号[::]{version_regex}"
],
"archived_document": {
"rjust_space_width": 60,
"rjust_character": " ",
"table_separator": "|",
"archive_template": "|{table_id}|({issue_type}){issue_title}{rjust_space}[{issue_repository}#{issue_id}]{issue_url_parents} |{introduced_version}|{archive_version}|",
"fill_issue_url_by_repository_type": [
"外部Issue",
"内部Issue"
],
"issue_title_processing_rules": {
"Bug修复": {
"add_prefix": "修复了",
"add_suffix": "的Bug",
"remove_keyword": []
}
}
}
}
}
55 changes: 0 additions & 55 deletions config/issue_processor.json

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 17 additions & 27 deletions rn_issues_auto_archiving/archiving_success.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import json
import os
from pathlib import Path

from shared.log import Log
from shared.issue_info import IssueInfo
from shared.get_args import get_value_from_args
from shared.issue_info import IssueInfoJson
from shared.json_dumps import json_dumps
from shared.env import (Env,
should_run_in_local
)
from auto_archiving.send_comment import send_comment
from issue_processor.issue_platform import Gitlab, Github
from shared.send_comment import send_comment
from issue_processor.git_service_client import GitlabClient, GithubClient


def main():
Expand All @@ -20,38 +16,32 @@ def main():
from dotenv import load_dotenv
load_dotenv()

output_path = os.environ[Env.ISSUE_OUTPUT_PATH]
issue_output_path = os.environ[Env.ISSUE_OUTPUT_PATH]
issue_repository = os.environ[Env.ISSUE_REPOSITORY]
token = os.environ[Env.TOKEN]

issue_info_json: IssueInfoJson

issue_info: IssueInfo
try:
issue_info_json = json.loads(
Path(output_path
).read_text(encoding="utf-8")
)
issue_info = IssueInfo()
issue_info.json_load(issue_output_path)
print(Log.print_issue_info
.format(issue_info=json_dumps(
IssueInfoJson.remove_sensitive_info(issue_info_json)
)))
issue_info = IssueInfo(
reopen_info=IssueInfo.ReopenInfo(
**issue_info_json.pop("reopen_info")
),
**issue_info_json
)
.format(issue_info=issue_info.to_print_string()
))

except FileNotFoundError:
print(Log.issue_output_not_found)
return

if not issue_info.should_archived_success():
return

http_header: dict[str, str]
if issue_info.platform_type == Github.name:
http_header = Github.create_http_header(
if issue_info.platform_type == GithubClient.name:
http_header = GithubClient.create_http_header(
token=token
)
elif issue_info.platform_type == Gitlab.name:
http_header = Gitlab.create_http_header(
elif issue_info.platform_type == GitlabClient.name:
http_header = GitlabClient.create_http_header(
token=token
)
else:
Expand All @@ -62,7 +52,7 @@ def main():
))
try:
send_comment(
comment_url=issue_info.reopen_info.comment_url,
comment_url=issue_info.links.comment_url,
http_header=http_header,
message=Log.issue_archived_success.format(
issue_id=issue_info.issue_id,
Expand Down
Loading

0 comments on commit 395f5ad

Please sign in to comment.