diff --git a/.ansible-lint b/.ansible-lint index 2a18051..226ad1c 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -2,6 +2,7 @@ # https://ansible-lint.readthedocs.io/en/latest/default_rules/ exclude_paths: - galaxy_roles/ + - .github/ skip_list: - experimental # all rules tagged as experimental diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..6463f81 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,14 @@ +name: pre-commit + +on: + pull_request: + push: + branches: [main] + +jobs: + pre-commit: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - uses: pre-commit/action@v3.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..6949f95 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,40 @@ +--- +# https://pre-commit.com/hooks.html +default_language_version: + python: python3 +exclude: > + .github +repos: + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.4.0 + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-json + - id: check-merge-conflict + - id: detect-private-key + - id: end-of-file-fixer + - id: forbid-new-submodules + - id: requirements-txt-fixer + - id: trailing-whitespace + + - repo: https://github.com/adrienverge/yamllint + rev: v1.35.1 + hooks: + - id: yamllint + args: [-c=.yamllint] + + - repo: https://github.com/jumanjihouse/pre-commit-hooks + rev: 3.0.0 # or specific git tag + hooks: + - id: forbid-binary + exclude: > + (?x)^( + screenshot.png + )$ + - id: git-check + - id: script-must-have-extension + - id: shellcheck + - id: shfmt diff --git a/ansible.sh b/ansible.sh index f39797a..ab8c097 100644 --- a/ansible.sh +++ b/ansible.sh @@ -1,7 +1,9 @@ +#!/bin/bash # Just `source ./ansible.rc` deactivate rm -rf ~/.py3 python3.12 -m venv ~/py3 +# shellcheck source=/dev/null source ~/py3/bin/activate pip install --upgrade pip wheel pip install -r requirements.txt diff --git a/inventory/test/hosts b/inventory/test/hosts index 7916aa6..1b127f5 100644 --- a/inventory/test/hosts +++ b/inventory/test/hosts @@ -14,4 +14,3 @@ controller ansible_host=10.0.0.206 controller ansible_host=10.0.0.206 [web] controller ansible_host=10.0.0.206 - diff --git a/requirements.txt b/requirements.txt index df7a5d7..bb11178 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ ansible-core<2.17.0 ansible-lint docker +pre-commit==4.0.1 diff --git a/roles/semaphore/templates/semaphore.service.j2 b/roles/semaphore/templates/semaphore.service.j2 index bf49ab8..a66e97e 100644 --- a/roles/semaphore/templates/semaphore.service.j2 +++ b/roles/semaphore/templates/semaphore.service.j2 @@ -13,4 +13,3 @@ TimeoutStopSec=60 [Install] WantedBy=multi-user.target -