diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 997fc850..e52bfb36 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.0 +current_version = 0.3.0 commit = True message = Bumps version to {new_version} tag = False diff --git a/Makefile b/Makefile index 94c49d09..7a138a97 100644 --- a/Makefile +++ b/Makefile @@ -178,31 +178,32 @@ cfn/lint: | guard/program/cfn-lint ## Runs eclint against the project eclint/lint: | guard/program/eclint guard/program/git eclint/lint: HAS_UNTRACKED_CHANGES ?= $(shell cd $(PROJECT_ROOT) && git status -s) -eclint/lint: ECLINT_FILES ?= git ls-files -z +eclint/lint: ECLINT_FILES ?= $(shell git -C $(PROJECT_ROOT) ls-files -z | grep -zv ".bats" | xargs -0) eclint/lint: @ echo "[$@]: Running eclint..." cd $(PROJECT_ROOT) && \ [ -z "$(HAS_UNTRACKED_CHANGES)" ] || (echo "untracked changes detected!" && exit 1) - cd $(PROJECT_ROOT) && \ - $(ECLINT_FILES) | grep -zv ".bats" | xargs -0 -I {} eclint check {} + eclint check $(ECLINT_FILES) @ echo "[$@]: Project PASSED eclint test!" -python/%: PYTHON_FILES ?= git ls-files --cached --others --exclude-standard '*.py' +python/%: PYTHON_FILES ?= $(shell git -C $(PROJECT_ROOT) ls-files --cached --others --exclude-standard '*.py' | xargs --no-run-if-empty printf "$(PROJECT_ROOT)/%s ") ## Checks format and lints Python files. Runs pylint on each individual ## file and uses a custom format for the lint messages. python/lint: | guard/program/pylint guard/program/black guard/program/git python/lint: @ echo "[$@]: Linting Python files..." - $(PYTHON_FILES) | xargs black --check - $(PYTHON_FILES) | $(XARGS) -n1 pylint -rn -sn \ - --msg-template="{path}:{line} [{symbol}] {msg}" {} - @ echo "[$@]: Python files PASSED lint test!" + black --check $(PYTHON_FILES) + for python_file in $(PYTHON_FILES); do \ + pylint --msg-template="{path}:{line} [{symbol}] {msg}" \ + -rn -sn $$python_file; \ + done + echo "[$@]: Python files PASSED lint test!" ## Formats Python files. python/format: | guard/program/black guard/program/git python/format: @ echo "[$@]: Formatting Python files..." - $(PYTHON_FILES) | xargs black + black $(PYTHON_FILES) @ echo "[$@]: Successfully formatted Python files!" ## Lints terraform files diff --git a/tests/make/eclint_lint_success.bats b/tests/make/eclint_lint_success.bats index 3d98d82e..76a7a533 100644 --- a/tests/make/eclint_lint_success.bats +++ b/tests/make/eclint_lint_success.bats @@ -18,11 +18,11 @@ done git add "$TEST_DIR/." git commit -m 'eclint success testing' - } @test "eclint/lint: success" { - run make eclint/lint + ECLINT_FILES=$(find "${TEST_DIR}" -type f | xargs echo) + run make eclint/lint ECLINT_FILES="${ECLINT_FILES}" [ "$status" -eq 0 ] } diff --git a/tests/make/python_format_success.bats b/tests/make/python_format_success.bats index 1575e9ef..b8e131b0 100644 --- a/tests/make/python_format_success.bats +++ b/tests/make/python_format_success.bats @@ -21,6 +21,10 @@ done run make python/format [ "$status" -eq 0 ] [[ "$output" == *"[python/format]: Successfully formatted Python files!"* ]] + + run make python/format PYTHON_FILES="$TEST_DIR/nested/*.py" + [ "$status" -eq 0 ] + [[ "$output" == *"1 file left unchanged"* ]] } function teardown() {