Skip to content
Snippets Groups Projects
Commit 0c83218e authored by nimrod's avatar nimrod
Browse files

A few fixes from the improved tests.

- Add the hooks package.
- Refactor and fix the bulk_check function.
parent 313d052e
No related branches found
No related tags found
No related merge requests found
Pipeline #2220 failed
...@@ -7,24 +7,23 @@ import sys ...@@ -7,24 +7,23 @@ import sys
import hooks.utils import hooks.utils
def checker(): def tf_validate(directory):
def check(directory): if (
if ( hooks.utils.check_directory(
hooks.utils.check( ["terraform", "init", "-backend=false"], directory=directory
["terraform", "init", "-backend=false"], directory=directory )
) > 0
> 0 ):
): return 1
return 1 if (
if ( hooks.utils.check_directory(
hooks.utils.check(["terraform", "validate"], directory=directory) ["terraform", "validate"], directory=directory
> 0 )
): > 0
return 1 ):
return 1
return 0
return 0
return check
def main(): def main():
...@@ -36,7 +35,7 @@ def main(): ...@@ -36,7 +35,7 @@ def main():
os.putenv("TF_INPUT", "0") os.putenv("TF_INPUT", "0")
os.putenv("TF_IN_AUTOMATION", "1") os.putenv("TF_IN_AUTOMATION", "1")
return hooks.utils.bulk_check( return hooks.utils.bulk_check(
checker, hooks.utils.unique_directories(args.file) tf_validate, hooks.utils.unique_directories(args.file)
) )
......
...@@ -85,6 +85,6 @@ def bulk_check(checker, items): ...@@ -85,6 +85,6 @@ def bulk_check(checker, items):
returncode = 0 returncode = 0
for item in items: for item in items:
check = checker(item) check = checker(item)
if check() > 0: if check > 0:
returncode = 1 returncode = 1
return returncode return returncode
from setuptools import setup from setuptools import setup, find_packages
with open("VERSION", "r", encoding="utf-8") as fh: with open("VERSION", "r", encoding="utf-8") as fh:
VERSION = fh.read().strip() VERSION = fh.read().strip()
...@@ -23,4 +23,5 @@ setup( ...@@ -23,4 +23,5 @@ setup(
"poetry-check=hook.poetry_check:main", "poetry-check=hook.poetry_check:main",
] ]
}, },
packages=find_packages(),
) )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment