From 4b5ed4b8c788029b96af26a153002be4dff94fd5 Mon Sep 17 00:00:00 2001 From: Rod S Date: Thu, 16 Nov 2023 22:02:41 -0800 Subject: [PATCH] Add CI to capture version silliness --- .github/workflows/ci.yml | 20 ++++++++++++++++++++ tests/basic_test.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 tests/basic_test.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..6860ddc659 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,20 @@ +name: Continuous Test + Deploy + +on: + push: + branches: [main] + tags: ["v*.*.*"] + pull_request: + branches: [main] + +jobs: + health_check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3 + uses: actions/setup-python@v2 + - name: Install FontTools + run: pip install fonttools pytest + - name: pytest + run: pytest \ No newline at end of file diff --git a/tests/basic_test.py b/tests/basic_test.py new file mode 100644 index 0000000000..6d79524646 --- /dev/null +++ b/tests/basic_test.py @@ -0,0 +1,30 @@ +from fontTools import ttLib +from pathlib import Path +import pytest +import re + +def test_consistent_version(): + fonts_dir = Path("fonts") + assert fonts_dir.is_dir() + + name5_re = re.compile(r'^Version (\d+.\d+);GOOG;noto-emoji:\d+:[a-z0-9]+$') + + debug_versions = [] + versions = set() + for font_file in fonts_dir.rglob("*.ttf"): + font = ttLib.TTFont(font_file) + head_ver = f"{font['head'].fontRevision:.03f}" + versions.add(head_ver) + debug_versions.append(f"{font_file.name} head {head_ver}") + for name in font['name'].names: + # name 5 is version + if name.nameID != 5: + continue + if not name.isUnicode(): + continue + match = name5_re.match(name.toUnicode()) + assert match is not None, f"{name.toUnicode()} is malformed" + versions.add(match.group(1)) + debug_versions.append(f"{font_file.name} name {match.group(1)}") + debug_versions = "\n".join(debug_versions) + assert len(versions) == 1, f"Should have a consistent version, found\n{debug_versions}" \ No newline at end of file