From 82af6938aaafc0b1b1582f42bd271661045f7a7d Mon Sep 17 00:00:00 2001 From: roman-kiselenko Date: Wed, 15 Nov 2023 18:51:07 +0300 Subject: [PATCH] add the config file for pre-commit Signed-off-by: roman-kiselenko --- .pre-commit-config.yaml | 32 ++++++++++++++++++++++++++++++++ DEVELOPMENT.md | 2 ++ README.md | 1 + 3 files changed, 35 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000000..1778b0f0d46 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,32 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +default_install_hook_types: ["pre-push"] +exclude: '(^vendor|.*golden$)' +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.2.0 + hooks: + - id: check-added-large-files + - id: check-yaml + args: ["--allow-multiple-documents"] + exclude: '(test\/gohelloworld\/gohelloworld-chart\/templates\/.*yaml$)' # Ignore yaml files with {{ }} cause they're not a valid + - id: check-shebang-scripts-are-executable + - id: check-json + - id: detect-private-key + exclude: "(.*_test.go|^examples\/v1\/pipelineruns\/beta\/isolated-workspaces.yaml$)" +- repo: local + hooks: + - id: lint-go + name: "Run make golangci-lint" + entry: make + args: ["golangci-lint"] + language: system + types: [go] + pass_filenames: false + - id: test-unit + name: "Unit testing" + entry: make + args: ["test-unit"] + language: system + types: [go] + pass_filenames: false \ No newline at end of file diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index b251396cb91..1cf7c923ced 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -56,6 +56,8 @@ You must install these tools: 1. [`git`](https://help.github.com/articles/set-up-git/): For source control +1. [`pre-commit`](https://pre-commit.com/#install): Git hook scripts + 1. [`go`](https://golang.org/doc/install): The language Tekton Pipelines is built in. > **Note** Golang [version v1.15](https://golang.org/dl/) or higher is recommended. diff --git a/README.md b/README.md index af8d9b10039..31275be08e7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # ![pipe](./pipe.png) Tekton Pipelines +[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit) [![Go Report Card](https://goreportcard.com/badge/tektoncd/pipeline)](https://goreportcard.com/report/tektoncd/pipeline) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4020/badge)](https://bestpractices.coreinfrastructure.org/projects/4020)