Skip to content

Commit 3796c94

Browse files
ngxsonCISC
andauthored
ci: validate model naming convention (#22680)
* ci: validate model naming convention * bring back dedicated ec workflow * add missing jobs --------- Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>
1 parent 634275f commit 3796c94

2 files changed

Lines changed: 51 additions & 5 deletions

File tree

.github/workflows/code-style.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Code Style Checker
2+
3+
on:
4+
workflow_dispatch: # allows manual triggering
5+
push:
6+
branches:
7+
- master
8+
pull_request:
9+
branches:
10+
- master
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
model-naming:
18+
runs-on: ubuntu-slim
19+
steps:
20+
- uses: actions/checkout@v6
21+
- name: Check model naming conventions
22+
run: |
23+
python3 - << 'EOF'
24+
import re, os, sys
25+
26+
pairs = re.findall(
27+
r'case\s+(LLM_ARCH_\w+)\s*:\s*\n\s+return new (llama_model_\w+)\s*\(',
28+
open("src/llama-model.cpp").read())
29+
30+
errors = []
31+
for arch, cls in pairs:
32+
suffix = arch[len("LLM_ARCH_"):]
33+
csuffix = cls[len("llama_model_"):]
34+
fname = csuffix.replace("_", "-") + ".cpp"
35+
36+
if not re.fullmatch(r'[A-Z][A-Z0-9_]*', suffix):
37+
errors.append(f"{arch}: suffix not upper snake case, example: LLM_ARCH_MY_MODEL")
38+
39+
if not re.fullmatch(r'[a-z][a-z0-9_]*', csuffix):
40+
errors.append(f"{arch}: class suffix not lower snake case, example: llama_model_my_model")
41+
42+
elif suffix.lower() != csuffix:
43+
errors.append(f"{arch}: arch/class name mismatch, expected class 'llama_model_{suffix.lower()}' but got '{cls}'")
44+
45+
elif not os.path.isfile(f"src/models/{fname}"):
46+
errors.append(f"{arch}: expects model file name to be src/models/{fname}, but not found")
47+
48+
if errors:
49+
print('\n'.join(f" - {e}" for e in errors)); sys.exit(1)
50+
print(f"OK: {len(pairs)} mappings validated.")
51+
EOF

.github/workflows/editorconfig.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ name: EditorConfig Checker
22

33
on:
44
workflow_dispatch: # allows manual triggering
5-
inputs:
6-
create_release:
7-
description: 'Create new release'
8-
required: true
9-
type: boolean
105
push:
116
branches:
127
- master

0 commit comments

Comments
 (0)