update github CI to verify UID is unique
This commit is contained in:
parent
1fb12b497f
commit
82591a385b
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
@ -8,7 +8,7 @@ on:
|
||||
- 'keyboards/**'
|
||||
|
||||
jobs:
|
||||
info:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
container: qmkfm/base_container
|
||||
@ -18,7 +18,10 @@ jobs:
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Verify Vial UID is unique
|
||||
run: python3 util/ci_vial_verify_uid.py
|
||||
|
||||
- name: Compile Vial keyboards
|
||||
run: |
|
||||
make git-submodule
|
||||
python3 util/compile_vial_keyboards.py
|
||||
python3 util/ci_compile_vial_keyboards.py
|
||||
|
53
util/ci_vial_verify_uid.py
Executable file
53
util/ci_vial_verify_uid.py
Executable file
@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python3
|
||||
from glob import glob
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import struct
|
||||
from collections import defaultdict
|
||||
|
||||
|
||||
def main():
|
||||
error = 0
|
||||
uid_to_keyboards = defaultdict(list)
|
||||
|
||||
for filename in glob("keyboards/**/vial.json", recursive=True):
|
||||
keyboard = filename[10:-10].split("/keymaps/")[0]
|
||||
|
||||
path = os.path.dirname(filename)
|
||||
uid = None
|
||||
while True:
|
||||
config_h = os.path.join(path, "config.h")
|
||||
if os.path.exists(config_h):
|
||||
with open(config_h, "r") as inf:
|
||||
for line in inf:
|
||||
uid = re.findall(r"#define.*VIAL_KEYBOARD_UID.*{(.*)}", line)
|
||||
if uid:
|
||||
break
|
||||
if uid:
|
||||
break
|
||||
path = os.path.dirname(path)
|
||||
if path.endswith("keyboards"):
|
||||
break
|
||||
|
||||
if not uid:
|
||||
print("Keyboard {} does not define a VIAL_KEYBOARD_UID".format(keyboard))
|
||||
error = 1
|
||||
continue
|
||||
|
||||
uid = uid[0].split(",")
|
||||
uid = [int(x, 16) for x in uid]
|
||||
uid = struct.pack("BBBBBBBB", *uid).hex()
|
||||
uid_to_keyboards[uid].append(keyboard)
|
||||
|
||||
print("{} uses UID {}".format(keyboard, uid))
|
||||
|
||||
for uid, keyboards in uid_to_keyboards.items():
|
||||
if len(keyboards) > 1:
|
||||
print("UID {} duplicated: {}".format(uid, keyboards))
|
||||
error = 1
|
||||
|
||||
return error
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
Loading…
Reference in New Issue
Block a user