Skip to content

Commit cd70de7

Browse files
committed
Add workflow for keyword checking
1 parent dbc7bfe commit cd70de7

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

.github/workflows/keywords.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Keywords
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- 'master'
8+
- 'release**'
9+
10+
jobs:
11+
check-keywords:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v6
15+
- run: ./scripts/check-keywords.py
Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
11
#!/bin/python3
2+
import argparse
3+
import requests
24
import re
35
import sys
46
from pathlib import Path
57

6-
parser = Path("../tidb/pkg/parser/parser.y")
7-
if not parser.exists():
8-
sys.exit(f"{parser} doesn't exist")
8+
aparser = argparse.ArgumentParser()
9+
aparser.add_argument(
10+
"--parser_file", default="../tidb/pkg/parser/parser.y", help="Path to parser.y"
11+
)
12+
aparser.add_argument(
13+
"--parser_url",
14+
default="https://github.com/pingcap/tidb/raw/refs/heads/master/pkg/parser/parser.y",
15+
help="Url to parser.y",
16+
)
17+
aparser.add_argument("--download_from_url", action="store_true")
18+
args = aparser.parse_args()
19+
20+
if args.download_from_url:
21+
r = requests.get(args.parser_url)
22+
if r.status_code != 200:
23+
sys.exit(f"failed to download parser file, got HTTP {r.status_code}")
24+
lines = r.text.splitlines()
25+
else:
26+
parser = Path(args.parser_file)
27+
if not parser.exists():
28+
sys.exit(f"{parser} doesn't exist")
29+
lines = parser.read_text().split("\n")
930

1031
kwdocs = Path("keywords.md")
1132
if not kwdocs.exists():
@@ -15,7 +36,7 @@
1536

1637
errors = 0
1738
section = "Unknown"
18-
for line in parser.read_text().split("\n"):
39+
for line in lines:
1940
if line == "":
2041
section = "NotKeywordToken"
2142

0 commit comments

Comments
 (0)