Skip to content

Commit

Permalink
Merge pull request #6 from boozt-platform/feat-add-markdown-lint
Browse files Browse the repository at this point in the history
feat: add yaml, json and markdown linters
  • Loading branch information
doniz authored Mar 21, 2024
2 parents f7d9bfd + fd3f8c4 commit 6f73fbe
Show file tree
Hide file tree
Showing 32 changed files with 718 additions and 294 deletions.
44 changes: 44 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -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'
---

<!-- markdownlint-disable -->
### Summary

<!-- A brief summary of the problem. -->

### Lefthook version

<!-- The result of `lefthook version -f` -->

### Steps to reproduce

<!-- All bug reports should include detailed steps to reproduce -->

### Expected results

<!-- Outline what you expected to see -->

### Actual results

<!-- Outline the actual results -->

### Possible Solution

<!--- Optionally suggest a fix or reason for the bug -->

### Logs / Screenshots

<!---
If the error can be reproduced via GUI or CLI command, please send the logs.
Make sure you have set LEFTHOOK_VERBOSE=true before running the command.
-->

```bash
LEFTHOOK_VERBOSE=true git ...
```

<!-- markdownlint restore -->
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-FileCopyrightText: Copyright Boozt Fashion, AB
# SPDX-License-Identifier: MIT
---
blank_issues_enabled: false
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Want to add a new hook or improve it? Create a feature request!
labels: 'feature request'
---

<!-- markdownlint-disable -->
### Summary

<!-- A brief summary of a feature. -->

### Value

<!-- A few words about what problem it is solving or how it makes life easier. -->

### Behavior and configuration changes

<!-- What should be changed in current behavior/configuration? -->

<!-- markdownlint restore -->
28 changes: 0 additions & 28 deletions .github/issue_template.md

This file was deleted.

26 changes: 12 additions & 14 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
- **Description**: <!-- Briefly describe the changes made in this pull request. -->
- **Current Behavior**: <!-- Describe the current behavior, or link to an open issue if applicable. -->
- **New Behavior**: <!-- Describe the new behavior introduced by this PR, especially if it's a feature change. -->
- **Breaking Changes**: <!-- Does this PR introduce any breaking changes? If so, provide guidelines to support backward compatibility and inform users how to resolve potential issues. -->
- **Type of Change**: <!-- What kind of change does this PR introduce? (Bug fix, feature, docs update, etc.) -->
<!-- markdownlint-disable -->

<!--
Closes # (issue)

- Please review the CONTRIBUTING file for guidelines on contributing to this project.
- Ensure that your commit messages follow the conventional commits guidelines.
- Double-check if any documentation needs to be updated within your changes.
- Have tests been added to cover the changes made?
<!-- Link to an issue(s) this PR fixes -->

### Additional Information
#### Summary

Please provide any additional information or context that may be relevant to this pull request.
<!-- Brief description of what was done -->

Thank you for your contribution to our project!
-->
#### Checklist

- [ ] Check locally
- [ ] Add tests
- [ ] Add documentation

<!-- markdownlint restore -->
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# SPDX-FileCopyrightText: Copyright Boozt Fashion, AB
# SPDX-License-Identifier: MIT

---
name: Release
on:
"on":
push:
branches:
- 'main'
Expand Down
11 changes: 6 additions & 5 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 5 additions & 3 deletions .lefthook.yaml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 12 additions & 9 deletions .lefthook/pre-commit/license-checker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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

Expand Down
3 changes: 0 additions & 3 deletions .license-checker → .license-checker.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
LICENSE_HEADER=$(cat <<EOF
SPDX-FileCopyrightText: Copyright Boozt Fashion, AB
SPDX-License-Identifier: MIT
EOF
)
Loading

0 comments on commit 6f73fbe

Please sign in to comment.