Skip to content

Commit 44a3e69

Browse files
update check_api_label_cn ci
1 parent 935944a commit 44a3e69

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

ci_scripts/check_api_label_cn.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def check_api_label(rootdir, file):
2525
real_file = Path(rootdir) / file
2626
with real_file.open("r", encoding="utf-8") as f:
2727
first_line = f.readline().strip()
28-
return first_line == generate_en_label_by_path(file)
28+
expected_label = generate_en_label_by_path(file)
29+
return first_line == expected_label, first_line, expected_label
2930

3031

3132
# path -> api_label (the first line's style)
@@ -74,12 +75,25 @@ def should_test(file):
7475

7576

7677
def run_cn_api_label_checking(rootdir, files):
78+
pass_check = True
7779
for file in files:
78-
if should_test(file) and not check_api_label(rootdir, file):
79-
logger.error(
80-
f"The first line in {rootdir}/{file} is not available, please re-check it!"
81-
)
82-
sys.exit(1)
80+
if should_test(file):
81+
check, actual, expected = check_api_label(rootdir, file)
82+
if not check:
83+
logger.error(
84+
f"❌ First Line API Label Mismatch\n"
85+
f" File: {file}\n"
86+
f" 🔥 Actual: `{actual}`\n"
87+
f" ✅ Expected: `{expected}`\n\n"
88+
f" (Note: The 'Expected' label is auto-generated based on the file path.\n"
89+
f" Please check if the filename is correct or update the first line of the file to match.)"
90+
)
91+
pass_check = False
92+
if pass_check:
93+
logger.info("All First Line API Label Check Passed !")
94+
else:
95+
logger.error("Some First Line API Label Check Failed !")
96+
sys.exit(1)
8397
valid_api_labels = find_all_api_labels_in_dir(rootdir)
8498
for file in files:
8599
if not file.endswith(".rst"):

0 commit comments

Comments
 (0)