diff --git a/CHANGELOG.md b/CHANGELOG.md index 963111aad9..cb5eb5432f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,9 @@ A more detailed list of changes is available in the corresponding milestones for ### Noteworthy code-changes - Created a dictionary at `Lib/fontbakery/legacy_checkids.py` that documents the renaming of checks-IDs that is happenning between versions v0.12.10 and v0.13.0 (PR #4929) - This file contains a translation map that can be useful: - - to be read directly by humans - - to generate documentation - - to implement a backwards compatibility mechanism + - This file contains a translation map that can be useful to be read directly by humans and it is also used to implement a backwards compatibility mechanism to accept the old IDs. + + - All reporters are now listing which legacy check-IDs were used on the --check-id and --exclude-checkid options and instructing the users to update to the new naming scheme, because the old ones will be permanently deprecated in the next major release. (issue #4942) ### New checks #### Added to the Universal profile diff --git a/Lib/fontbakery/checkrunner.py b/Lib/fontbakery/checkrunner.py index bc8726a604..dbf7be6dfa 100644 --- a/Lib/fontbakery/checkrunner.py +++ b/Lib/fontbakery/checkrunner.py @@ -68,6 +68,8 @@ def __init__( for testable in self.context.testables: testable.context = self.context + self.legacy_checkid_references = set() + @staticmethod def _check_result(result) -> Subresult: """Check that the check returned a well formed result: @@ -231,17 +233,46 @@ def _run_check(self, identity: Identity): @property def order(self) -> Tuple[Identity, ...]: + from fontbakery.legacy_checkids import renaming_map + + legacy_ids = {} + for k, v in renaming_map.items(): + try: + legacy_ids[v].append(k) + except KeyError: + legacy_ids[v] = [k] + _order = [] for section in self.profile.sections: for check in section.checks: - if self._explicit_checks and all( - explicit not in check.id for explicit in self._explicit_checks - ): - continue - if self._exclude_checks and any( - excluded in check.id for excluded in self._exclude_checks - ): - continue + if self._explicit_checks: + selected_via_new_checkid = any( + explicit in check.id for explicit in self._explicit_checks + ) + selected_via_legacy_checkid = False + if not selected_via_new_checkid and check.id in legacy_ids: + for legacy in legacy_ids[check.id]: + if any( + explicit in legacy for explicit in self._explicit_checks + ): + selected_via_legacy_checkid = True + self.legacy_checkid_references.add(legacy) + + if not selected_via_legacy_checkid and not selected_via_new_checkid: + continue + + if self._exclude_checks: + if any(excluded in check.id for excluded in self._exclude_checks): + continue + + if check.id in legacy_ids: + for legacy in legacy_ids[check.id]: + if any( + excluded in legacy for excluded in self._exclude_checks + ): + self.legacy_checkid_references.add(legacy) + continue + args = set(check.args) context_args = set(arg for arg in args if arg in dir(self.context)) @@ -296,6 +327,7 @@ def distribute_result(result): # Tell all the reporters we're done for reporter in reporters: + reporter.legacy_checkid_references = list(self.legacy_checkid_references) reporter.end() def _override_status(self, subresult: Subresult, check): diff --git a/Lib/fontbakery/reporters/ghmarkdown.py b/Lib/fontbakery/reporters/ghmarkdown.py index b714c18752..2528e277cd 100644 --- a/Lib/fontbakery/reporters/ghmarkdown.py +++ b/Lib/fontbakery/reporters/ghmarkdown.py @@ -77,6 +77,29 @@ def template(self, data): other_checks[key] = [] other_checks[key].append(check) + if self.legacy_checkid_references: + references = "\n - ".join(self.legacy_checkid_references) + deprecation_warning = ( + "By late-December 2024, FontBakery version 0.13.0" + " introduced a new naming scheme for the check-IDs.\n" + "\n" + "Fontbakery detected usage of old IDs and performed an" + " automatic backwards-compatibility translation for you.\n" + "This automatic translation will be deprecated in the next" + " major release.\n" + "\n" + "Please start using the new check-IDs as documented at\n" + "https://github.com/fonttools/fontbakery/blob/" + "83db7cc2a6ad58585ddec9397306e0420843edb1/Lib/" + "fontbakery/legacy_checkids.py\n" + "\n" + "The following legacy check-IDs were detected:\n" + f" - {references}\n" + "\n" + ) + else: + deprecation_warning = None + # Sort them by log-level results: ordering = ["ERROR", "FATAL", "FAIL", "WARN", "INFO", "PASS", "SKIP"] for check_group in [fatal_checks, experimental_checks, other_checks]: @@ -94,4 +117,5 @@ def template(self, data): other_checks=other_checks, succinct=self.succinct, total=num_checks, + deprecation_warning=deprecation_warning, ) diff --git a/Lib/fontbakery/reporters/html.py b/Lib/fontbakery/reporters/html.py index 2218110a31..039e930800 100644 --- a/Lib/fontbakery/reporters/html.py +++ b/Lib/fontbakery/reporters/html.py @@ -110,6 +110,28 @@ def template(self, data) -> str: (e for e in section["result"].elements() if e != "PASS"), key=LOGLEVELS.index, ) + if self.legacy_checkid_references: + deprecation_warning = ( + "By late-December 2024, FontBakery version 0.13.0" + " introduced a new naming scheme for the check-IDs.
" + "
" + "Fontbakery detected usage of old IDs and performed an" + " automatic backwards-compatibility translation for you.
" + "This automatic translation will be deprecated in the next" + " major release.
" + "
" + "Please start using the new check-IDs as documented at" + " " + "/Lib/fontbakery/legacy_checkids.py
" + "
" + "The following legacy check-IDs were detected:
" + f" - {'
- '.join(self.legacy_checkid_references)}
" + "
" + ) + else: + deprecation_warning = None return self.template_engine().render( sections=data["sections"], @@ -118,4 +140,5 @@ def template(self, data) -> str: total=total, summary={k: data["result"][k] for k in LOGLEVELS}, succinct=self.succinct, + deprecation_warning=deprecation_warning, ) diff --git a/Lib/fontbakery/reporters/templates/html/main.html b/Lib/fontbakery/reporters/templates/html/main.html index 3cc96b288c..a46f2edfd6 100644 --- a/Lib/fontbakery/reporters/templates/html/main.html +++ b/Lib/fontbakery/reporters/templates/html/main.html @@ -19,6 +19,10 @@
{% include "top.html" %} + {% if deprecation_warning %} +

DEPRECATION WARNING

+

{{deprecation_warning|safe}}

+ {% endif %} {% include "summary_table.html" %} {% include "summary_notes.html" %} {% for section in sections %} diff --git a/Lib/fontbakery/reporters/templates/markdown/main.markdown b/Lib/fontbakery/reporters/templates/markdown/main.markdown index b573d5543e..3bc6481a34 100644 --- a/Lib/fontbakery/reporters/templates/markdown/main.markdown +++ b/Lib/fontbakery/reporters/templates/markdown/main.markdown @@ -2,6 +2,11 @@ fontbakery version: {{fb_version}} +{% if deprecation_warning %} +### DEPRECATION WARNING +{{deprecation_warning}} +{% endif %} + {% if fatal_checks %} ## Checks with FATAL results diff --git a/Lib/fontbakery/reporters/terminal.py b/Lib/fontbakery/reporters/terminal.py index db8e85af6e..8ac95e319b 100644 --- a/Lib/fontbakery/reporters/terminal.py +++ b/Lib/fontbakery/reporters/terminal.py @@ -197,6 +197,26 @@ def end(self): and self._counter[PASS.name] > 20 ): self._console.print(CUPCAKE) + if self.legacy_checkid_references: + self._console.print( + "[message-FATAL]DEPRECATION WARNING[/]:\n" + "By late-December 2024, FontBakery version 0.13.0 introduced a new" + " naming scheme for the check-IDs.\n" + "\n" + "Fontbakery detected usage of old IDs and performed an automatic" + " backwards-compatibility translation for you.\n" + "This automatic translation will be deprecated in the next" + " major release.\n" + "\n" + "Please start using the new check-IDs as documented at\n" + "https://github.com/fonttools/fontbakery/blob/" + "83db7cc2a6ad58585ddec9397306e0420843edb1/Lib/" + "fontbakery/legacy_checkids.py\n" + "\n" + "The following legacy check-IDs were detected:\n" + f" - {'\n - '.join(self.legacy_checkid_references)}\n" + "\n" + ) self._console.print("DONE!") def receive_result(self, checkresult: CheckResult):