Update version_branch.yml

This commit is contained in:
2025-12-23 16:25:07 -06:00
parent b981391813
commit 4b59ddcb34

View File

@@ -182,41 +182,39 @@ jobs:
moko_init "Sanity check workflow file" moko_init "Sanity check workflow file"
python3 - <<'PY' python3 - <<'PY'
from pathlib import Path from pathlib import Path
target = Path('.github/workflows/version_branch.yml') target = Path('.github/workflows/version_branch.yml')
if not target.exists(): if not target.exists():
raise SystemExit('[FATAL] Missing workflow file: .github/workflows/version_branch.yml') raise SystemExit('[FATAL] Missing workflow file: .github/workflows/version_branch.yml')
data = target.read_bytes() data = target.read_bytes()
# Disallow literal tab (0x09) and other ASCII control characters except LF (0x0A) and CR (0x0D). # Disallow literal tab (0x09) and other ASCII control characters except LF (0x0A) and CR (0x0D).
# Report line numbers without printing the raw characters. # Report line numbers without printing the raw characters.
def byte_to_line(blob: bytes, idx: int) -> int:
def byte_to_line(blob: bytes, idx: int) -> int: return blob[:idx].count(b'
# Count newlines prior to byte offset.
return blob[:idx].count(b'
') + 1 ') + 1
bad = [] bad = []
for i, b in enumerate(data): for i, b in enumerate(data):
if b == 0x09: if b == 0x09:
bad.append(('TAB', i, b)) bad.append(('TAB', i, b))
elif b < 0x20 and b not in (0x0A, 0x0D): elif b < 0x20 and b not in (0x0A, 0x0D):
bad.append(('CTRL', i, b)) bad.append(('CTRL', i, b))
if bad: if bad:
print('[ERROR] Disallowed characters detected in workflow file:') print('[ERROR] Disallowed characters detected in workflow file:')
for kind, off, val in bad[:200]: for kind, off, val in bad[:200]:
line_no = byte_to_line(data, off) line_no = byte_to_line(data, off)
if kind == 'TAB': if kind == 'TAB':
print(f' line {line_no}: TAB_PRESENT') print(f' line {line_no}: TAB_PRESENT')
else: else:
print(f' line {line_no}: CTRL_0x{val:02X}_PRESENT') print(f' line {line_no}: CTRL_0x{val:02X}_PRESENT')
raise SystemExit(2) raise SystemExit(2)
print('[INFO] Sanity check passed') print('[INFO] Sanity check passed')
PY PY
- name: Enterprise policy gate - name: Enterprise policy gate
run: | run: |