build(git): add pre-commit package

This commit is contained in:
Nathaniel Landau
2022-10-07 14:38:54 -04:00
parent 8e134c2d71
commit f5497c0983
2 changed files with 142 additions and 66 deletions

68
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,68 @@
---
repos:
- hooks:
- id: "commitizen"
repo: https://github.com/commitizen-tools/commitizen
rev: master
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-builtin-literals
- id: check-case-conflict
- id: check-docstring-first
- id: check-json
exclude: ^files/certs
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-vcs-permalinks
- id: check-xml
- id: check-yaml
- id: detect-private-key
- id: mixed-line-ending
- id: trailing-whitespace
types: [python]
args: [--markdown-linebreak-ext=md]
- repo: https://github.com/adrienverge/yamllint.git
rev: master
hooks:
- id: yamllint
exclude: vault\.yml|\.pre-commit-config.yaml
files: \.(yaml|yml)$
types: [file, yaml]
entry: yamllint --strict --config-file .yamllint.yml
- repo: local
hooks:
- id: ansible-lint
name: running ansible-lint
language: system
exclude: |
(?x)^(
(inventory|vault|variables|default_variables)\.ya?ml|
\..*\.ya?ml|
galaxy-roles/.*\.ya?ml|
templates/.*\.ya?ml|
files/.*\.ya?ml
)$
files: \.ya?ml$
entry: ansible-lint --force-color --parseable --config-file .ansible-lint.yml
- id: lint-shellscript-templates
name: lint shellscript templates
language: system
files: \.sh\.j2$
entry: shellcheck -x --exclude=1009,1054,1056,1072,1073,1083,2001,2148
- id: lint-shellscripts
name: lint shellscripts
language: system
files: \.sh$
entry: shellcheck -x --exclude=2001,2148
- id: run-shellscripts-bats-tests
name: run bats unit tests
language: system
files: \.bats$
entry: bats -t

View File

@@ -1,3 +1,5 @@
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
# Ansible Homelab Configuration
Repository for managing computers, services, and orchestration on my home LAN via Ansible. **These files are heavily customized for my unique set-up and preferences** and are published in the hopes they are helpful to someone as a reference. Do not expect them to work without heavy customization for your own use.
@@ -174,3 +176,9 @@ Nomad is used as the orchestration engine. The following conventions are used th
- Indented heredocs can be used using `value = <<-EOT` to analyses the lines in the sequence to find the one with the smallest number of leading spaces, and then trims that many spaces from the beginning of all of the lines.
- Nomad env variables or Consul key/values used in templates will reload jobs when configurations change dynamically
- Tags in service stanzas integrate with Traefik via the Consul catalog
# Developing
- This repository makes use of the wonderful Python [pre-commit](https://pre-commit.com/) package. To install, run `pre-commit install --install-hooks`
- This repository uses [Commitizen](https://github.com/commitizen-tools/commitizen) to enforce conventional commits.