From 2e6f31d2f71586790aca5b4fbfa82d802d2975e1 Mon Sep 17 00:00:00 2001 From: Marc Foley Date: Fri, 16 Aug 2024 14:23:36 +0100 Subject: [PATCH] .ci/test_font_tags.py added --- .ci/test_font_tags.py | 33 ++++++++++++++++++++++++++++++++ .github/workflows/font_tags.yaml | 11 ++++------- 2 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 .ci/test_font_tags.py diff --git a/.ci/test_font_tags.py b/.ci/test_font_tags.py new file mode 100644 index 0000000000..7263e0f0f6 --- /dev/null +++ b/.ci/test_font_tags.py @@ -0,0 +1,33 @@ +import json +from urllib.request import urlopen +import sys + +dev_data = json.loads( + urlopen("https://fonts.google.com/metadata/fonts").read().decode("utf-8") +) +dev_families = set(f["family"] for f in dev_data["familyMetadataList"]) + +csv_data = ( + urlopen("https://raw.githubusercontent.com/google/fonts/main/tags/all/families.csv") + .read() + .decode("utf-8") +) +csv_families = set( + line.split(",")[0] + for line in csv_data.split("\n") + if line + if line.split(",")[0] != "Family" +) + +families_missing_tags = sorted(dev_families - csv_families) + +if families_missing_tags: + missing_list = "\n".join(families_missing_tags) + raise ValueError( + f"The following {len(families_missing_tags)} families are missing tags:\n\n" + f"{missing_list}\n\n" + "Please add tags for these families using the following webapp: " + "https://google.github.io/fonts/tags.html" + ) + +sys.exit(0) diff --git a/.github/workflows/font_tags.yaml b/.github/workflows/font_tags.yaml index 8e761ceddd..371dcb74d7 100644 --- a/.github/workflows/font_tags.yaml +++ b/.github/workflows/font_tags.yaml @@ -1,5 +1,5 @@ -# Check font tagging spreadsheet is correctly structured -name: Font tagging structure +# Check font tags +name: Check font tags on: push: @@ -19,9 +19,6 @@ jobs: with: python-version: "3.10" - # Check font tags data is correct - - name: Install gftools - run: pip install gftools[qa] - - name: Test font tagging spreadsheet + - name: Check font tags run: | - gftools font-tags lint . \ No newline at end of file + python .ci/test_font_tags.py \ No newline at end of file -- 2.47.2