mirror of
http://shenjack.top:5100/ARS/ARS-docs.git
synced 2024-11-22 22:51:05 +08:00
Commented out unused code in label.yml
我的问题( Update label.yml to install dependencies using pip Update git clone URL for python-packs repository Fix git clone URL in label.yml workflow Add ls commands to debug dependency installation Update directory paths in label.yml Update label generation script Add ls commands to label.yml workflow Add ls command to display file details Remove unnecessary code in label.yml Update label.yml and add requirement.txt 不管了! build? mkdir added
This commit is contained in:
parent
76fd306ed2
commit
e44e4d132c
|
@ -2,10 +2,9 @@ name: 自动生成 label
|
|||
|
||||
# main 分支推送
|
||||
on:
|
||||
[push]
|
||||
# push:
|
||||
# branches:
|
||||
# - main
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
Generate-label:
|
||||
|
@ -13,31 +12,42 @@ jobs:
|
|||
steps:
|
||||
- name: 获取仓库
|
||||
uses: http://shenjack.top:5100/gitea-server/checkout@v4
|
||||
with:
|
||||
path: main
|
||||
|
||||
# - name: ensure pip
|
||||
# uses: http://shenjack.top:5100/gitea-server/python-packs@1cd32b1235ba23d51524b6870c0735f63efcffc2
|
||||
|
||||
- name: ensurepip
|
||||
uses: http://shenjack.top:5100/gitea-server/checkout@v4
|
||||
with:
|
||||
repository: gitea-server/python-packs
|
||||
with:
|
||||
path: python-packs
|
||||
- name: pip
|
||||
run: |
|
||||
cd ..
|
||||
git clone http://shenjack.top:5100/gitea-server/python-packs.git
|
||||
cd python-packs
|
||||
python3 -m ensurepip
|
||||
cd ../ARS-docs
|
||||
|
||||
- name: 安装依赖
|
||||
run: |
|
||||
ls -la .
|
||||
ls -la ..
|
||||
ls -la ../..
|
||||
python3 -m ../python-packs/ensurepip
|
||||
python3 -m pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
python3 -m pip install -U pip
|
||||
python3 -m pip install mistune
|
||||
python3 -m pip install -U -r scripts/requirement.txt
|
||||
ls . -la
|
||||
ls scripts
|
||||
|
||||
- name: 生成 label
|
||||
run: |
|
||||
python3 generate_label.py
|
||||
python3 scripts/parse-label.py
|
||||
|
||||
- name: 检查是否有改动
|
||||
run: |
|
||||
git config user.name gitea-actions
|
||||
git config user.email gitea-action@shenjack.top
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
git add .
|
||||
git commit -m "gen by python script"
|
||||
# 创建并切换到deploy分支
|
||||
git checkout -b deploy
|
||||
# 将更改添加到deploy分支的最新提交
|
||||
git commit --amend --no-edit
|
||||
# 推送到deploy分支
|
||||
git push origin HEAD --force
|
||||
else
|
||||
echo "工作区没有改动"
|
||||
fi
|
||||
|
||||
# https://gitea.com/actions/gitea-release-action
|
||||
|
|
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
venv
|
||||
env
|
||||
*__pycache__*
|
||||
build
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f47c635221913891af353c5ffb1282fdab8040d0d19ece72a0271f5dacafc0f5
|
||||
size 10125
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:41e7055e133c7b299ffcf2c1c9deea59258ddcf903df81aeee19eaee70652063
|
||||
size 10031
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:da0f69741e6a6ff7f9804a502ae771fbf6fc93f8025e6400835215599870d36a
|
||||
size 23841
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1097d8ac9662ffe9f8bdb8738072b69296ad028a7c89a167858fb076322a8979
|
||||
size 86
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:601cfbbf97ae6bb2d6d175f9fc0336b1eefdbd09952313fce4356a56d293fb50
|
||||
size 13276
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5f360fe68055a475b72b955d3837cb0a4346dfff918f50250d0a014f4cfed103
|
||||
size 11832
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bb602b483a4aeef696a01da8575f4d57ab849e5844519e5cda6ab2df38882546
|
||||
size 38638
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:649557ccb7d795b9a7866e47c693d1f1437ed138a05916651cab818e7377251a
|
||||
size 83640
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6c7b521439dbae44dcc27829af089c26aa13ab88c76c7a7a0e525384d0657060
|
||||
size 6078
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2435ed3f325fe210b713eca63a65411a21325c0a18aebd02868f09b6049f758b
|
||||
size 26266
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5855cdf6f1c38060495a57ca54fbd8b188d483c85b3abf764d39d2c93dc7890b
|
||||
size 5859
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d72759bf482de5e96cdeff5e4d7f80a9b475757c5779c4834879c929291e8e66
|
||||
size 7784
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:27a9c829b744420d1b6304ae4df0e18b7731be68a954a687ca5bed27c587271d
|
||||
size 691
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6af674c5531515ab68bff3b81ebae900642441578a7b4d2a13215b4c0f7c7786
|
||||
size 16281
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1097d8ac9662ffe9f8bdb8738072b69296ad028a7c89a167858fb076322a8979
|
||||
size 86
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9a8b49117bae9d2f4294f9fec6e1c3ffe099631bd9ffc751920e7b2855fcc49a
|
||||
size 1267
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:bbb378bbd2fb5a069977a3e20cc844fc4e0cecb3df4c67bd5a5ae4b7c5d032d5
|
||||
size 8963
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a343283cc6abff4725503930028d424afd57891052a51200f75d4377c4a0cf9e
|
||||
size 1247
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d17057a1884e34516613bc557ecb51ce054b1b295018346ea70bb7ed326a0b01
|
||||
size 10427
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:64d0db9358b47d4a1d93bbd81c4249a280a880f3bd379e0a6decbecd8076606b
|
||||
size 8272
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:db3d921f5bd1905a963662b299e74eba315ded36330ba3479d717a9a53361905
|
||||
size 23586
|
|
@ -1,3 +0,0 @@
|
|||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ebd7467b076ebef1aaea8f7d116a5c2953f19de29d3751c90ce35434cdf42828
|
||||
size 50817
|
|
@ -1,28 +1,68 @@
|
|||
|
||||
from pathlib import Path
|
||||
from pprint import pprint
|
||||
|
||||
import mistune
|
||||
|
||||
from qtoml.encoder import dumps
|
||||
from qtoml.decoder import loads
|
||||
from lib_not_dr import loggers
|
||||
from lib_not_dr.types.options import Options
|
||||
|
||||
|
||||
ast_markdown = mistune.create_markdown(renderer='ast')
|
||||
|
||||
def read_files(module_path: Path):
|
||||
with open(module_path, 'r', encoding='utf-8') as f:
|
||||
file = f.read()
|
||||
|
||||
class TagParser(Options):
|
||||
module_root: Path
|
||||
tags: dict[str, list[str]] = {}
|
||||
logger: loggers.logger.Logger = None # noqa
|
||||
|
||||
def load_module(self, **kwargs):
|
||||
for readme in self.module_root.rglob('readme.md'):
|
||||
self.logger.debug(readme.absolute(), tag="load file")
|
||||
self.get_module_data(readme)
|
||||
|
||||
parsed = ast_markdown(file)
|
||||
return parsed
|
||||
tag_toml = dumps(self.tags)
|
||||
tag_path = self.module_root / ".." / "build" / "tags.toml"
|
||||
tag_path.mkdir(parents=True, exist_ok=True)
|
||||
tag_path.touch(exist_ok=True)
|
||||
with open(tag_path, 'w', encoding='utf-8') as file:
|
||||
file.write(tag_toml)
|
||||
|
||||
|
||||
def get_module_data(self, module_path: Path):
|
||||
with open(module_path, 'r', encoding='utf-8') as f:
|
||||
file = f.read()
|
||||
|
||||
ast = ast_markdown(file)
|
||||
if len(ast) == 0:
|
||||
return
|
||||
|
||||
if ast[0] != {'type': 'thematic_break'}:
|
||||
# 排除开头不是注释块的
|
||||
return
|
||||
|
||||
self.logger.info(f"开始解析 {ast[1]}")
|
||||
config_code = ast[1].get("raw", "")
|
||||
config_dict = loads(config_code)
|
||||
self.logger.trace(config_dict)
|
||||
|
||||
if not (tag_list := config_dict.get('tags')):
|
||||
self.logger.warn("未找到 tags", tag=str(module_path))
|
||||
return
|
||||
|
||||
for tag in tag_list:
|
||||
if tag not in self.tags:
|
||||
self.tags[tag] = [module_path.__str__()]
|
||||
else:
|
||||
self.tags[tag].append(module_path.__str__())
|
||||
|
||||
def init(self, **kwargs) -> bool:
|
||||
self.logger = loggers.get_logger()
|
||||
self.logger.global_level = 0
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
module_path = Path('modules')
|
||||
|
||||
# walk through the modules
|
||||
# for every markdown file
|
||||
# parse the label
|
||||
|
||||
for md_file in module_path.rglob('*.md'):
|
||||
print(md_file)
|
||||
parsed = read_files(md_file)
|
||||
pprint(parsed)
|
||||
|
||||
parser = TagParser(module_root = Path("modules"))
|
||||
parser.load_module()
|
||||
parser.logger.info(parser.tags)
|
||||
|
|
3
scripts/requirement.txt
Normal file
3
scripts/requirement.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
mistune
|
||||
lib-not-dr
|
||||
qtoml
|
Loading…
Reference in New Issue
Block a user