Skip to content

Commit 0bf252a

Browse files
committed
Check new commits for yes/no in package.yml
**Summary** - Add checks for yes/no in package.yml. - Resolves #6346
1 parent 3df6762 commit 0bf252a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

common/CI/package_checks.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,26 @@ def _includes_homepage(self, file: str) -> bool:
419419
yaml.default_flow_style = False
420420
return 'homepage' in yaml.load(f)
421421

422+
class BooleanStyle(PullRequestCheck):
423+
_error = 'Invalid boolean style. Use true/false instead.'
424+
_level = Level.ERROR
425+
_pattern = re.compile(r':\s*(yes|no)\s*$', re.IGNORECASE)
426+
427+
def run(self) -> List[Result]:
428+
results: List[Result] = []
429+
430+
for f in self.package_files:
431+
with self._open(f) as stream:
432+
for i, line in enumerate(stream.readlines(), start=1):
433+
if self._pattern.search(line):
434+
results.append(Result(
435+
message=self._error,
436+
file=f,
437+
line=i,
438+
level=self._level
439+
))
440+
441+
return results
422442

423443
class Monitoring(PullRequestCheck):
424444
_error = '`monitoring.yaml` is missing'
@@ -805,6 +825,7 @@ def _commit_package_yaml(self, ref: str) -> Optional[PackageYML]:
805825

806826
class Checker:
807827
checks = [
828+
BooleanStyle,
808829
CommitMessage,
809830
FrozenPackage,
810831
Homepage,

0 commit comments

Comments
 (0)