From d46d9b6a50f31b8e9a0eb924ee5d123c975c98b2 Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Fri, 10 Apr 2020 20:56:18 +0300 Subject: [PATCH] A plethora of small updates. - Update Ansible. - More pre-commit checks. - Replace the Vault shell script with a simpler grep hook. --- .pre-commit-config.yaml | 35 +++++++++++++++++++++++------------ .pre-commit-hooks.yaml | 16 +++++++++++++++- .travis.yml | 8 +++++++- README.rst | 4 ++-- ansible-vault-check | 7 ------- hooks.yaml | 14 -------------- setup.py | 12 ++++++------ 7 files changed, 53 insertions(+), 43 deletions(-) mode change 120000 => 100644 .pre-commit-hooks.yaml delete mode 100755 ansible-vault-check delete mode 100644 hooks.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 36e74f9..f2941a1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,24 @@ +# vim:ff=unix ts=2 sw=2 ai expandtab +--- repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v1.4.0 - hooks: - - id: check-added-large-files - - id: check-yaml - - id: check-merge-conflict - - id: flake8 -- repo: https://www.shore.co.il/git/shell-pre-commit/ - rev: v0.6.0 - hooks: - - id: shell-lint - files: ansible-vault-check + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.5.0 + hooks: + - id: check-added-large-files + - id: check-merge-conflict + - id: detect-private-key + - id: trailing-whitespace + - repo: https://github.com/Lucas-C/pre-commit-hooks-markup + rev: v1.0.0 + hooks: + - id: rst-linter + - repo: https://github.com/adrienverge/yamllint + rev: v1.21.0 + hooks: + - id: yamllint + - repo: https://github.com/amperser/proselint/ + rev: 0.10.2 + hooks: + - id: proselint + types: [plain-text] + exclude: LICENSE|requirements diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml deleted file mode 120000 index 4641bf3..0000000 --- a/.pre-commit-hooks.yaml +++ /dev/null @@ -1 +0,0 @@ -hooks.yaml \ No newline at end of file diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 0000000..1fd8ed1 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,15 @@ +--- +- id: ansible-syntax-check + name: Syntax check Ansible playbooks + description: Check Ansible playbooks for syntax errors. + language: python + entry: ansible-playbook + files: playbook.yml + args: ['--inventory=localhost,', '--syntax-check'] +- id: ansible-vault-check + name: Verify vaulted files + description: Verify that Ansible Vault files are vaulted. + language: pygrep + files: vault + entry: |- + ANSIBLE_VAULT diff --git a/.travis.yml b/.travis.yml index 4f7116e..3dc7fc4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,12 @@ --- language: python -python: ["2.7", "3.4", "3.5", "3.6"] +python: + - "2.7" + - "3.4" + - "3.5" + - "3.6" + - "3.7" + - "3.8" dist: trusty sudo: false group: beta diff --git a/README.rst b/README.rst index feac6e8..6522788 100644 --- a/README.rst +++ b/README.rst @@ -14,7 +14,7 @@ Ansible `pre-commit <http://pre-commit.com/>`_ hooks. Requirements ------------ -- Pre-commit. +- Pre-commit 1.2 or later. - Python 2.7 or 3.4 or later. Installation @@ -25,7 +25,7 @@ Add the following to your :code:`.pre-commit-config.yaml`: .. code:: yaml - repo: https://www.shore.co.il/git/ansible-pre-commit/ - sha: v0.6.0 + sha: v0.9.0 hooks: - id: ansible-syntax-check files: site.yml #In case you want to specify other playbook files. diff --git a/ansible-vault-check b/ansible-vault-check deleted file mode 100755 index 41aa16c..0000000 --- a/ansible-vault-check +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -set -eu -for filename in $@ -do - grep -q ANSIBLE_VAULT "$filename" || \ - (echo "$filename is not vaulted." && exit 1) -done diff --git a/hooks.yaml b/hooks.yaml deleted file mode 100644 index 593d42e..0000000 --- a/hooks.yaml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- id: ansible-syntax-check - name: Syntax check Ansible playbooks - description: Check Ansible playbooks for syntax errors. - language: python - entry: ansible-playbook - files: playbook.yml - args: ['--inventory=localhost,', '--syntax-check'] -- id: ansible-vault-check - name: Verify vaulted files - description: Verify that Ansible Vault files are vaulted. - language: script - entry: ansible-vault-check - files: vault diff --git a/setup.py b/setup.py index f0e4be2..cbbe0da 100644 --- a/setup.py +++ b/setup.py @@ -2,10 +2,10 @@ from setuptools import setup setup( - name='pre_commit_ansible_dummy_package', - url='https://www.shore.co.il/git/ansible-pre-commit', - author='Nimrod Adar', - author_email='nimrod@shore.co.il', - version=open('VERSION', 'r').read().strip(), - install_requires=['ansible==2.6.2'], + name="pre_commit_ansible_dummy_package", + url="https://www.shore.co.il/git/ansible-pre-commit", + author="Nimrod Adar", + author_email="nimrod@shore.co.il", + version=open("VERSION", "r").read().strip(), + install_requires=["ansible==2.9.6"], ) -- GitLab