diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 958f5f0..5b2722c 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -15,6 +15,13 @@ kubernetes: { fileMatch: ['templates/.+\\.yaml$', 'tests/.*expected\\.yaml$'], }, + 'pre-commit': { enabled: true }, + regexManagers: [ + { + fileMatch: ['^.pre-commit-config.yaml$'], + matchStrings: [" +- '?(?[^' @=]+)(@|==)(?[^' @=]+)'? # (?.+)"], + }, + ], packageRules: [ /** Automerge the patch, the minor and the dev dependency */ { diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 1d72326..564d439 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -40,6 +40,16 @@ jobs: - run: echo "${HOME}/.local/bin" >> ${GITHUB_PATH} - run: python3 -m pip install --user --requirement=ci/requirements.txt + - uses: actions/cache@v3 + with: + path: ~/.cache/pre-commit + key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} + restore-keys: "pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}\npre-commit-" + - run: pre-commit run --all-files + env: + SKIP: helm-lock + - run: git diff + if: failure() - name: Checks run: c2cciutils-checks diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..a421de3 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,74 @@ +ci: + autoupdate_schedule: quarterly + skip: + - copyright + - helm-lock + - ripsecrets +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: detect-private-key + - id: check-merge-conflict + - id: check-ast + - id: debug-statements + - id: check-toml + - id: check-yaml + exclude: ^templates/.+\.yaml$ + args: + - --allow-multiple-documents + - id: check-json + - id: end-of-file-fixer + - id: trailing-whitespace + - id: mixed-line-ending + - repo: https://github.com/sbrunner/hooks + rev: 0.3.2 + hooks: + - id: copyright + - id: workflows-require-timeout + - id: helm-lock + - repo: https://github.com/codespell-project/codespell + rev: v2.2.2 + hooks: + - id: codespell + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v2.7.1 + hooks: + - id: prettier + additional_dependencies: + - prettier@2.8.1 # npm + - prettier-plugin-sh@0.12.8 # npm + - prettier-plugin-toml@0.3.1 # npm + - '@prettier/plugin-xml@0.12.0' # npm + - repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.9.0.2 + hooks: + - id: shellcheck + - repo: https://github.com/jumanjihouse/pre-commit-hooks + rev: 3.0.0 + hooks: + - id: git-check + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.20.0 + hooks: + - id: check-github-actions + - id: check-github-workflows + - id: check-jsonschema + name: Check GitHub Workflows set timeout-minutes + files: ^\.github/workflows/[^/]+$ + types: + - yaml + args: + - --builtin-schema + - github-workflows-require-timeout + - id: check-renovate + additional_dependencies: + - pyjson5==1.6.2 # pypi + - repo: https://github.com/sirwart/ripsecrets + rev: v0.1.5 + hooks: + - id: ripsecrets + - repo: https://github.com/gruntwork-io/pre-commit + rev: v0.1.17 + hooks: + - id: helmlint diff --git a/README.md b/README.md index 3bd2675..81d46b8 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,12 @@ With this chart you can easily deploy a simple custom application on Kubernetes, with only configuration. [See as example](./tests/values.yaml). + +## Contributing + +Install the pre-commit hooks: + +```bash +pip install pre-commit +pre-commit install --allow-missing-config +``` diff --git a/ci/requirements.txt b/ci/requirements.txt index 90843cf..5888ef0 100644 --- a/ci/requirements.txt +++ b/ci/requirements.txt @@ -1 +1,2 @@ c2cciutils[checks,publish]==1.5.0 +pre-commit==2.21.0