Skip to content

Commit 5ccbbb7

Browse files
committed
feat: better check
1 parent 496637e commit 5ccbbb7

7 files changed

Lines changed: 385 additions & 58 deletions

File tree

.github/workflows/check.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,31 @@ on:
1919

2020
jobs:
2121
resource:
22-
runs-on: macos-latest
22+
runs-on: ubuntu-latest
2323
steps:
2424
- uses: actions/checkout@v4
2525
with:
2626
fetch-depth: 0
2727

28-
# pip install maafw
28+
- name: Use Node
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: 22
32+
33+
- name: Run maa-checker
34+
run: |
35+
npx @nekosu/maa-checker@latest ./assets/interface.json --github=.
36+
2937
- name: Install maafw
3038
run: |
31-
python -m pip install --upgrade pip
32-
python -m pip install --upgrade maafw --pre
39+
python -m pip install --upgrade pip
40+
python -m pip install --upgrade maafw --pre
3341
3442
- name: Check Resource
3543
run: |
36-
python ./check_resource.py ./assets/resource/
44+
python ./check_resource.py ./assets/resource/
45+
46+
- name: Validate JSON Schema
47+
run: |
48+
python -m pip install jsonschema==4.26.0 referencing==0.37.0
49+
python tools/validate_schema.py --schema-dir deps/tools --resource-dirs assets/resource --exclude-dirs assets/resource/announcement --interface-files assets/interface.json

assets/interface.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
],
8686
"option": {
8787
"任务选项1": {
88+
"type": "select",
8889
"cases": [
8990
{
9091
"name": "文本1",
@@ -105,4 +106,4 @@
105106
]
106107
}
107108
}
108-
}
109+
}

assets/resource/pipeline/my_task.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"custom_recognition": "my_reco_222",
88
"action": "Custom",
99
"custom_action": "my_action_111"
10-
}
10+
},
11+
"OcrTask": {}
1112
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "Custom Action Schema",
4+
"description": "Schema for custom actions in MaaFramework pipeline",
5+
"type": "object",
6+
"additionalProperties": true
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "Custom Recognition Schema",
4+
"description": "Schema for custom recognitions in MaaFramework pipeline",
5+
"type": "object",
6+
"additionalProperties": true
7+
}

deps/tools/pipeline.schema.json

Lines changed: 11 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -994,9 +994,9 @@
994994
},
995995
"expected": {
996996
"title": "Expected Property",
997-
"description": "期望的结果,支持正则。必选",
997+
"description": "期望的结果,支持正则。可选,默认匹配所有结果",
998998
"$ref": "#/$defs/jsonRegexOrList",
999-
"markdownDescription": "*string* | *list<string, >*\n\n期望的结果,支持正则。必选"
999+
"markdownDescription": "*string* | *list<string, >*\n\n期望的结果,支持正则。可选,默认匹配所有结果"
10001000
},
10011001
"threshold": {
10021002
"title": "Threshold Property",
@@ -1043,19 +1043,7 @@
10431043
"type": "string",
10441044
"markdownDescription": "*string*\n\n模型 **文件夹** 路径。使用 `model/ocr` 文件夹的相对路径。可选,默认为空。\n\n若为空,则为 `model/ocr` 根目录下的模型文件。\n\n文件夹中需要包含 `rec.onnx`, `det.onnx`, `keys.txt` 三个文件。"
10451045
}
1046-
},
1047-
"anyOf": [
1048-
{
1049-
"required": [
1050-
"expected"
1051-
]
1052-
},
1053-
{
1054-
"required": [
1055-
"expected_code"
1056-
]
1057-
}
1058-
]
1046+
}
10591047
},
10601048
"OcrV1": {
10611049
"properties": {
@@ -1115,9 +1103,9 @@
11151103
},
11161104
"expected": {
11171105
"title": "Expected Property",
1118-
"description": "期望的分类下标。必选",
1106+
"description": "期望的分类下标。可选,默认匹配所有结果",
11191107
"$ref": "#/$defs/jsonInt32OrList",
1120-
"markdownDescription": "*int* | *list<int, >*\n\n期望的分类下标。必选"
1108+
"markdownDescription": "*int* | *list<int, >*\n\n期望的分类下标。可选,默认匹配所有结果"
11211109
},
11221110
"order_by": {
11231111
"title": "Order By Property",
@@ -1142,26 +1130,12 @@
11421130
"anyOf": [
11431131
{
11441132
"required": [
1145-
"model",
1146-
"expected"
1147-
]
1148-
},
1149-
{
1150-
"required": [
1151-
"model_code",
1152-
"expected_code"
1133+
"model"
11531134
]
11541135
},
11551136
{
11561137
"required": [
1157-
"model_code",
1158-
"expected"
1159-
]
1160-
},
1161-
{
1162-
"required": [
1163-
"model",
1164-
"expected_code"
1138+
"model_code"
11651139
]
11661140
}
11671141
]
@@ -1224,9 +1198,9 @@
12241198
},
12251199
"expected": {
12261200
"title": "Expected Property",
1227-
"description": "期望的分类下标。必选",
1201+
"description": "期望的分类下标。可选,默认匹配所有结果",
12281202
"$ref": "#/$defs/jsonInt32OrList",
1229-
"markdownDescription": "*int* | *list<int, >*\n\n期望的分类下标。"
1203+
"markdownDescription": "*int* | *list<int, >*\n\n期望的分类下标。可选,默认匹配所有结果。"
12301204
},
12311205
"threshold": {
12321206
"title": "Threshold Property",
@@ -1259,26 +1233,12 @@
12591233
"anyOf": [
12601234
{
12611235
"required": [
1262-
"model",
1263-
"expected"
1264-
]
1265-
},
1266-
{
1267-
"required": [
1268-
"model_code",
1269-
"expected_code"
1270-
]
1271-
},
1272-
{
1273-
"required": [
1274-
"model_code",
1275-
"expected"
1236+
"model"
12761237
]
12771238
},
12781239
{
12791240
"required": [
1280-
"model",
1281-
"expected_code"
1241+
"model_code"
12821242
]
12831243
}
12841244
]

0 commit comments

Comments
 (0)