Commit b2c2e9ab authored by nimrod's avatar nimrod
Browse files

A whole lot of stuff.

- A bunch of hooks, some copied from previous repos, some improvements
  on previous attempts, some new.
- README, CI, etc.
- A Python utilities module for helping with Python hooks.
parent 093d2c98
Loading
Loading
Loading
Loading
Loading

.gitlab-ci.yml

0 → 100644
+6 −0
Original line number Diff line number Diff line
---
include:
  - project: shore/ci-templates
    file: templates/pre-commit.yml
  - project: shore/ci-templates
    file: templates/pre-commit-repo.yml
+105 −0
Original line number Diff line number Diff line
---
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks.git
    rev: v4.0.1
    hooks:
      - id: check-added-large-files
      - id: check-executables-have-shebangs
      - id: check-merge-conflict
      - id: check-shebang-scripts-are-executable
      - id: check-yaml
      - id: detect-private-key
      - id: end-of-file-fixer
      - id: trailing-whitespace

  - repo: https://github.com/codespell-project/codespell.git
    rev: v2.1.0
    hooks:
      - id: codespell

  - repo: https://github.com/Yelp/detect-secrets.git
    rev: v1.1.0
    hooks:
      - id: detect-secrets

  - repo: https://gitlab.com/devopshq/gitlab-ci-linter
    rev: v1.0.3
    hooks:
      - id: gitlab-ci-linter
        args:
          - "--server"
          - https://git.shore.co.il

  - repo: https://github.com/amperser/proselint.git
    rev: 0.10.2
    hooks:
      - id: proselint
        types: [plain-text]
        exclude: LICENSE

  - repo: https://github.com/adrienverge/yamllint.git
    rev: v1.26.3
    hooks:
      - id: yamllint

  - repo: https://github.com/executablebooks/mdformat.git
    rev: 0.7.9
    hooks:
      - id: mdformat

  - repo: https://github.com/ambv/black.git
    rev: 21.8b0
    hooks:
      - id: black
        args:
          - |
              --line-length=79

  - repo: https://github.com/PyCQA/prospector.git
    rev: 1.5.1b0
    hooks:
      - id: prospector
        args:
          - |-
            --max-line-length=79
          - |-
            --with-tool=bandit
          - |-
            --without-tool=pep257
          - |-
            --doc-warnings
          - |-
            --test-warnings
          - |-
            --full-pep8
          - |-
            --strictness=high
          - |-
            --no-autodetect
        additional_dependencies:
          - bandit

  - repo: https://gitlab.com/pycqa/flake8.git
    rev: 3.9.2
    hooks:
      - id: flake8
        args:
          - |-
            --doctests
        additional_dependencies:
          - flake8-bugbear

  - repo: https://github.com/pre-commit/pre-commit.git
    rev: v2.15.0
    hooks:
      - id: validate_manifest

  - repo: https://git.shore.co.il/nimrod/shell-pre-commit.git
    rev: v0.6.0
    hooks:
      - id: shell-lint

  - repo: https://github.com/shellcheck-py/shellcheck-py.git
    rev: v0.7.2.1
    hooks:
      - id: shellcheck

.pre-commit-hooks.yaml

0 → 100644
+72 −0
Original line number Diff line number Diff line
---
- id: shell-validate
  name: Lint shell scripts
  description: Run /bin/sh -en against shell scripts.
  language: script
  entry: ./hooks/shell-validate
  types: [shell]
  minimum_pre_commit_version: 0.15.0 #  Because of types.

- id: ansible-syntax-check
  name: Syntax check Ansible playbooks
  description: Check Ansible playbooks for syntax errors.
  language: python
  entry: ansible-playbook
  files: playbook\.yml
  types: [yaml]
  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

- id: docker-compose
  name: docker-compose config
  description: Validate the Docker Compose file using docker-compose config
  minimum_pre_commit_version: '0.18.0'
  language: python
  entry: docker-compose-validate
  files: docker-compose
  types: [yaml]

- id: terraform-fmt
  name: Format Terraform files
  description: Format Terraform files using terraform fmt
  language: python
  types: [terraform]
  entry: terraform-fmt

- id: terraform-validate
  name: Validate Terraform modules
  description: Validate Terraform modules using terraform validate
  language: python
  types: [terraform]
  entry: terraform-validate

- id: poetry-check
  name: poetry check
  description: Validate pyproject.toml files using Poetry
  language: python
  entry: poetry-check
  types: [toml]
  files: pyproject

- id: branch-merge-conflicts
  name: branch merge conflicts
  description: Checks for merge conflicts with a specific branch.
  language: script
  entry: ./hooks/branch-merge-conflicts
  pass_filenames: false
  always_run: true

- id: pip-outdated
  name: pip-outdated
  description: Find outdated dependencies in your requirements files.
  language: python
  entry: pip-outdated
  args: ['--verbose']
  files: 'requirements.*\.txt$'
+11 −3
Original line number Diff line number Diff line
@@ -4,12 +4,20 @@ A collection of [pre-commit](https://pre-commit.com/) hooks.

## Example .pre-commit-config.yaml


```yaml
---
- repo: https://git.shore.co.il/nimrod/pre-commit-hooks.git
  rev: 0.1.0
  rev: 0.1.0  # Check for the latest tag or run pre-commit autoupdate.
  hooks:
    - id: shell-validate
    - id: ansible-syntax-check
    - id: ansible-vault-check
    - id: docker-compose
    - id: terraform-fmt  # uses the installed system terraform.
    - id: terraform-validate  # uses the installed system terraform.
    - id: poetry-check
    - id: branch-merge-conflict
    - id: pip-outdated
```

## License

VERSION

0 → 100644
+1 −0
Original line number Diff line number Diff line
0.0.1
Loading