From 1eb548d382126bb1917c5a9fc85d4924c441beda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernd=20Sch=C3=B6rgers?= Date: Wed, 9 Sep 2020 14:00:50 +0200 Subject: [PATCH] Add pre-commit support (#42) --- .pre-commit-config.yaml | 13 +++++++++++++ CONTRIBUTING.md | 10 +++++++--- README.md | 1 + 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..92a0f768 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,13 @@ +# See https://pre-commit.com for more information +repos: +- repo: local + hooks: + - id: ct-lint + name: "Chart Test: Lint" + language: docker_image + pass_filenames: false + types: ['file'] + files: '^charts/.*(\.ya?ml|\.tpl|\.helmignore|NOTES.txt)' + entry: -u 0 quay.io/helmpack/chart-testing:v3.0.0 ct + args: + - lint diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b3704ab9..591bd599 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,9 +33,9 @@ See `git help commit`: ### Technical Requirements -* Must follow [Charts best practices](https://helm.sh/docs/topics/chart_best_practices/) -* Must pass CI jobs for linting and installing changed charts with the [chart-testing](https://github.com/helm/chart-testing) tool -* Any change to a chart requires a version bump following [semver](https://semver.org/) principles. See [Immutability(#immutability) and [Versioning](#versioning) below +* Must follow [Charts best practices](https://helm.sh/docs/topics/chart_best_practices/). +* Must pass CI jobs for linting and installing changed charts with the [chart-testing](https://github.com/helm/chart-testing) tool See [pre-commit](#pre-commit) below. +* Any change to a chart requires a version bump following [semver](https://semver.org/) principles. See [Immutability](#immutability) and [Versioning](#versioning) below. Once changes have been merged, the release job will automatically run to package and release changed charts. @@ -51,3 +51,7 @@ Charts should start at `1.0.0`. Any breaking (backwards incompatible) changes to 1. Bump the MAJOR version 2. In the README, under a section called "Upgrading", describe the manual steps necessary to upgrade to the new (specified) MAJOR version + +### pre-commit + +This repo supports the [pre-commit](https://pre-commit.com) framework. By installing the framework (see [docs](https://pre-commit.com/#install)) it is possible to perform the chart linting step before committing your code. This can help prevent linter issues in the pipeline. Note that this requires having Docker running on your development environment. diff --git a/README.md b/README.md index 185ac5af..03b48635 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![](https://github.com/k8s-at-home/charts/workflows/Release%20Charts/badge.svg?branch=master)](https://github.com/k8s-at-home/charts/actions) +[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) ## Usage