Skip to content

Commit 4d100d0

Browse files
authored
Check new commits for yes/no in package.yml (#6355)
2 parents b93fb90 + 3a78c80 commit 4d100d0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

common/CI/package_checks.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,28 @@ def _includes_homepage(self, file: str) -> bool:
420420
return 'homepage' in yaml.load(f)
421421

422422

423+
class BooleanStyle(PullRequestCheck):
424+
_error = 'Invalid boolean style. Use true/false instead.'
425+
_level = Level.ERROR
426+
_pattern = re.compile(r':\s*(yes|no)\s*$', re.IGNORECASE)
427+
428+
def run(self) -> List[Result]:
429+
results: List[Result] = []
430+
431+
for f in self.package_files:
432+
with self._open(f) as stream:
433+
for i, line in enumerate(stream.readlines(), start=1):
434+
if self._pattern.search(line):
435+
results.append(Result(
436+
message=self._error,
437+
file=f,
438+
line=i,
439+
level=self._level
440+
))
441+
442+
return results
443+
444+
423445
class Monitoring(PullRequestCheck):
424446
_error = '`monitoring.yaml` is missing'
425447
_level = Level.WARNING
@@ -805,6 +827,7 @@ def _commit_package_yaml(self, ref: str) -> Optional[PackageYML]:
805827

806828
class Checker:
807829
checks = [
830+
BooleanStyle,
808831
CommitMessage,
809832
FrozenPackage,
810833
Homepage,

0 commit comments

Comments
 (0)