1111# Default configuration
1212# -------------------------------------------------------------------------------------------------
1313CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
14+ # File lint
1415FL_VERSION = 0.4
15- FL_IGNORES = .git/,.github/,tests/
16+ FL_IGNORES = .git/,.github/
17+ # Json lint
18+ JL_VERSION = 1.6.0-0.5
19+ JL_IGNORES = .git/,.github/
20+ # Yamllint
21+ YL_VERSION = 1.26-0.9
22+ # Shellcheck
23+ SC_IGNORES = .git/,.github/
24+ SC_VERSION = stable
1625
1726
1827# -------------------------------------------------------------------------------------------------
@@ -21,6 +30,8 @@ FL_IGNORES = .git/,.github/,tests/
2130.PHONY: lint
2231lint: lint-files
2332lint: lint-yaml
33+ lint: lint-json
34+ lint: lint-bash
2435
2536
2637.PHONY: lint-files
@@ -39,9 +50,44 @@ lint-files:
3950
4051.PHONY: lint-yaml
4152lint-yaml:
42- @# Lint all files
4353 @echo "################################################################################"
4454 @echo "# Lint Yaml"
4555 @echo "################################################################################"
46- @docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data cytopia/yamllint .
56+ @if docker run --rm $$(tty -s && echo "-it" || echo) -v "$(CURRENT_DIR):/data:ro" -w /data cytopia/yamllint:$(YL_VERSION) .; then \
57+ echo "OK"; \
58+ else \
59+ echo "Failed"; \
60+ exit 1; \
61+ fi;
4762 @echo
63+
64+
65+ .PHONY: lint-json
66+ lint-json:
67+ @echo "################################################################################"
68+ @echo "# Lint JSON"
69+ @echo "################################################################################"
70+ @if docker run --rm $$(tty -s && echo "-it" || echo) -v "$(CURRENT_DIR):/data:ro" -w /data cytopia/jsonlint:$(JL_VERSION) \
71+ -t ' ' -i '$(JL_IGNORES)' '*.json'; then \
72+ echo "OK"; \
73+ else \
74+ echo "Failed"; \
75+ exit 1; \
76+ fi;
77+ @echo
78+
79+
80+ .PHONY: lint-bash
81+ lint-bash:
82+ @echo "################################################################################"
83+ @echo "# Lint Bash"
84+ @echo "################################################################################"
85+ @IGNORES=""; \
86+ if [ "$(SC_IGNORES)" ]; then \
87+ IGNORES="$$( echo "-not \( -path \"./$(SC_IGNORES)*\"" | sed 's|,|*" -o -path "./|g' ) \)"; \
88+ fi; \
89+ CMD="find . -name '*.sh' $${IGNORES} -print0"; \
90+ echo "$${CMD}"; \
91+ if [ "$$( eval "$${CMD}" )" != "" ]; then \
92+ eval "$${CMD}" | xargs -0 -n1 docker run --rm -v $(CURRENT_DIR):/data -w /data koalaman/shellcheck:$(SC_VERSION) --shell=bash; \
93+ fi
0 commit comments