diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..92c541e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,14 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + args: + - --allow-multiple-documents + - id: check-merge-conflict + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.7.1.1 + hooks: + - id: shellcheck diff --git a/Makefile b/Makefile index c20cc9e..7979b7c 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,9 @@ .PHONY: all test clean -all: test shellcheck +all: check test test: test-negative test-positive -.PHONY: shellcheck -shellcheck: - shellcheck *.sh - .PHONY: test-positive test-positive: @echo "Check valid compose file." @@ -19,3 +15,13 @@ test-negative: ./compose-check.sh tests/docker-compose.bad.yml && { echo 'fail'; exit 1; } || echo 'ok' @echo "Check multiple files. Should error." ./compose-check.sh tests/docker-compose* && { echo 'fail'; exit 1; } || echo 'ok' + +# Installs pre-commit hooks +.PHONY: install-hooks +install-hooks: + pre-commit install --install-hooks + +# Checks files for encryption +.PHONY: check +check: + pre-commit run --all-files