Skip to content

Commit f1473c6

Browse files
author
Alan Christie
committed
Fixes linter
Fixes dry-run - was running checks (which is pointless)
1 parent 16135bd commit f1473c6

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

jote/jote.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,20 @@ def _lint(definition_file: str) -> bool:
4141
print(f'! The yamllint file ({_YAMLLINT_FILE}) is missing')
4242
return False
4343

44-
errors = linter.run(definition_file, YamlLintConfig(file=_YAMLLINT_FILE))
44+
errors = linter.run(open(definition_file),
45+
YamlLintConfig(file=_YAMLLINT_FILE))
4546
if errors:
46-
print(f'! Job definition "{definition_file}" fails yamllint: -')
47+
# We're given a 'generator' and we don't know if there are errors
48+
# until we iterator over it. So here we print an initial error message
49+
# on the first error.
50+
found_errors: bool = False
4751
for error in errors:
52+
if not found_errors:
53+
print(f'! Job definition "{definition_file}" fails yamllint: -')
54+
found_errors = True
4855
print(error)
49-
return False
56+
if found_errors:
57+
return False
5058

5159
return True
5260

@@ -280,7 +288,9 @@ def _test(args: argparse.Namespace,
280288

281289
# Inspect the results
282290
# (only if successful so far)
283-
if test_status and job_definition.tests[job_test_name].checks.outputs:
291+
if test_status \
292+
and not args.dry_run \
293+
and job_definition.tests[job_test_name].checks.outputs:
284294
test_status = \
285295
_check(t_compose,
286296
job_definition.tests[job_test_name].checks.outputs)
@@ -367,7 +377,7 @@ def main() -> None:
367377
job_definitions, num_tests = _load(args.skip_lint)
368378
if num_tests < 0:
369379
print('! FAILURE')
370-
print('! Definition file has filed yamllint')
380+
print('! Definition file has failed yamllint')
371381
arg_parser.error('Done (FAILURE)')
372382

373383
msg: str = 'test' if num_tests == 1 else 'tests'

0 commit comments

Comments
 (0)