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 <[email protected]>
  • Loading branch information
mcasquer committed Sep 12, 2024
1 parent e93c587 commit c2b295a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tmt/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2130,6 +2130,21 @@ 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 env_files:
for env_file in env_files:
env_file = Path(env_file).resolve()

if not env_file.exists() or not env_file.stat().st_size:
yield LinterOutcome.FAIL, f'the file "{env_file}" does not exists or 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 c2b295a

Please sign in to comment.