Skip to content

Commit

Permalink
adding pre-commit for validate check
Browse files Browse the repository at this point in the history
Signed-off-by: ntishchauhan0022 <nitishchauhan0022@gmail.com>
  • Loading branch information
nitishchauhan0022 committed Aug 11, 2023
1 parent 9be2e36 commit 59095f8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,9 @@ repos:
entry: golangci-lint run
types: [go]
pass_filenames: false
- id: validate-changelog
name: Validate Changelog
language: system
entry: "bash hack/validate-changelog.sh"
pass_filenames: false
files: CHANGELOG\.md
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio

### Improvements

- **General**: Adding a changelog validating script to check for formatting and order in make and github action ([#3190](https://github.com/kedacore/keda/issues/3190))
- **General:**: Add ScaledObject/ScaledJob names to output of `kubectl get triggerauthentication/clustertriggerauthentication` ([#796](https://github.com/kedacore/keda/issues/796))
- **General:**: Add standalone CRD generation to release workflow ([#2726](https://github.com/kedacore/keda/issues/2726))

Expand Down Expand Up @@ -108,8 +109,10 @@ None.

- **General**: Paused ScaledObject continues working after removing the annotation ([#4733](https://github.com/kedacore/keda/issues/4733))
- **General**: Skip resolving secrets if namespace is restricted ([#4519](https://github.com/kedacore/keda/issues/4519))
- **General**: Adding a changelog validating script to check for formatting and order in make and github action ([#3190](https://github.com/kedacore/keda/issues/3190))
- **Prometheus**: Authenticated connections to Prometheus work in non-PodIdenty case ([#4695](https://github.com/kedacore/keda/issues/4695))


### Deprecations

You can find all deprecations in [this overview](https://github.com/kedacore/keda/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Abreaking-change) and [join the discussion here](https://github.com/kedacore/keda/discussions/categories/deprecations).
Expand Down
16 changes: 8 additions & 8 deletions hack/validate-changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ fi
# Define a function to extract and sort sections
function extract_and_check() {
local section=$1
local content=$(awk "/### $section/{flag=1;next}/### /{flag=0}flag" <<< "$unreleased" | grep '^- \*\*')
local content=$(awk "/### $section/{flag=1;next}/### /{flag=0}flag" <<< "$unreleased" | grep '^- \*\*')

# Skip if content does not exist
if [[ -z "$content" ]]; then
return
fi

local sorted_content=$(echo "$content" | sort)

# Check pattern and throw error if wrong pattern found
echo "$content" | grep -Pv '^(-\s\*\*[^*]+\*\*: .*\(\[#(\d+)\]\(https:\/\/github\.com\/kedacore\/keda\/(pull|issues)\/\2\)\))$' | while read -r line ; do
echo "Error: Wrong pattern found in $section section, line: $line"
exit 1
done
while IFS= read -r line; do
echo "Error: Wrong pattern found in $section section, line: $line"
exit 1
done < <(grep -Pv '^(-\s\*\*[^*]+\*\*: .*\(\[#(\d+)\]\(https:\/\/github\.com\/kedacore\/keda\/(pull|issues)\/\2\)\))$' <<< "$content")

if [ "$content" != "$sorted_content" ]; then
echo "Error: The $section section is not sorted correctly. Correct order:"
echo "$sorted_content"
Expand All @@ -50,4 +50,4 @@ extract_and_check "New"
extract_and_check "Improvements"
extract_and_check "Fixes"
extract_and_check "Deprecations"
extract_and_check "Other"
extract_and_check "Other"

0 comments on commit 59095f8

Please sign in to comment.