From f49584930b31081096699aefd09b307487488163 Mon Sep 17 00:00:00 2001 From: Silke Hofstra Date: Thu, 24 Oct 2024 13:53:46 +0200 Subject: [PATCH] ci/package_checks: Add check for monitoring.yml **Summary** Add a check that errors when `monitoring.yml` does not exist. --- common/CI/package_checks.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/common/CI/package_checks.py b/common/CI/package_checks.py index 4206bc233fa..604b9274604 100755 --- a/common/CI/package_checks.py +++ b/common/CI/package_checks.py @@ -301,6 +301,9 @@ def _read(self, path: str) -> str: with self._open(path) as f: return str(f.read()) + def _exists(self, path: str) -> bool: + return os.path.exists(self._path(path)) + def load_package_yml(self, file: str) -> PackageYML: with self._open(file) as f: return PackageYML(f) @@ -417,6 +420,19 @@ def _includes_homepage(self, file: str) -> bool: return 'homepage' in yaml.load(f) +class Monitoring(PullRequestCheck): + _error = '`monitoring.yml` is missing' + _level = Level.WARNING + + def run(self) -> List[Result]: + return [Result(message=self._error, file=f, level=self._level) + for f in self.package_files + if not self._has_monitoring_yml(f)] + + def _has_monitoring_yml(self, file: str) -> bool: + return self._exists(os.path.join(os.path.dirname(file), 'monitoring.yml')) + + class PackageBumped(PullRequestCheck): _msg = 'Package release is not incremented by 1' _msg_new = 'Package release is not 1' @@ -782,6 +798,7 @@ class Checker: CommitMessage, FrozenPackage, Homepage, + Monitoring, PackageBumped, PackageDependenciesOrder, PackageDirectory,