From a639b782cfdacb65f03e9c59485fe7a17fb3c794 Mon Sep 17 00:00:00 2001 From: Dafydd Jones Date: Sat, 3 Oct 2020 10:52:33 +0100 Subject: [PATCH] ci(pre-commit): add to formula [skip ci] * Automated using https://github.com/myii/ssf-formula/pull/259 --- .pre-commit-config.yaml | 39 +++++++++++++++++++-------------------- .travis.yml | 19 +++++++++++++------ bin/install-hooks | 16 ++++++++++++++++ 3 files changed, 48 insertions(+), 26 deletions(-) create mode 100755 bin/install-hooks diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f4893e6..86cf5fa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,40 +17,39 @@ repos: stages: [manual] additional_dependencies: ['@commitlint/config-conventional@8.3.4'] always_run: true + - repo: https://github.com/adithyabsk/mirrors-rubocop + rev: v0.91.0 + hooks: + - id: rubocop + name: Check Ruby files with rubocop + args: [--debug] + always_run: true + pass_filenames: false - repo: https://github.com/jumanjihouse/pre-commit-hooks rev: 2.1.3 hooks: - - id: rubocop - exclude: ^Gemfile\.lock$ - id: shellcheck name: Check shell scripts with shellcheck - exclude_types: [zsh] + files: ^.*\.(sh|bash|ksh)$ + types: [] args: [] - repo: https://github.com/adrienverge/yamllint.git rev: v1.23.0 hooks: - id: yamllint name: Check YAML syntax with yamllint - args: [--strict] - types: [file] - files: > - (?x)^( - \.salt-lint| - \.yamllint| - .*\.example| - test/.*\.sls| - .*\.(yaml|yml) - )$ - exclude: ^test/salt/.*/.*\.sls$ + args: [--strict, '.'] + always_run: true + pass_filenames: false - repo: https://github.com/warpnet/salt-lint rev: v0.3.0 hooks: - id: salt-lint name: Check Salt files using salt-lint files: ^.*\.(sls|jinja|j2|tmpl|tst)$ - - repo: https://github.com/myint/rstcheck - rev: 3f929574 - hooks: - - id: rstcheck - name: Check reST files using rstcheck - args: [--report=warning] +# - repo: https://github.com/myint/rstcheck +# rev: 3f929574 +# hooks: +# - id: rstcheck +# name: Check reST files using rstcheck +# args: [--report=warning] diff --git a/.travis.yml b/.travis.yml index a7edc73..affb781 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,9 +31,6 @@ jobs: # Run all of the linters in a single job - language: 'node_js' node_js: 'lts/*' - cache: - directories: - - $HOME/.cache/pre-commit env: 'Lint' name: 'Lint: salt-lint, yamllint, rubocop, shellcheck & commitlint' before_install: 'skip' @@ -57,10 +54,20 @@ jobs: - npm i -D @commitlint/config-conventional @commitlint/travis-cli - commitlint-travis + + # Run `pre-commit` linters in a single job + - language: 'python' + env: 'Lint_pre-commit' + name: 'Lint: pre-commit' + before_install: 'skip' + cache: + directories: + - $HOME/.cache/pre-commit + script: # Install and run `pre-commit` - - pip install pre-commit - - pre-commit run --all-files --verbose - - pre-commit run --hook-stage manual --verbose commitlint-travis + - pip install pre-commit==2.7.1 + - pre-commit run --all-files --color always --verbose + - pre-commit run --color always --hook-stage manual --verbose commitlint-travis ## Define the rest of the matrix based on Kitchen testing # Make sure the instances listed below match up with diff --git a/bin/install-hooks b/bin/install-hooks new file mode 100755 index 0000000..840bb6c --- /dev/null +++ b/bin/install-hooks @@ -0,0 +1,16 @@ +#!/usr/bin/env sh +set -o nounset # Treat unset variables as an error and immediately exit +set -o errexit # If a command fails exit the whole script + +if [ "${DEBUG:-false}" = "true" ]; then + set -x # Run the entire script in debug mode +fi + +if ! command -v pre-commit >/dev/null 2>&1; then + echo "pre-commit not found: please install or check your PATH" >&2 + echo "See https://pre-commit.com/#installation" >&2 + exit 1 +fi + +pre-commit install --install-hooks +pre-commit install --hook-type commit-msg --install-hooks