Skip to content

Commit

Permalink
Adds new lint function for empty env files
Browse files Browse the repository at this point in the history
New function that raises a failure if the size of
the environment file, if this one exists, is zero.

Signed-off-by: mcasquer <mcasquer@redhat.com>
  • Loading branch information
mcasquer committed Sep 12, 2024
1 parent 21c9e97 commit e1db5ce
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tmt/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2130,6 +2130,22 @@ def lint_unknown_keys(self) -> LinterReturn:

yield LinterOutcome.PASS, 'correct keys are used'

def lint_empty_env_files(self) -> LinterReturn:
""" P001: env files are not empty """

env_files = self.node.get("environment-file") or []
if len(env_files) > 0:
for env_file in env_files:
path = os.path.normpath(env_file)
size = os.path.getsize(path)

if (path is not None and size == 0):
yield LinterOutcome.FAIL, f'the file "{env_file}" is empty'

return

yield LinterOutcome.PASS, 'no empty environment files found'

def lint_execute_not_defined(self) -> LinterReturn:
""" P002: execute step must be defined with "how" """

Expand Down

0 comments on commit e1db5ce

Please sign in to comment.