From 0215b3add48adba2e88b4077236cb4dd603a8719 Mon Sep 17 00:00:00 2001 From: Donatas Navidonskis Date: Thu, 21 Mar 2024 14:45:44 +0200 Subject: [PATCH 01/11] feat: add markdownlint hook --- .markdownlint.yaml | 278 +++++++++++++++++++++++++++++ hooks/markdown-lint/.lefthook.yaml | 13 ++ hooks/markdown-lint/README.md | 18 ++ 3 files changed, 309 insertions(+) create mode 100644 .markdownlint.yaml create mode 100644 hooks/markdown-lint/.lefthook.yaml create mode 100644 hooks/markdown-lint/README.md diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..d539428 --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,278 @@ +# SPDX-FileCopyrightText: Copyright Boozt Fashion, AB +# SPDX-License-Identifier: MIT +--- +# Default state for all rules +default: true +# Path to configuration file to extend +extends: null +# MD001/heading-increment: Heading levels should only increment by one level +# at a time: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md001.md +MD001: true +# MD003/heading-style: Heading style: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md003.md +MD003: + # Heading style + style: "consistent" +# MD004/ul-style: Unordered list style: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md004.md +MD004: + # List style + style: "consistent" +# MD005/list-indent: Inconsistent indentation for list items at the same +# level: https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md005.md +MD005: true +# MD007/ul-indent: Unordered list indentation: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md007.md +MD007: + # Spaces for indent + indent: 2 + # Whether to indent the first level of the list + start_indented: false + # Spaces for first level indent (when start_indented is set) + start_indent: 2 +# MD009/no-trailing-spaces: Trailing spaces: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md009.md +MD009: + # Spaces for line break + br_spaces: 2 + # Allow spaces for empty lines in list items + list_item_empty_lines: false + # Include unnecessary breaks + strict: false +# MD010/no-hard-tabs: Hard tabs: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md010.md +MD010: + # Include code blocks + code_blocks: true + # Fenced code languages to ignore + ignore_code_languages: [] + # Number of spaces for each hard tab + spaces_per_tab: 1 +# MD011/no-reversed-links: Reversed link syntax: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md011.md +MD011: true +# MD012/no-multiple-blanks: Multiple consecutive blank lines: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md012.md +MD012: + # Consecutive blank lines + maximum: 1 +# MD013/line-length: Line length: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md013.md +MD013: + # Number of characters + line_length: 80 + # Number of characters for headings + heading_line_length: 80 + # Number of characters for code blocks + code_block_line_length: 80 + # Include code blocks + code_blocks: true + # Include tables + tables: true + # Include headings + headings: true + # Strict length checking + strict: false + # Stern length checking + stern: false +# MD014/commands-show-output: Dollar signs used before commands without showing +# output : https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md014.md +MD014: true +# MD018/no-missing-space-atx: No space after hash on atx style heading: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md018.md +MD018: true +# MD019/no-multiple-space-atx: Multiple spaces after hash on atx style heading: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md019.md +MD019: true +# MD020/no-missing-space-closed-atx: No space inside hashes on closed +# atx style heading: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md020.md +MD020: true +# MD021/no-multiple-space-closed-atx: Multiple spaces inside hashes on closed +# atx style heading: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md021.md +MD021: true +# MD022/blanks-around-headings: Headings should be surrounded by blank lines: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md022.md +MD022: + # Blank lines above heading + lines_above: 1 + # Blank lines below heading + lines_below: 1 +# MD023/heading-start-left: Headings must start at the beginning of the line: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md023.md +MD023: true +# MD024/no-duplicate-heading: Multiple headings with the same content: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md024.md +MD024: + # Only check sibling headings + siblings_only: false +# MD025/single-title/single-h1: Multiple top-level headings +# in the same document: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md025.md +MD025: + # Heading level + level: 1 + # RegExp for matching title in front matter + front_matter_title: "^\\s*title\\s*[:=]" +# MD026/no-trailing-punctuation: Trailing punctuation in heading: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md026.md +MD026: + # Punctuation characters + punctuation: ".,;:!。,;:!" +# MD027/no-multiple-space-blockquote: Multiple spaces after blockquote symbol: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md027.md +MD027: true +# MD028/no-blanks-blockquote: Blank line inside blockquote: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md028.md +MD028: true +# MD029/ol-prefix: Ordered list item prefix: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md029.md +MD029: + # List style + style: "one_or_ordered" +# MD030/list-marker-space: Spaces after list markers: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md030.md +MD030: + # Spaces for single-line unordered list items + ul_single: 1 + # Spaces for single-line ordered list items + ol_single: 1 + # Spaces for multi-line unordered list items + ul_multi: 1 + # Spaces for multi-line ordered list items + ol_multi: 1 +# MD031/blanks-around-fences: Fenced code blocks should be surrounded by +# blank lines: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md031.md +MD031: + # Include list items + list_items: true +# MD032/blanks-around-lists: Lists should be surrounded by blank lines: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md032.md +MD032: true +# MD033/no-inline-html: Inline HTML: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md033.md +MD033: + # Allowed elements + allowed_elements: [] +# MD034/no-bare-urls: Bare URL used: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md034.md +MD034: true +# MD035/hr-style: Horizontal rule style: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md035.md +MD035: + # Horizontal rule style + style: "consistent" +# MD036/no-emphasis-as-heading: Emphasis used instead of a heading: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md036.md +MD036: + # Punctuation characters + punctuation: ".,;:!?。,;:!?" +# MD037/no-space-in-emphasis: Spaces inside emphasis markers: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md037.md +MD037: true +# MD038/no-space-in-code: Spaces inside code span elements: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md038.md +MD038: true +# MD039/no-space-in-links: Spaces inside link text: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md039.md +MD039: true +# MD040/fenced-code-language: Fenced code blocks should have +# a language specified: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md040.md +MD040: + # List of languages + allowed_languages: [] + # Require language only + language_only: false +# MD041/first-line-heading/first-line-h1 : First line in a file should +# be a top-level heading: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md041.md +MD041: + # Heading level + level: 1 + # RegExp for matching title in front matter + front_matter_title: "^\\s*title\\s*[:=]" +# MD042/no-empty-links: No empty links: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md042.md +MD042: true +# MD043/required-headings: Required heading structure: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md043.md +MD043: false +# MD044/proper-names: Proper names should have the correct capitalization: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md044.md +MD044: + # List of proper names + names: [] + # Include code blocks + code_blocks: true + # Include HTML elements + html_elements: true +# MD045/no-alt-text: Images should have alternate text (alt text): +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md045.md +MD045: true +# MD046/code-block-style: Code block style: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md046.md +MD046: + # Block style + style: "consistent" +# MD047/single-trailing-newline: Files should end with a +# single newline character: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md047.md +MD047: true +# MD048/code-fence-style: Code fence style: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md048.md +MD048: + # Code fence style + style: "consistent" +# MD049/emphasis-style: Emphasis style: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md049.md +MD049: + # Emphasis style + style: "consistent" +# MD050/strong-style: Strong style: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md050.md +MD050: + # Strong style + style: "consistent" +# MD051/link-fragments: Link fragments should be valid: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md051.md +MD051: true +# MD052/reference-links-images: Reference links and images should use +# a label that is defined: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md052.md +MD052: + # Include shortcut syntax + shortcut_syntax: false +# MD053/link-image-reference-definitions: Link and image reference +# definitions should be needed: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md053.md +MD053: + # Ignored definitions + ignored_definitions: + - "//" +# MD054/link-image-style: Link and image style: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md054.md +MD054: + # Allow autolinks + autolink: true + # Allow inline links and images + inline: true + # Allow full reference links and images + full: true + # Allow collapsed reference links and images + collapsed: true + # Allow shortcut reference links and images + shortcut: true + # Allow URLs as inline links + url_inline: true +# MD055/table-pipe-style: Table pipe style: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md055.md +MD055: + # Table pipe style + style: "consistent" +# MD056/table-column-count: Table column count: +# https://github.com/DavidAnson/markdownlint/blob/v0.33.0/doc/md056.md +MD056: true diff --git a/hooks/markdown-lint/.lefthook.yaml b/hooks/markdown-lint/.lefthook.yaml new file mode 100644 index 0000000..1960dab --- /dev/null +++ b/hooks/markdown-lint/.lefthook.yaml @@ -0,0 +1,13 @@ +# SPDX-FileCopyrightText: Copyright Boozt Fashion, AB +# SPDX-License-Identifier: MIT +--- +pre-commit: + commands: + # for a full documentation of the markdownlint-cli see + # https://github.com/DavidAnson/markdownlint + markdown-lint: + glob: "*.md" + run: | + docker run -v $(pwd):/workdir \ + ghcr.io/igorshubovych/markdownlint-cli:latest \ + --dot {staged_files} diff --git a/hooks/markdown-lint/README.md b/hooks/markdown-lint/README.md new file mode 100644 index 0000000..ae48435 --- /dev/null +++ b/hooks/markdown-lint/README.md @@ -0,0 +1,18 @@ +# markdown-lint hook + +markdownlint is a static analysis tool based in node.js with a library of rules +to enforce standards and consistency for Markdown files. + +For a full configuration and documentation [follow this link](https://github.com/DavidAnson/markdownlint). + +## How to Use It + +```yaml +# .lefthook.yaml +remotes: + - git_url: git@github.com:boozt-platform/lefthook + ref: [tag] + configs: + # lint the markdown (.md) files + - hooks/markdown-lint/.lefthook.yaml +``` From 1b85d54a9c888774b698006c48b140bc50e0cde6 Mon Sep 17 00:00:00 2001 From: Donatas Navidonskis Date: Thu, 21 Mar 2024 16:48:42 +0200 Subject: [PATCH 02/11] feat: add yamllint hook --- hooks/yamllint/.lefthook.yaml | 13 +++++++++++++ hooks/yamllint/README.md | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 hooks/yamllint/.lefthook.yaml create mode 100644 hooks/yamllint/README.md diff --git a/hooks/yamllint/.lefthook.yaml b/hooks/yamllint/.lefthook.yaml new file mode 100644 index 0000000..1636441 --- /dev/null +++ b/hooks/yamllint/.lefthook.yaml @@ -0,0 +1,13 @@ +# SPDX-FileCopyrightText: Copyright Boozt Fashion, AB +# SPDX-License-Identifier: MIT +--- +pre-commit: + commands: + # for a full documentation of the yamllint see + # https://yamllint.readthedocs.io/ + yamllint: + glob: "*.{yml,yaml}" + run: | + docker run -v $(pwd):/code \ + pipelinecomponents/yamllint:0.31.0 \ + /app/bin/yamllint {staged_files} diff --git a/hooks/yamllint/README.md b/hooks/yamllint/README.md new file mode 100644 index 0000000..2906e9c --- /dev/null +++ b/hooks/yamllint/README.md @@ -0,0 +1,18 @@ +# yamllint hook + +A linter for YAML files. It checks the syntax validity, key repetition, +cosmetic issues as such lines length, trailing spaces, indentations and etc. + +For a full configuration and documentation [follow this link](https://yamllint.readthedocs.io/en/stable/). + +## How to Use It + +```yaml +# .lefthook.yaml +remotes: + - git_url: git@github.com:boozt-platform/lefthook + ref: [tag] + configs: + # A linter for YAML files. + - hooks/yamllint/.lefthook.yaml +``` From 110b2b0e017e8067675fe24fed4bdfb6ca6311e3 Mon Sep 17 00:00:00 2001 From: Donatas Navidonskis Date: Thu, 21 Mar 2024 16:54:09 +0200 Subject: [PATCH 03/11] feat: add commitlint hook (checks git commits based by CC) --- hooks/commitlint/.lefthook.yaml | 2 +- hooks/commitlint/README.md | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hooks/commitlint/.lefthook.yaml b/hooks/commitlint/.lefthook.yaml index 287fdc9..5525b77 100644 --- a/hooks/commitlint/.lefthook.yaml +++ b/hooks/commitlint/.lefthook.yaml @@ -1,6 +1,6 @@ # SPDX-FileCopyrightText: Copyright Boozt Fashion, AB # SPDX-License-Identifier: MIT - +--- commit-msg: parallel: true scripts: diff --git a/hooks/commitlint/README.md b/hooks/commitlint/README.md index 19f2624..989f945 100644 --- a/hooks/commitlint/README.md +++ b/hooks/commitlint/README.md @@ -1,6 +1,8 @@ # commitlint hook -This hook checks if the commit message follows the conventional commits framework. For a full information take a look at CONTRIBUTING.md guideline (Updating Code section). +This hook checks if the commit message follows the conventional commits +framework. For a full information take a look at CONTRIBUTING.md guideline +(Updating Code section). ## How to Use It @@ -16,7 +18,8 @@ remotes: ## Configuration -The script supports two environment variables that can be reconfigured. You can define the environment variables as follows: +The script supports two environment variables that can be reconfigured. You +can define the environment variables as follows: ```shell # default values for environment variables @@ -25,7 +28,8 @@ export MAX_COMMIT_MESSAGE_LENGTH=80 export VALID_COMMIT_PREFIXES="build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test" ``` -Alternatively, you can create a `.commitlint` environment file in the project root, and the script will automatically source it: +Alternatively, you can create a `.commitlint` environment file in the project +root, and the script will automatically source it: ```bash # .commitlint From 50f61afc5682f0ad37aaf42eaebfe4c5b3cfa193 Mon Sep 17 00:00:00 2001 From: Donatas Navidonskis Date: Thu, 21 Mar 2024 16:55:32 +0200 Subject: [PATCH 04/11] feat: add license-checker hook (to check license headers across the files) --- .lefthook/pre-commit/license-checker.sh | 21 +++++++++-------- .license-checker => .license-checker.txt | 3 --- hooks/license-checker/.lefthook.yaml | 2 +- hooks/license-checker/README.md | 29 +++++++++--------------- 4 files changed, 24 insertions(+), 31 deletions(-) rename .license-checker => .license-checker.txt (71%) diff --git a/.lefthook/pre-commit/license-checker.sh b/.lefthook/pre-commit/license-checker.sh index f972014..dcee5c6 100755 --- a/.lefthook/pre-commit/license-checker.sh +++ b/.lefthook/pre-commit/license-checker.sh @@ -4,19 +4,22 @@ # SPDX-License-Identifier: MIT # Script is a pre-commit hook to check if the staged files -# has the license header from the file license-header.txt (we only check if it's contains). +# has the license header from the file license-header.txt or the +# environment variable called LICENSE_HEADER (we only check if +# it's contains). set -eo pipefail -# include .license-checker file if exists in the root directory -if [ -f .license-checker ]; then - # shellcheck source=/dev/null - source .license-checker -fi - -EXCLUDE_FILES_EXT=${EXCLUDE_FILES_EXT:-"LICENSE|\\.md|\\.gitignore|\\.license-checker|CODEOWNERS|\\.gitattributes|\\.editorconfig|\\.json|\\.lock|\\.toml"} +LICENSE_HEADER=${LICENSE_HEADER:-""} +EXCLUDE_FILES_EXT=${EXCLUDE_FILES_EXT:-"LICENSE|\\.md|\\.gitignore|\\.license-checker.txt|CODEOWNERS|\\.gitattributes|\\.editorconfig|\\.json|\\.lock|\\.toml"} STAGED_FILES=$(git diff --name-only --diff-filter=d --staged) +# read .license-checker.txt file if exists in the root directory +if [[ -f .license-checker.txt && -z "$LICENSE_HEADER" ]]; then + # read the file and set the LICENSE_HEADER variable + LICENSE_HEADER=$(cat .license-checker.txt) +fi + # error message function printing in red color # usage: error "message" error() { @@ -27,7 +30,7 @@ error() { # if the LICENSE_HEADER is empty, then exit if [ -z "$LICENSE_HEADER" ]; then error "The LICENSE_HEADER environment variable is empty." - error "Either create .license-checker file in the root directory or set the LICENSE_HEADER environment variable." + error "Either create .license-checker.txt file in the root directory or set the LICENSE_HEADER environment variable." exit 1 fi diff --git a/.license-checker b/.license-checker.txt similarity index 71% rename from .license-checker rename to .license-checker.txt index 57691ef..22a7f14 100644 --- a/.license-checker +++ b/.license-checker.txt @@ -1,5 +1,2 @@ -LICENSE_HEADER=$(cat < Date: Thu, 21 Mar 2024 18:33:43 +0200 Subject: [PATCH 05/11] feat: add jsonlint hook (this hook validates json files) --- hooks/jsonlint/.lefthook.yaml | 13 +++++++++++++ hooks/jsonlint/README.md | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 hooks/jsonlint/.lefthook.yaml create mode 100644 hooks/jsonlint/README.md diff --git a/hooks/jsonlint/.lefthook.yaml b/hooks/jsonlint/.lefthook.yaml new file mode 100644 index 0000000..1b158b9 --- /dev/null +++ b/hooks/jsonlint/.lefthook.yaml @@ -0,0 +1,13 @@ +# SPDX-FileCopyrightText: Copyright Boozt Fashion, AB +# SPDX-License-Identifier: MIT +--- +pre-commit: + parallel: true + commands: + jsonlint: + glob: "*.json" + stage_fixed: true + run: | + docker run --rm -v $(pwd):/code \ + pipelinecomponents/jsonlint:0.19.1 \ + jsonlint {staged_files} -s -i diff --git a/hooks/jsonlint/README.md b/hooks/jsonlint/README.md new file mode 100644 index 0000000..eda4d42 --- /dev/null +++ b/hooks/jsonlint/README.md @@ -0,0 +1,22 @@ +# jsonlint hook + +Validation tool for JSON files. [https://github.com/zaach/jsonlint](https://github.com/zaach/jsonlint) + +## Configuration + +Currently, we are using this tool to validate our JSON files and run a git +patch to fix it due to formatting issues. So by default, we use it to sort +the keys and automatically update the actual files (and lefthook will execute +the `git add`). + +## How to Use It + +```yaml +# .lefthook.yaml +remotes: + - git_url: git@github.com:boozt-platform/lefthook + ref: [tag] + configs: + # validate the JSON files + - hooks/jsonlint/.lefthook.yaml +``` From c7badf6e35d3d910daf278a1b6801bd71c8f9bf6 Mon Sep 17 00:00:00 2001 From: Donatas Navidonskis Date: Thu, 21 Mar 2024 18:39:50 +0200 Subject: [PATCH 06/11] feat: add hadolint hook (to lint Dockerfiles) --- hooks/hadolint/.lefthook.yaml | 6 ++++-- hooks/hadolint/README.md | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 hooks/hadolint/README.md diff --git a/hooks/hadolint/.lefthook.yaml b/hooks/hadolint/.lefthook.yaml index 38fc40b..6b8988e 100644 --- a/hooks/hadolint/.lefthook.yaml +++ b/hooks/hadolint/.lefthook.yaml @@ -1,10 +1,12 @@ # SPDX-FileCopyrightText: Copyright Boozt Fashion, AB # SPDX-License-Identifier: MIT - +--- pre-commit: parallel: true commands: hadolint: glob: "Dockerfile*" run: | - docker run --rm -it -v $(pwd):/app -w /app ghcr.io/hadolint/hadolint hadolint {staged_files} + docker run --rm -it -v $(pwd):/app -w /app \ + ghcr.io/hadolint/hadolint \ + hadolint {staged_files} diff --git a/hooks/hadolint/README.md b/hooks/hadolint/README.md new file mode 100644 index 0000000..c1867b6 --- /dev/null +++ b/hooks/hadolint/README.md @@ -0,0 +1,16 @@ +# hadolint hook + +A Dockerfile linter that helps to build Docker images by following the best +practices. [https://github.com/hadolint/hadolint](https://github.com/hadolint/hadolint) + +## How to Use It + +```yaml +# .lefthook.yaml +remotes: + - git_url: git@github.com:boozt-platform/lefthook + ref: [tag] + configs: + # lint Dockerfiles + - hooks/hadolint/.lefthook.yaml +``` From 24a7017e1e59c57c4e3f7cc029f694bfa52c6f5e Mon Sep 17 00:00:00 2001 From: Donatas Navidonskis Date: Thu, 21 Mar 2024 18:55:40 +0200 Subject: [PATCH 07/11] style: adjust yaml & markdown files due to the linting --- .github/workflows/release.yml | 3 +- .goreleaser.yaml | 11 +-- .lefthook.yaml | 8 +- .yamllint.yaml | 12 +++ README.md | 50 ++++++++++--- docs/CODE_OF_CONDUCT.md | 23 +++--- docs/CONTRIBUTING.md | 129 +++++++++++++++++++++++--------- docs/SECURITY.md | 14 +++- hooks/shellcheck/.lefthook.yaml | 7 +- hooks/shellcheck/README.md | 15 ++++ 10 files changed, 201 insertions(+), 71 deletions(-) create mode 100644 .yamllint.yaml create mode 100644 hooks/shellcheck/README.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9e789c3..d63cc20 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,8 +1,9 @@ # SPDX-FileCopyrightText: Copyright Boozt Fashion, AB # SPDX-License-Identifier: MIT +--- name: Release -on: +"on": push: branches: - 'main' diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 1986bbe..66b31bd 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -3,12 +3,13 @@ # For more information about the configuration file, see: # https://goreleaser.com/customization/build/ - +--- builds: - # By default we don't let to release packages. Our consideration is to use SemVer - # based by conventional commits to release new versions of the project once it's - # merged to the main branch. If this is a Go project, you can remove this section - # and use the default configuration to release the packages within the new version. + # By default we don't let to release packages. Our consideration is to use + # SemVer based by conventional commits to release new versions of the project + # once it's merged to the main branch. If this is a Go project, you can + # remove this section and use the default configuration to release the + # packages within the new version. - skip: true checksum: diff --git a/.lefthook.yaml b/.lefthook.yaml index fad3a8f..b6ec6ad 100644 --- a/.lefthook.yaml +++ b/.lefthook.yaml @@ -1,12 +1,14 @@ # SPDX-FileCopyrightText: Copyright Boozt Fashion, AB # SPDX-License-Identifier: MIT - +--- extends: # lint commit messages based by the conventional commits - hooks/commitlint/.lefthook.yaml - # lint Dockerfiles - - hooks/hadolint/.lefthook.yaml # lint shell scripts - hooks/shellcheck/.lefthook.yaml # check if the license headers are present in the files - hooks/license-checker/.lefthook.yaml + # lint the markdown (.md) files + - hooks/markdown-lint/.lefthook.yaml + # lint the yaml (.yml, .yaml) files + - hooks/yamllint/.lefthook.yaml diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 0000000..414658e --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,12 @@ +# SPDX-FileCopyrightText: Copyright Boozt Fashion, AB +# SPDX-License-Identifier: MIT +--- +# For more information about the configuration file, see: +# https://yamllint.readthedocs.io/en/stable/configuration.html +extends: default + +yaml-files: + - '*.yaml' + - '*.yml' + - '.yamllint' + - '.yamllint.yaml' diff --git a/README.md b/README.md index 3e6bcd2..a33e1c3 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,15 @@ + [][homepage] [![GitHub Tag (latest SemVer)](https://img.shields.io/github/v/tag/boozt-platform/lefthook.svg?label=latest&sort=semver)][releases] [![license](https://img.shields.io/badge/license-mit-brightgreen.svg)][license] + # lefthook -Various organizational hooks based on the [lefthook](https://github.com/evilmartians/lefthook) for development and continuous integration. Hooks enforce consistent practices across all commits and deployments. +Various organizational hooks based on the [lefthook](https://github.com/evilmartians/lefthook) +for development and continuous integration. Hooks enforce consistent practices +across all commits and deployments. ## Table of Contents @@ -18,7 +22,12 @@ Various organizational hooks based on the [lefthook](https://github.com/evilmart ## How to Use It +Create a new file `.lefthook.yaml` in your project's root folder and use the +example content below: + ```yaml +# .lefthook.yaml +--- remotes: - git_url: git@github.com:boozt-platform/lefthook ref: v1.2.0 @@ -33,26 +42,40 @@ remotes: - hooks/license-checker/.lefthook.yaml ``` +Run `lefthook install` (follow the [installation guide](https://github.com/evilmartians/lefthook/blob/master/docs/install.md) +if the lefthook command is not present on the system). + ## Available Hooks - - [commitlint](./hooks/commitlint/) (**commit-msg**) - Lint commit messages based by the conventional commits - - [hadolint](./hooks/hadolint/) (**pre-commit**) - A smarter Dockerfile linter - - [shellcheck](./hooks/shellcheck/) (**pre-commit**) - a static analysis tool for shell scripts - - [license-checker](./hooks/license-checker/) (**pre-commit**) - Checks if the license headers are present in the Git staged files with possibility to exclude certain files or file extensions using Regular Expression pattern. +- [commitlint](./hooks/commitlint/) (**commit-msg**) - Lint commit messages +based by the conventional commits +- [hadolint](./hooks/hadolint/) (**pre-commit**) - A smarter Dockerfile linter +- [shellcheck](./hooks/shellcheck/) (**pre-commit**) - a static analysis tool +for shell scripts +- [license-checker](./hooks/license-checker/) (**pre-commit**) - Checks if the +license headers are present in the Git staged files with possibility to exclude +certain files or file extensions using Regular Expression pattern. ## About Boozt -Boozt is a leading and fast-growing Nordic technology company selling fashion and lifestyle online mainly through its multi-brand webstore [Boozt.com][boozt] and [Booztlet.com][booztlet]. +Boozt is a leading and fast-growing Nordic technology company selling fashion +and lifestyle online mainly through its multi-brand webstore [Boozt.com][boozt] +and [Booztlet.com][booztlet]. -The company is focused on using cutting-edge, in-house developed technology to curate the best possible customer experience. +The company is focused on using cutting-edge, in-house developed technology to +curate the best possible customer experience. -With offices in Sweden, Denmark, Lithuania and Poland, we pride ourselves in having a diverse team, consisting of 1100+ employees and 38 nationalities. +With offices in Sweden, Denmark, Lithuania and Poland, we pride ourselves in +having a diverse team, consisting of 1100+ employees and 38 nationalities. -See our [Medium][blog] blog page for technology-focused articles. Would you like to make your mark by working with us at Boozt? Take a look at our [latest hiring opportunities][careers]. +See our [Medium][blog] blog page for technology-focused articles. Would you +like to make your mark by working with us at Boozt? Take a look at our +[latest hiring opportunities][careers]. ## Reporting Issues -Please provide a clear and concise description of the problem or the feature you're missing along with any relevant context or screenshots. +Please provide a clear and concise description of the problem or the feature +you're missing along with any relevant context or screenshots. Check existing issues before reporting to avoid duplicates. @@ -60,13 +83,16 @@ Please follow the [Issue Reporting Guidelines][issues] before opening a new issu ## Contributing -Contributions are highly valued and very welcome! For the process of reviewing changes, we use [Pull Requests][pull-request]. For a detailed information please follow the [Contribution Guidelines][contributing] +Contributions are highly valued and very welcome! For the process of reviewing +changes, we use [Pull Requests][pull-request]. For a detailed information +please follow the [Contribution Guidelines][contributing] ## License [![license](https://img.shields.io/badge/license-mit-brightgreen.svg)][license] -This project is licensed under the MIT. Please see [LICENSE][license] for full details. +This project is licensed under the MIT. Please see [LICENSE][license] for +full details. [homepage]: https://github.com/boozt-platform/lefthook [releases]: https://github.com/boozt-platform/lefthook/releases diff --git a/docs/CODE_OF_CONDUCT.md b/docs/CODE_OF_CONDUCT.md index efc2f98..48df890 100644 --- a/docs/CODE_OF_CONDUCT.md +++ b/docs/CODE_OF_CONDUCT.md @@ -5,9 +5,9 @@ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, gender identity and expression, level of experience, -nationality, personal appearance, race, religion, or sexual identity and -orientation. +size, disability, ethnicity, gender identity and expression, level of +experience, nationality, personal appearance, race, religion, or sexual +identity and orientation. ## Our Standards @@ -55,11 +55,14 @@ further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting opensource@boozt.com, which is a shared team inbox. If the incident involves someone who receives that shared inbox, you can contact an individual maintainer (@doniz) at ```donnav``` + ```@boozt.com```. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. +reported by contacting [opensource@boozt.com](opensource@boozt.com), which is +a shared team inbox. If the incident involves someone who receives that shared +inbox, you can contact an individual maintainer (@doniz) at +```donnav``` + ```@boozt.com```. All complaints will be reviewed and +investigated and will result in a response that is deemed necessary and +appropriate to the circumstances. The project team is obligated to maintain +confidentiality with regard to the reporter of an incident. Further details of +specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other @@ -67,8 +70,8 @@ members of the project's leadership. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at [https://contributor-covenant.org/version/1/4][version] +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 1.4, available at [https://contributor-covenant.org/version/1/4][version] [homepage]: https://contributor-covenant.org [version]: https://contributor-covenant.org/version/1/4/ diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index c56cc5f..cd10c6e 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -1,6 +1,9 @@ # Contributing Guidelines -Thank you for considering contributing to our project! Your contributions are highly valued and help improve the project for everyone. To make the contribution process as smooth as possible, please follow the guidelines outlined below: +Thank you for considering contributing to our project! Your contributions are +highly valued and help improve the project for everyone. To make the +contribution process as smooth as possible, please follow the guidelines +outlined below: 1. [Opening a GitHub Issue](#opening-a-github-issue) 1. [Forking the Repository](#forking-the-repository) @@ -14,41 +17,60 @@ Thank you for considering contributing to our project! Your contributions are hi ## Opening a GitHub Issue -If you encounter a bug, have a feature request (please note that we want to avoid [feature creep][feature-creep] and we cannot guarantee your request will be accepted), or wish to suggest an improvement, please open a GitHub issue and ask the [CODEOWNERS][codeowners] and community prior starting a contribution. Provide a clear and concise description of the problem or suggestion, including any relevant details or context. This will help us understand and address the issue efficiently. +If you encounter a bug, have a feature request (please note that we want to +avoid [feature creep][feature-creep] and we cannot guarantee your request will +be accepted), or wish to suggest an improvement, please open a GitHub issue and +ask the [CODEOWNERS][codeowners] and community prior starting a contribution. + +Provide a clear and concise description of the problem or suggestion, including +any relevant details or context. This will help us understand and address the +issue efficiently. ## Forking the Repository -To contribute to the project, fork the repository on GitHub and create a new branch as described in the [GitHub Flow][github-flow]. This will create a copy of the project in your GitHub account where you can make changes without affecting the original repository. +To contribute to the project, fork the repository on GitHub and create a new +branch as described in the [GitHub Flow][github-flow]. This will create a copy +of the project in your GitHub account where you can make changes without +affecting the original repository. ## Updating Documentation -Documentation is crucial for understanding and using the project effectively. If you make changes to the code, please ensure that any relevant documentation is updated accordingly. This includes README files, code comments, and any other documentation files. +Documentation is crucial for understanding and using the project effectively. +If you make changes to the code, please ensure that any relevant documentation +is updated accordingly. This includes README files, code comments, and any +other documentation files. Please follow [Readme Driven Development][rdd]. ## Updating Tests -Maintaining a robust test suite is essential for ensuring the reliability and stability of the project. +Maintaining a robust test suite is essential for ensuring the reliability and +stability of the project. -If you make changes to the code, please update any relevant tests to reflect those changes. This helps -prevent regressions and ensures that the project continues to function as expected (see [TDD][tdd]). +If you make changes to the code, please update any relevant tests to reflect +those changes. This helps prevent regressions and ensures that the project +continues to function as expected (see [TDD][tdd]). -The test folder (if provided) in repository will have documentation guideline how to run the tests. +The test folder (if provided) in repository will have documentation guideline +how to run the tests. ## Updating Code -Ensure to make your changes to the codebase and [commit][commit-and-review] messages early and often, following the standards outlined in the project's README.md or CONTRIBUTING.md file. Use [conventional commits][conventional-commits] for commit messages, adhering to one of the following patterns: +Ensure to make your changes to the codebase and [commit][commit-and-review] +messages early and often, following the standards outlined in the project's +README.md or CONTRIBUTING.md file. Use [conventional commits][conventional-commits] +for commit messages, adhering to one of the following patterns: - - `[optional scope]: [optional body] [optional footer(s)]` - - `[optional scope]: ` +- `[optional scope]: [optional body] [optional footer(s)]` +- `[optional scope]: ` Refer to the table below for the possible commit types: | Type | Description| | ---- | ---- | -| build | Changes affecting the build system or dependencies (example scopes: gulp, npm) +| build | Changes affecting the build system or dependencies | | chore | Maintenance tasks such as upgrades or cleanup | -| ci | Changes to CI configuration files or scripts (example scopes: Travis, Circle, GitLab, GitHub) | +| ci | Changes to CI configuration files or scripts | | docs | Documentation-only changes | | feat | New features | | fix | Bug fixes | @@ -58,15 +80,20 @@ Refer to the table below for the possible commit types: | style | Changes to code style or formatting | | test | Adding or correcting tests | -Exclamation mark (!) is optional and can be used to indicate breaking changes. Use it before colon (:). i.e. `feat(auth)!: add login feature`. +Exclamation mark (!) is optional and can be used to indicate breaking changes. +Use it before colon (:). i.e. `feat(auth)!: add login feature`. For comprehensive documentation, [click here][conventional-commits]. -If a backwards incompatible change is unavoidable, ensure to mention it in your pull request and provide justification for the necessity of the change. +If a backwards incompatible change is unavoidable, ensure to mention it in +your pull request and provide justification for the necessity of the change. ## Creating a Pull Request -Once you've made your changes and are ready to contribute them back to the project, [create a pull request (PR)][pr]. Provide a clear and descriptive title for your PR, along with a summary of the changes made, any related GitHub issues and any notes on backwards incompatibility. +Once you've made your changes and are ready to contribute them back to the +project, [create a pull request (PR)][pr]. Provide a clear and descriptive +title for your PR, along with a summary of the changes made, any related GitHub +issues and any notes on backwards incompatibility. Be sure to follow the pull request template, if one is provided. @@ -74,39 +101,71 @@ Be sure to follow the pull request template, if one is provided. To create a new hook, follow these steps: -1. Run `make add_hook [options]` (i.e. `make add_hook NAME=jslint`). Below are the available options you can pass: +1. Create a new folder in `hooks/[new-hook-name]/`. + +1. Create a file inside folder `hooks/[new-hook-name]/` called `.lefthook.yaml` +within license header as the following code below: + + ```yaml + # SPDX-FileCopyrightText: Copyright Boozt Fashion, AB + # SPDX-License-Identifier: MIT + --- + pre-commit: + parallel: true + commands: + hadolint: + glob: "Dockerfile*" + run: | + docker run --rm -it -v $(pwd):/app -w /app \ + ghcr.io/hadolint/hadolint \ + hadolint {staged_files} + ``` + +1. Create a file inside folder `hooks/[new-hook-name]/` called `README.md` with +the following content structure: + + ```markdown + # [new-hook-name] hook -Name|Description|Required|Default| ----|---|---|---| -NAME|The name of the hook|Yes|| -DOCKERFILE|Boolean option to create an empty Dockerfile file in the hook folder with the license included|No|False| + ## How to Use It -2. Add necessary files to your new hook. -3. Adjust the `.lefthook.yaml` file to execute your new hook. You can use either a script or Docker. It's recommended to use Docker unless it's a simple bash script or specific to a development niche (such as frontend - JavaScript, CSS, or backend - Go, Python). -4. Update the README.md documentation to include your new hook in the list of available hooks and provide a brief description. -5. If you requested to create a Dockerfile, the script will output the `yaml` options to add to the `.goreleaser.yaml` file. These options facilitate the creation of a Docker image for various OS architectures. -6. To run tests against your Docker image, you can use the following commands: + - - `make NAME=` or `make build NAME=`: This command builds the image and runs the security check. For example: `make NAME=jslint`. - - Alternatively, you can execute these commands individually: - - `make container_build NAME=`: Builds the Docker image. - - `make container_scan NAME=`: Performs a security scan on the Docker image. - - `make container_run NAME=`: Runs the Docker image. + ## Configuration + + + + ``` + + > [!NOTE] + > For hooks that have scripts, consider [following the guidelines](https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md#scripts) + to place them in the correct `.lefthook/` directory. + +1. Update the main project's `README.md` file to add this hook in +"How to Use It" and "Available Hooks" sections. ## License Information -To ensure proper attribution and compliance with licensing terms, we require that all source code files include a [short-form SPDX ID][spdx-license-info] license comment block. This block should be added at the top of each source code file. +To ensure proper attribution and compliance with licensing terms, we require +that all source code files include a [short-form SPDX ID][spdx-license-info] +license comment block. This block should be added at the top of each +source code file. -``` +```text SPDX-FileCopyrightText: Copyright Boozt Fashion, AB SPDX-License-Identifier: MIT ``` -For more information of the SPDX file tags please follow https://spdx.github.io/spdx-spec/v2.3/file-tags/. +For more information of the SPDX file tags please follow [https://spdx.github.io/spdx-spec/v2.3/file-tags/](https://spdx.github.io/spdx-spec/v2.3/file-tags/). ## Merging and Releasing -After your pull request has been reviewed and approved by the project maintainers ([CODEOWNERS][codeowners]), it will be merged into the main branch. Once merged, the changes will be included in the next release of the project and the [Semantic Versioning (SemVer)][semver] principles will be applied. You'll be asked for squash your commits if it's not following the standards of the [conventional commits][conventional-commits]. +After your pull request has been reviewed and approved by the project +maintainers ([CODEOWNERS][codeowners]), it will be merged into the main branch. +Once merged, the changes will be included in the next release of the project +and the [Semantic Versioning (SemVer)][semver] principles will be applied. +You'll be asked for squash your commits if it's not following the standards of +the [conventional commits][conventional-commits]. **Thank you for your contribution!** diff --git a/docs/SECURITY.md b/docs/SECURITY.md index 48baca8..d8ccbfc 100644 --- a/docs/SECURITY.md +++ b/docs/SECURITY.md @@ -1,7 +1,15 @@ # Reporting Security Vulnerabilities -If you discover any security vulnerabilities in our project, we appreciate your responsible disclosure. To report a security issue, please avoid creating public GitHub issues. Instead, email us directly at security@boozt.com. We kindly request that you refrain from disclosing the vulnerability publicly until it has been addressed by our team. +If you discover any security vulnerabilities in our project, we appreciate your +responsible disclosure. To report a security issue, please avoid creating +public GitHub issues. Instead, email us directly at [security@boozt.com](security@boozt.com). +We kindly request that you refrain from disclosing the vulnerability publicly +until it has been addressed by our team. -We prioritize vulnerabilities present only in the latest version of our product. This helps us focus on addressing the most relevant security concerns and minimizing noise. +We prioritize vulnerabilities present only in the latest version of our +product. This helps us focus on addressing the most relevant security concerns +and minimizing noise. -We take security seriously and are committed to promptly addressing and resolving any reported vulnerabilities. Thank you for helping us maintain the security and integrity of our project. +We take security seriously and are committed to promptly addressing and +resolving any reported vulnerabilities. Thank you for helping us maintain the +security and integrity of our project. diff --git a/hooks/shellcheck/.lefthook.yaml b/hooks/shellcheck/.lefthook.yaml index 88b5574..0cf153a 100644 --- a/hooks/shellcheck/.lefthook.yaml +++ b/hooks/shellcheck/.lefthook.yaml @@ -1,10 +1,13 @@ # SPDX-FileCopyrightText: Copyright Boozt Fashion, AB # SPDX-License-Identifier: MIT - +--- pre-commit: parallel: true commands: shellcheck: glob: "*.sh" + # https://github.com/koalaman/shellcheck/wiki run: | - docker run --rm -v $(pwd):/mnt koalaman/shellcheck:stable {staged_files} + docker run --rm -v $(pwd):/mnt \ + koalaman/shellcheck:stable \ + {staged_files} diff --git a/hooks/shellcheck/README.md b/hooks/shellcheck/README.md new file mode 100644 index 0000000..1a17415 --- /dev/null +++ b/hooks/shellcheck/README.md @@ -0,0 +1,15 @@ +# shellcheck hook + +A shell script static analysis tool. [https://github.com/koalaman/shellcheck](https://github.com/koalaman/shellcheck) + +## How to Use It + +```yaml +# .lefthook.yaml +remotes: + - git_url: git@github.com:boozt-platform/lefthook + ref: [tag] + configs: + # lint shell scripts + - hooks/shellcheck/.lefthook.yaml +``` From 0c1c52d4701e5f15f97828e387986cb48c635236 Mon Sep 17 00:00:00 2001 From: Donatas Navidonskis Date: Thu, 21 Mar 2024 18:57:23 +0200 Subject: [PATCH 08/11] chore: delete deprecated files, we will use separate repo --- Makefile | 39 ------------------- add-hook.sh | 105 ---------------------------------------------------- 2 files changed, 144 deletions(-) delete mode 100644 Makefile delete mode 100755 add-hook.sh diff --git a/Makefile b/Makefile deleted file mode 100644 index f90a541..0000000 --- a/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -# SPDX-FileCopyrightText: Copyright Boozt Fashion, AB -# SPDX-License-Identifier: MIT - -SHELL := /usr/bin/env bash -.DEFAULT_GOAL := build -NAME ?= "" - -.PHONY: build -build: container_build container_scanning - -.PHONY: container_build -container_build: - @docker build \ - -t ${NAME} \ - --file "${PWD}/hooks/${NAME}/Dockerfile" \ - . - -.PHONY: container_run -run: container_run -container_run: - @docker run --rm -it \ - -v ${PWD}:/app \ - ${NAME} \ - bash - -.PHONY: container_scanning -scan: container_scanning -container_scanning: - @docker run --rm \ - -v /var/run/docker.sock:/var/run/docker.sock \ - -v ${HOME}/.trivy:/root/.cache/ \ - aquasec/trivy:0.38.3 \ - image --no-progress --exit-code 1 --severity CRITICAL ${NAME} - -.PHONY: add_hook -add_hook: - @read -r -p "Enter the name of the hook: " HOOK_NAME; \ - read -r -p "Do you want to create a Dockerfile for the hook? [y/N] " CREATE_DOCKERFILE; \ - bash -c "NAME=$$HOOK_NAME CREATE_DOCKERFILE=$$CREATE_DOCKERFILE $(PWD)/add-hook.sh" diff --git a/add-hook.sh b/add-hook.sh deleted file mode 100755 index 3de0a1a..0000000 --- a/add-hook.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/usr/bin/env bash - -# SPDX-FileCopyrightText: Copyright Boozt Fashion, AB -# SPDX-License-Identifier: MIT - -export NAME="${NAME:-""}" -export CREATE_DOCKERFILE="${CREATE_DOCKERFILE:-N}" - -SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" -HOOKS_DIR="hooks" -HOOKS_PATH="${SCRIPT_DIR}/${HOOKS_DIR}" - -# error message function printing in red color -# usage: error "message" -error() { - local message=${1:-""} - echo -e "\033[0;31m${message}\033[0m" -} - -# create hooks dir if not exists -if [ ! -d "${HOOKS_PATH}" ]; then - mkdir -p "${HOOKS_PATH}" -fi - -# check if the NAME environment variable is not empty -if [ -z "$NAME" ]; then - error "The NAME environment variable is empty" - exit 1 -fi - -# check if the given module name not yet exists to be able to create a new module -if [ -d "${HOOKS_PATH}/${NAME}" ]; then - error "The module ${NAME} already exists" - exit 1 -fi - -# create a new module directory -mkdir -p "${HOOKS_PATH}/${NAME}" - -# create .lefthook.yaml file with the SPDX license in it -cat > "${HOOKS_PATH}/${NAME}/.lefthook.yaml" < "${HOOKS_PATH}/${NAME}/README.md" < "${HOOKS_PATH}/${NAME}/Dockerfile" < Date: Thu, 21 Mar 2024 19:17:19 +0200 Subject: [PATCH 09/11] docs: update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 44 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 4 +++ .github/ISSUE_TEMPLATE/feature_request.md | 20 +++++++++++ .github/issue_template.md | 28 --------------- 4 files changed, 68 insertions(+), 28 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md delete mode 100644 .github/issue_template.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..7430626 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,44 @@ +--- +name: Report a bug +about: Found something broken? Let us know! If it's not yet reproducible, +please `Ask a question` instead. +labels: 'bug' +--- + + +### Summary + + + +### Lefthook version + + + +### Steps to reproduce + + + +### Expected results + + + +### Actual results + + + +### Possible Solution + + + +### Logs / Screenshots + + + +```bash +LEFTHOOK_VERBOSE=true git ... +``` + + diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..7f07d38 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,4 @@ +# SPDX-FileCopyrightText: Copyright Boozt Fashion, AB +# SPDX-License-Identifier: MIT +--- +blank_issues_enabled: false diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..3ada22e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Want to add a new hook or improve it? Create a feature request! +labels: 'feature request' +--- + + +### Summary + + + +### Value + + + +### Behavior and configuration changes + + + + diff --git a/.github/issue_template.md b/.github/issue_template.md deleted file mode 100644 index 70f0361..0000000 --- a/.github/issue_template.md +++ /dev/null @@ -1,28 +0,0 @@ - - - -Thank you for taking the time to submit an issue! Your contribution is valuable to us. Before you proceed, please take a moment to go through the checklist below: - -### Checklist - -- [ ] Have you attempted to debug or fix the issue yourself? Bug fixes and documentation improvements are always welcome. -- [ ] Have you checked if a similar issue has already been created? -- [ ] Do you have an idea for a new feature? If so, please label your issue with "enhancement". - - -If none of the above apply, you may proceed to create a new bug report. Please provide the following information to help us address the issue effectively: - -### Bug Report Details - -- **Description**: Describe the issue in detail. -- **Steps to Reproduce**: Provide a clear and concise description of the steps to reproduce the issue. -- **Expected Behavior**: Describe what you expected to happen. -- **Actual Behavior**: Describe what actually happened. -- **Version**: Specify the version of the software you are using. -- **Operating System**: Specify the OS and version you are using (e.g., Mac, Linux, Windows). -- **Labels**: Use `bug` and `help wanted`. - - -Feel free to include any additional information such as code snippets, links, screenshots, or any other relevant facts that may help in diagnosing and resolving the issue. - -Thank you for your contribution to our project! From 90fe0e4bbcfbf540b20c2ad8443b879bdcce6066 Mon Sep 17 00:00:00 2001 From: Donatas Navidonskis Date: Thu, 21 Mar 2024 19:17:35 +0200 Subject: [PATCH 10/11] docs: update PR template --- .github/pull_request_template.md | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index baef864..b969ada 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,19 +1,17 @@ -- **Description**: -- **Current Behavior**: -- **New Behavior**: -- **Breaking Changes**: -- **Type of Change**: + - -### Additional Information +#### Summary -Please provide any additional information or context that may be relevant to this pull request. + -Thank you for your contribution to our project! ---> +#### Checklist + +- [ ] Check locally +- [ ] Add tests +- [ ] Add documentation + + From fd3f8c4a467cbe9752a8d08f672b47fa44f56007 Mon Sep 17 00:00:00 2001 From: Donatas Navidonskis Date: Thu, 21 Mar 2024 19:22:23 +0200 Subject: [PATCH 11/11] docs: update main documentation (to add new hooks/features) --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index a33e1c3..3209d8d 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,12 @@ remotes: - hooks/shellcheck/.lefthook.yaml # check if the license headers are present in the files - hooks/license-checker/.lefthook.yaml + # lint the markdown (.md) files + - hooks/markdown-lint/.lefthook.yaml + # A linter for YAML files. + - hooks/yamllint/.lefthook.yaml + # validate the JSON files + - hooks/jsonlint/.lefthook.yaml ``` Run `lefthook install` (follow the [installation guide](https://github.com/evilmartians/lefthook/blob/master/docs/install.md) @@ -55,6 +61,10 @@ for shell scripts - [license-checker](./hooks/license-checker/) (**pre-commit**) - Checks if the license headers are present in the Git staged files with possibility to exclude certain files or file extensions using Regular Expression pattern. +- [jsonlint](./hooks/jsonlint/) (**pre-commit**) - Validation tool for JSON files. +- [yamllint](./hooks/yamllint/) (**pre-commit**) - A linter for YAML files. +- [markdown-lint](./hooks/markdown-lint/) (**pre-commit**) - is a static +analysis tool for *.md files. ## About Boozt