diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 740fbfae0844c51ea5852512c2b56b5ad076d908..030b17c568f98b8d7889d6d114aaf383ca46850c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,18 +4,4 @@ - id: check-added-large-files - id: check-yaml - id: check-merge-conflict -- repo: https://www.shore.co.il/git/shell-pre-commit/ - sha: v0.1.0 - hooks: - - id: shell-lint - files: ansible-syntax-check|ansible-vault-check -- repo: local - hooks: - - id: piprot - name: piprot - description: Check up-to-date Python requirements - language: system - entry: piprot - args: ['--quiet', '--outdated'] - files: requirements.txt - always_run: true + - id: flake8 diff --git a/.travis.yml b/.travis.yml index bd44fadf8db48eeb8c053b8b9f02ef7bc5cc8b5b..2e3294c8bf1f626da614184881ba6ef54231b1b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ --- language: python -python: "2.7" +python: ["2.7", "3.3", "3.4", "3.5", "3.6"] dist: trusty sudo: false group: beta @@ -9,8 +9,12 @@ cache: - directories: - $HOME/.pre-commit +install: + - pip install pre-commit + script: - pre-commit run --all-files + - pip install . notifications: email: false diff --git a/LICENSE.txt b/LICENSE.txt index 26259f8ede5ead7e28994616f416fbe2e1f193e5..21f83f94ebe311f9f78caffc53a72d754f703e2a 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2016 Adar Nimrod +Copyright (c) 2017 Adar Nimrod Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.rst b/README.rst index 441f5323c29aa1bd574ac9ae6df8b724df932f56..8ece22c6a6c609bc6f0dfd716dc22bb7c0081ad1 100644 --- a/README.rst +++ b/README.rst @@ -1,21 +1,12 @@ -Ansible pre-commit hooks -######################## +Python pre-commit hooks +####################### -.. image:: https://travis-ci.org/adarnimrod/ansible-pre-commit.svg?branch=master - :target: https://travis-ci.org/adarnimrod/ansible-pre-commit +.. image:: https://travis-ci.org/adarnimrod/python-pre-commit.svg?branch=master + :target: https://travis-ci.org/adarnimrod/python-pre-commit Ansible `pre-commit <http://pre-commit.com/>`_ hooks. -- ansible-syntax-check: The hook runs - :code:`ansible --syntax-check` against playbooks declared. -- ansible-vault-check: The hook verifies that files that have :code:`vault` in - the filename are indeed vaulted. - -Dependencies ------------- - -- Ansible. -- Pre-commit. +- :code:`piprot`: Checks your requirements files for out of date packages. Installation ------------ @@ -24,23 +15,10 @@ Add the following to your :code:`.pre-commit-config.yaml`: .. code:: yaml - - repo: https://www.shore.co.il/git/ansible-pre-commit/ - sha: v0.4.0 + - repo: https://www.shore.co.il/git/python-pre-commit/ + sha: v0.1.0 hooks: - - id: ansible-syntax-check - # In case you want to specify other playbook files: - files: playbook.yml - - id: ansible-vault-check - -And run :code:`pre-commit autoupdate` to update the hooks. In case your -:code:`roles` directory isn't in the same directory as the playbook you're -testing or at :code:`/etc/ansible/roles` you need to declare the roles search -path in :code:`ansible.cfg` in the root of the repo like so: - -.. code:: - - [defaults] - roles_path=path/to/roles/directory:path/to/another/roles/directory + - id: piprot License ------- diff --git a/VERSION b/VERSION index 8f0916f768f0487bcf8d33827ce2c8dcecb645c1..6e8bf73aa550d4c57f6f35830f1bcdc7a4a62f38 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.0 +0.1.0 diff --git a/ansible-syntax-check b/ansible-syntax-check deleted file mode 100755 index e933723bdca7e94662e9cb17bc4b200434a20e64..0000000000000000000000000000000000000000 --- a/ansible-syntax-check +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -set -eu -for playbook in $@ -do - ansible-playbook --inventory=localhost, --syntax-check "$playbook" -done diff --git a/ansible-vault-check b/ansible-vault-check deleted file mode 100755 index 41aa16cba0d3f7cc5ff7ed90995925e88c9a1faf..0000000000000000000000000000000000000000 --- 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 index 593d42e2a9b93ac7af3a17d21b87e326f1c31c39..84e445fbe62f103945900832ab07d833ef6240d0 100644 --- a/hooks.yaml +++ b/hooks.yaml @@ -1,14 +1,8 @@ --- -- id: ansible-syntax-check - name: Syntax check Ansible playbooks - description: Check Ansible playbooks for syntax errors. +- id: piprot + name: Check requirements for out of date packages. + description: Check requirements for out of date packages. 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 + entry: piprot + args: ['--outdated'] + files: 'requirements.*\.txt$' diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index d700ebe1a64351d8b787f13528c28c44413500d2..0000000000000000000000000000000000000000 --- a/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -ansible==2.2.1.0 -pre-commit==0.11.0 -piprot==0.9.7 diff --git a/setup.py b/setup.py index 0e5dcfa48d5408ac19492d0d2a2eb888496e2f84..5134384366f99e5fb4e167493f79f9bc625b5de4 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup setup( - name='pre_commit_ansible_dummy_package', - version='0.1.0', - install_requires=['ansible==2.2.1.0'], + name='pre_commit_python_dummy_package', + version=open('VERSION', 'r').read().strip(), + install_requires=['piprot', 'docutils'], )