From d26a6b9f186828b9b06668f559e22bf6db6b3735 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Sat, 15 Nov 2025 10:10:00 +0200 Subject: [PATCH] Test speaker names --- .github/workflows/ci.yml | 15 ++++++------ .schemas/pathschema | 1 - .tests/requirements.txt | 1 + .tests/speaker_names.py | 50 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 6 ----- Makefile | 9 +++++--- 6 files changed, 65 insertions(+), 17 deletions(-) create mode 100644 .tests/speaker_names.py delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 505b87a5bf..49189c67de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,21 +1,22 @@ name: CI -on: - push: - branches: main - pull_request: +on: [push, pull_request, workflow_dispatch] + +env: + FORCE_COLOR: 1 + PIP_DISABLE_PIP_VERSION_CHECK: 1 jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: - python-version: 3.12 + python-version: 3.x - name: Install run: make install-deps diff --git a/.schemas/pathschema b/.schemas/pathschema index fb4a879a3b..a685802dc7 100644 --- a/.schemas/pathschema +++ b/.schemas/pathschema @@ -18,7 +18,6 @@ tools/ .gitignore .editorconfig -.travis.yml CONTRIBUTING.rst CONTRIBUTORS_WITHOUT_COMMITS.rst LICENSE diff --git a/.tests/requirements.txt b/.tests/requirements.txt index ee44f5a75f..39a256d5f1 100644 --- a/.tests/requirements.txt +++ b/.tests/requirements.txt @@ -4,4 +4,5 @@ jsonschema pathschema pygments six +termcolor unidecode diff --git a/.tests/speaker_names.py b/.tests/speaker_names.py new file mode 100644 index 0000000000..86dc607ffe --- /dev/null +++ b/.tests/speaker_names.py @@ -0,0 +1,50 @@ +import argparse +import json +import sys + +from termcolor import colored, cprint + +from tools.utils import get_json_files + + +def check_speaker_names(data_root, verbose=False): + _, video_paths = get_json_files(data_root) + + invalid_names = [] + # Map of disallowed speaker names to their correct replacements + replacements = { + "Glyph Lefkowitz": "Glyph", + } + + for video_path in video_paths: + with open(video_path, encoding="UTF-8") as fp: + video_blob = json.load(fp) + speakers = video_blob.get("speakers", []) + + for speaker in speakers: + if speaker in replacements: + invalid_names.append((video_path, speaker, replacements[speaker])) + + if invalid_names: + cprint("Disallowed speaker names found:", "red") + for path, speaker, replacement in invalid_names: + speaker = colored(speaker, "red") + print(f"\t{path}: {speaker}") + print(f"\t\tUse {colored(replacement, 'green')} instead of {speaker}") + sys.exit(1) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("-d", "--data-root", + help="directory to search for JSON files") + parser.add_argument("-v", "--verbose", + type=int, + help="increase output verbosity") + args = parser.parse_args() + + check_speaker_names(args.data_root, verbose=args.verbose) + + +if __name__ == '__main__': + main() diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5d8c28b6bf..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -language: python -python: -- '3.5' -install: make install-deps -script: make test - diff --git a/Makefile b/Makefile index 644f8f9794..b3f30b40cd 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ help: @echo ' ' .venv: - python3 -m venv $(VENV) + python3 -m venv $(VENV) --upgrade-deps install-deps: .venv $(BIN)/pip install -r $(TESTSDIR)/requirements.txt @@ -54,6 +54,9 @@ test-languages: install-deps test-filename-length: install-deps $(PYTHON) $(TESTSDIR)/filename_length.py -d $(BASEDIR) -v $(VERBOSE) -test: test-directory-schemas test-schemas test-ids-unique test-slugs-unique test-render-rest test-languages test-filename-length +test-speaker-names: install-deps + $(PYTHON) $(TESTSDIR)/speaker_names.py -d $(BASEDIR) -v $(VERBOSE) -.PHONY: help test test-directory-schemas test-schemas test-ids-unique test-slugs-unique test-render-rest test-shape test-languages +test: test-directory-schemas test-schemas test-ids-unique test-slugs-unique test-render-rest test-languages test-filename-length test-speaker-names + +.PHONY: help test test-directory-schemas test-schemas test-ids-unique test-slugs-unique test-render-rest test-shape test-languages test-speaker-names