Browse Source

Add pre-commit hooks of our own

Adds some basic near-universal checks and shellcheck
master
IamTheFij 1 year ago
parent
commit
5c7dc7758b
  1. 14
      .pre-commit-config.yaml
  2. 16
      Makefile

14
.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

16
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

Loading…
Cancel
Save