Skip to content

Commit cb3593c

Browse files
committed
Makefile: exit with error if hadolint is not empty
Updated the lint-dockerfiles target to: - Capture all hadolint output - Exit with code 1 if any warnings or errors are found - Work correctly in both GitHub Actions and local environments
1 parent b280474 commit cb3593c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,17 @@ lint: ## Run linter (clippy)
9898
.PHONY: lint-dockerfiles
9999
lint-dockerfiles: ## Check all Dockerfiles using hadolint
100100
@if [ "$$GITHUB_ACTIONS" = "true" ]; then \
101-
find . -name "Dockerfile*" -type f -exec hadolint {} \;; \
101+
OUTPUT=$$(find . -name "Dockerfile*" -type f -exec hadolint {} \;); \
102+
if [ -n "$$OUTPUT" ]; then \
103+
echo "$$OUTPUT"; \
104+
exit 1; \
105+
fi; \
102106
else \
103-
find . -name "Dockerfile*" -type f -exec sh -c 'docker run --rm -i hadolint/hadolint < "$$1"' _ {} \;; \
107+
OUTPUT=$$(find . -name "Dockerfile*" -type f -exec sh -c 'docker run --rm -i hadolint/hadolint < "$$1"' _ {} \;); \
108+
if [ -n "$$OUTPUT" ]; then \
109+
echo "$$OUTPUT"; \
110+
exit 1; \
111+
fi; \
104112
fi
105113

106114
.PHONY: setup-wasm-toolchain

0 commit comments

Comments
 (0)