From 981605c7153e7f3ed7659028a48013d1ed6ba98d Mon Sep 17 00:00:00 2001 From: DevOps Date: Fri, 14 Nov 2025 15:32:37 +0545 Subject: [PATCH 1/7] feat: sync-precommit --- .github/scripts/extract_config.sh | 42 +++++++++ .github/workflows/sync-precommit-config.yaml | 16 +--- global/extract_config.sh | 12 +-- global/precommitFile/.pre-commit-config.yaml | 97 -------------------- 4 files changed, 51 insertions(+), 116 deletions(-) create mode 100644 .github/scripts/extract_config.sh delete mode 100644 global/precommitFile/.pre-commit-config.yaml diff --git a/.github/scripts/extract_config.sh b/.github/scripts/extract_config.sh new file mode 100644 index 0000000..e1bf850 --- /dev/null +++ b/.github/scripts/extract_config.sh @@ -0,0 +1,42 @@ +# #!/bin/bash + +# # Extract the YAML config from setup_pre_commit_config function in global/pre-commit.sh +# # and save it to global/precommitFile/.pre-commit-config.yaml + +# mkdir -p global/precommitFile + +# sed -n '/cat > "\$file" <<'\''EOF'\''/,/EOF/p' global/pre-commit.sh | sed '1d;$d' > global/precommitFile/.pre-commit-config.yaml + +# echo "Config extracted to global/precommitFile/.pre-commit-config.yaml" + +#!/bin/bash + +# List of directories in root that may contain pre-commit.sh +LANG_DIRS=("global" "golang" "python" "terraform" "typescript") + +echo "🔍 Searching for pre-commit.sh in project folders..." + +for dir in "${LANG_DIRS[@]}"; do + script_path="$dir/pre-commit.sh" + + if [[ -f "$script_path" ]]; then + echo "➡️ Found: $script_path" + + # Create destination folder + dest_dir="$dir/precommitFile" + mkdir -p "$dest_dir" + + # Output file + dest_file="$dest_dir/.pre-commit-config.yaml" + + # Extract YAML using sed + sed -n "/cat > \"\\\$file\" <<'EOF'/,/EOF/p" "$script_path" \ + | sed '1d;$d' > "$dest_file" + + echo " ✓ Extracted config → $dest_file" + else + echo "⚠️ No pre-commit.sh found in $dir — skipping." + fi +done + +echo "✅ Extraction complete!" diff --git a/.github/workflows/sync-precommit-config.yaml b/.github/workflows/sync-precommit-config.yaml index 973bb8c..b8e4ec3 100644 --- a/.github/workflows/sync-precommit-config.yaml +++ b/.github/workflows/sync-precommit-config.yaml @@ -26,19 +26,9 @@ jobs: persist-credentials: true - name: Extract config from script - run: bash global/extract_config.sh - - # - name: Validate YAML syntax - # run: | - # if command -v yamllint >/dev/null 2>&1; then - # yamllint global/precommitFile/.pre-commit-config.yaml - # else - # python3 -c "import yaml; yaml.safe_load(open('global/precommitFile/.pre-commit-config.yaml'))" - # fi - - # - name: Copy updated pre-commit config to root - # run: | - # cp global/precommitFile/.pre-commit-config.yaml .pre-commit-config.yaml + run: | + chmod +x .github/scripts/extract_config.sh + .github/scripts/generate-changelog.sh - name: Check if changes exist id: changes diff --git a/global/extract_config.sh b/global/extract_config.sh index 28998bc..c20f2b6 100755 --- a/global/extract_config.sh +++ b/global/extract_config.sh @@ -1,10 +1,10 @@ -#!/bin/bash +# #!/bin/bash -# Extract the YAML config from setup_pre_commit_config function in global/pre-commit.sh -# and save it to global/precommitFile/.pre-commit-config.yaml +# # Extract the YAML config from setup_pre_commit_config function in global/pre-commit.sh +# # and save it to global/precommitFile/.pre-commit-config.yaml -mkdir -p global/precommitFile +# mkdir -p global/precommitFile -sed -n '/cat > "\$file" <<'\''EOF'\''/,/EOF/p' global/pre-commit.sh | sed '1d;$d' > global/precommitFile/.pre-commit-config.yaml +# sed -n '/cat > "\$file" <<'\''EOF'\''/,/EOF/p' global/pre-commit.sh | sed '1d;$d' > global/precommitFile/.pre-commit-config.yaml -echo "Config extracted to global/precommitFile/.pre-commit-config.yaml" \ No newline at end of file +# echo "Config extracted to global/precommitFile/.pre-commit-config.yaml" \ No newline at end of file diff --git a/global/precommitFile/.pre-commit-config.yaml b/global/precommitFile/.pre-commit-config.yaml deleted file mode 100644 index d6b9705..0000000 --- a/global/precommitFile/.pre-commit-config.yaml +++ /dev/null @@ -1,97 +0,0 @@ -repos: - # ✅ Precommit hooks - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 - hooks: - - id: check-yaml - - id: end-of-file-fixer - - id: trailing-whitespace - - id: check-added-large-files - - id: check-vcs-permalinks - - id: check-symlinks - - id: destroyed-symlinks - - id: pretty-format-json - - # ✅ golang fmt and go tidey - - repo: https://github.com/TekWizely/pre-commit-golang - rev: v1.0.0-rc.1 - hooks: - - id: go-fmt - args: [-w] - - id: go-mod-tidy # Ensure go.mod & go.sum are tidy - - - repo: https://github.com/psf/black - rev: 23.9.1 - hooks: - - id: black - args: [--line-length=88] - # ✅ Import sorter (runs before Black) - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 - hooks: - - id: isort - args: ["--profile=black"] - - # ✅ Linter (flake8 for code quality) - - repo: https://github.com/pycqa/flake8 - rev: 6.1.0 - hooks: - - id: flake8 - args: - - --max-line-length=88 - - --extend-ignore=E203,W503 - additional_dependencies: - - flake8-bugbear - - flake8-comprehensions - - flake8-docstrings - # ✅ Static code analysis for Python (pylint optional) - - repo: https://github.com/pycqa/pylint - rev: v3.2.6 - hooks: - - id: pylint - args: ["--disable=C0114,C0115,C0116"] - additional_dependencies: - - pylint-django - - pylint-flask - # ✅ Terraform docs - - repo: https://github.com/terraform-docs/terraform-docs - rev: "v0.16.0" - hooks: - - id: terraform-docs-go - args: ["markdown", "table", "--output-file", "README.md", "./"] - - # ✅ Terraform precommit - - repo: https://github.com/antonbabenko/pre-commit-terraform - rev: "v1.74.1" - hooks: - - id: terraform_fmt - - id: terraform_validate - - id: terraform_tflint - - id: terraform_tfsec - - # ✅ Stylelint - - repo: https://github.com/thibaudcolas/pre-commit-stylelint - rev: v15.10.3 - hooks: - - id: stylelint - files: \.(css|scss)$ - exclude: "node_modules/" - additional_dependencies: - - stylelint - - stylelint-config-standard - args: ['--config', '.stylelintrc.json', '--fix'] - - # ✅ Codespell - - repo: https://github.com/codespell-project/codespell - rev: v2.2.5 - hooks: - - id: codespell - files: ^.*\.(py|c|h|md|rst|yml|go|sh|sql|tf|yaml)$ - args: ["--ignore-words-list", "hist,nd"] - # ✅ Gitleaks - - repo: https://github.com/gitleaks/gitleaks - rev: v8.21.0 - hooks: - - id: gitleaks - args: ["detect", "--verbose"] - verbose: true From 3bd9878bca0912705eccfd5df0123d7db753ebf4 Mon Sep 17 00:00:00 2001 From: DevOps Date: Fri, 14 Nov 2025 15:35:04 +0545 Subject: [PATCH 2/7] feat: sync-precommit --- .github/workflows/sync-precommit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sync-precommit-config.yaml b/.github/workflows/sync-precommit-config.yaml index b8e4ec3..8d73cb9 100644 --- a/.github/workflows/sync-precommit-config.yaml +++ b/.github/workflows/sync-precommit-config.yaml @@ -28,7 +28,7 @@ jobs: - name: Extract config from script run: | chmod +x .github/scripts/extract_config.sh - .github/scripts/generate-changelog.sh + .github/scripts/extract_config.sh - name: Check if changes exist id: changes From ccebb60accdaf93c93bd17bbed4fdcac0a4242e0 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 14 Nov 2025 09:50:18 +0000 Subject: [PATCH 3/7] Sync pre-commit YAML config from global/precommitFile --- .github/scripts/extract_config.sh | 0 global/precommitFile/.pre-commit-config.yaml | 97 +++++++++++++++++++ golang/precommitFile/.pre-commit-config.yaml | 34 +++++++ python/precommitFile/.pre-commit-config.yaml | 0 .../precommitFile/.pre-commit-config.yaml | 0 .../precommitFile/.pre-commit-config.yaml | 34 +++++++ 6 files changed, 165 insertions(+) mode change 100644 => 100755 .github/scripts/extract_config.sh create mode 100644 global/precommitFile/.pre-commit-config.yaml create mode 100644 golang/precommitFile/.pre-commit-config.yaml create mode 100644 python/precommitFile/.pre-commit-config.yaml create mode 100644 terraform/precommitFile/.pre-commit-config.yaml create mode 100644 typescript/precommitFile/.pre-commit-config.yaml diff --git a/.github/scripts/extract_config.sh b/.github/scripts/extract_config.sh old mode 100644 new mode 100755 diff --git a/global/precommitFile/.pre-commit-config.yaml b/global/precommitFile/.pre-commit-config.yaml new file mode 100644 index 0000000..d6b9705 --- /dev/null +++ b/global/precommitFile/.pre-commit-config.yaml @@ -0,0 +1,97 @@ +repos: + # ✅ Precommit hooks + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-added-large-files + - id: check-vcs-permalinks + - id: check-symlinks + - id: destroyed-symlinks + - id: pretty-format-json + + # ✅ golang fmt and go tidey + - repo: https://github.com/TekWizely/pre-commit-golang + rev: v1.0.0-rc.1 + hooks: + - id: go-fmt + args: [-w] + - id: go-mod-tidy # Ensure go.mod & go.sum are tidy + + - repo: https://github.com/psf/black + rev: 23.9.1 + hooks: + - id: black + args: [--line-length=88] + # ✅ Import sorter (runs before Black) + - repo: https://github.com/PyCQA/isort + rev: 5.12.0 + hooks: + - id: isort + args: ["--profile=black"] + + # ✅ Linter (flake8 for code quality) + - repo: https://github.com/pycqa/flake8 + rev: 6.1.0 + hooks: + - id: flake8 + args: + - --max-line-length=88 + - --extend-ignore=E203,W503 + additional_dependencies: + - flake8-bugbear + - flake8-comprehensions + - flake8-docstrings + # ✅ Static code analysis for Python (pylint optional) + - repo: https://github.com/pycqa/pylint + rev: v3.2.6 + hooks: + - id: pylint + args: ["--disable=C0114,C0115,C0116"] + additional_dependencies: + - pylint-django + - pylint-flask + # ✅ Terraform docs + - repo: https://github.com/terraform-docs/terraform-docs + rev: "v0.16.0" + hooks: + - id: terraform-docs-go + args: ["markdown", "table", "--output-file", "README.md", "./"] + + # ✅ Terraform precommit + - repo: https://github.com/antonbabenko/pre-commit-terraform + rev: "v1.74.1" + hooks: + - id: terraform_fmt + - id: terraform_validate + - id: terraform_tflint + - id: terraform_tfsec + + # ✅ Stylelint + - repo: https://github.com/thibaudcolas/pre-commit-stylelint + rev: v15.10.3 + hooks: + - id: stylelint + files: \.(css|scss)$ + exclude: "node_modules/" + additional_dependencies: + - stylelint + - stylelint-config-standard + args: ['--config', '.stylelintrc.json', '--fix'] + + # ✅ Codespell + - repo: https://github.com/codespell-project/codespell + rev: v2.2.5 + hooks: + - id: codespell + files: ^.*\.(py|c|h|md|rst|yml|go|sh|sql|tf|yaml)$ + args: ["--ignore-words-list", "hist,nd"] + # ✅ Gitleaks + - repo: https://github.com/gitleaks/gitleaks + rev: v8.21.0 + hooks: + - id: gitleaks + args: ["detect", "--verbose"] + verbose: true diff --git a/golang/precommitFile/.pre-commit-config.yaml b/golang/precommitFile/.pre-commit-config.yaml new file mode 100644 index 0000000..f2e6eb3 --- /dev/null +++ b/golang/precommitFile/.pre-commit-config.yaml @@ -0,0 +1,34 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + args: ["--allow-multiple-documents"] + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-added-large-files + - id: check-vcs-permalinks + - id: check-symlinks + - id: destroyed-symlinks + + - repo: https://github.com/TekWizely/pre-commit-golang + rev: v1.0.0-rc.1 + hooks: + - id: go-fmt + args: [-w] + - id: go-mod-tidy # Ensure go.mod & go.sum are tidy + + + - repo: https://github.com/codespell-project/codespell + rev: v2.2.5 + hooks: + - id: codespell + files: ^.*\.(py|c|h|md|rst|yml|go|sh|sql|tf|yaml)$ + exclude: ^.*(_test\.go|\.min\.js|\.map)$ + args: ["--ignore-words-list", "hist,nd"] + + - repo: https://github.com/zricethezav/gitleaks + rev: v8.18.0 + hooks: + - id: gitleaks + args: ["detect", "--verbose"] diff --git a/python/precommitFile/.pre-commit-config.yaml b/python/precommitFile/.pre-commit-config.yaml new file mode 100644 index 0000000..e69de29 diff --git a/terraform/precommitFile/.pre-commit-config.yaml b/terraform/precommitFile/.pre-commit-config.yaml new file mode 100644 index 0000000..e69de29 diff --git a/typescript/precommitFile/.pre-commit-config.yaml b/typescript/precommitFile/.pre-commit-config.yaml new file mode 100644 index 0000000..b2920ba --- /dev/null +++ b/typescript/precommitFile/.pre-commit-config.yaml @@ -0,0 +1,34 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-added-large-files + + # - repo: https://github.com/pre-commit/mirrors-prettier + # rev: v3.1.0 + # hooks: + # - id: prettier + # files: \.(js|jsx|ts|tsx|css|html|json)$ + # types: [file] + # exclude: "node_modules/" + # args: ['--config', '.prettierrc'] + + - repo: https://github.com/thibaudcolas/pre-commit-stylelint + rev: v15.10.3 + hooks: + - id: stylelint + files: \.(css|scss)$ + exclude: "node_modules/" + additional_dependencies: + - stylelint + - stylelint-config-standard + args: ['--config', '.stylelintrc.json', '--fix'] + + - repo: https://github.com/gitleaks/gitleaks + rev: v8.21.0 + hooks: + - id: gitleaks + args: ["detect", "--verbose"] From 3f2d3d88b8d5a346ab0fee75a7f730f36fb34e31 Mon Sep 17 00:00:00 2001 From: DevOps Date: Fri, 14 Nov 2025 15:39:23 +0545 Subject: [PATCH 4/7] feat: sync-precommit --- global/pre-commit.sh | 4 ++-- golang/pre-commit.sh | 1 + python/pre-commit.sh | 2 +- terraform/pre-commit.sh | 1 + typescript/pre-commit.sh | 1 + 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/global/pre-commit.sh b/global/pre-commit.sh index 6ad6738..7022294 100755 --- a/global/pre-commit.sh +++ b/global/pre-commit.sh @@ -68,7 +68,7 @@ setup_pre_commit_config() { if [[ ! -f "$file" ]]; then cat > "$file" <<'EOF' repos: - # ✅ Precommit hooks + ############ ✅ Precommit hooks ############# - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: @@ -81,7 +81,7 @@ repos: - id: destroyed-symlinks - id: pretty-format-json - # ✅ golang fmt and go tidey + ########## ✅ golang fmt and go tidey ######### - repo: https://github.com/TekWizely/pre-commit-golang rev: v1.0.0-rc.1 hooks: diff --git a/golang/pre-commit.sh b/golang/pre-commit.sh index 53c1310..9e95d49 100755 --- a/golang/pre-commit.sh +++ b/golang/pre-commit.sh @@ -64,6 +64,7 @@ setup_pre_commit_config() { cat > "$file" <<'EOF' repos: + ############ ✅ Precommit hooks ############# - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: diff --git a/python/pre-commit.sh b/python/pre-commit.sh index af05247..72d58a0 100755 --- a/python/pre-commit.sh +++ b/python/pre-commit.sh @@ -60,7 +60,7 @@ setup_pre_commit_config() { cat > "$config" <<'EOF' repos: - # ✅ Generic pre-commit hygiene + ############ ✅ Precommit hooks ############# - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks: diff --git a/terraform/pre-commit.sh b/terraform/pre-commit.sh index a470148..340fd30 100755 --- a/terraform/pre-commit.sh +++ b/terraform/pre-commit.sh @@ -44,6 +44,7 @@ setup_pre_commit_config() { if [ ! -f "$pre_commit_config" ]; then cat > "$pre_commit_config" < "$file" <<'EOF' repos: + ############ ✅ Precommit hooks ############# - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: From 28c5b45d590f0e3ebbc58b68a410b22682fee7ca Mon Sep 17 00:00:00 2001 From: DevOps Date: Fri, 14 Nov 2025 15:40:11 +0545 Subject: [PATCH 5/7] feat: sync-precommit --- typescript/pre-commit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/pre-commit.sh b/typescript/pre-commit.sh index 44a1e18..ab8af65 100755 --- a/typescript/pre-commit.sh +++ b/typescript/pre-commit.sh @@ -71,7 +71,7 @@ setup_pre_commit_config() { if [[ ! -f "$file" ]]; then cat > "$file" <<'EOF' repos: - ############ ✅ Precommit hooks ############# + ############ ✅ Precommit hooks ############# - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: From cde3c0b964415a71fd93d607e0014d16822ac409 Mon Sep 17 00:00:00 2001 From: DevOps Date: Fri, 14 Nov 2025 15:41:22 +0545 Subject: [PATCH 6/7] feat: sync-precommit --- typescript/pre-commit.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/pre-commit.sh b/typescript/pre-commit.sh index ab8af65..36fe05d 100755 --- a/typescript/pre-commit.sh +++ b/typescript/pre-commit.sh @@ -71,7 +71,7 @@ setup_pre_commit_config() { if [[ ! -f "$file" ]]; then cat > "$file" <<'EOF' repos: - ############ ✅ Precommit hooks ############# + ############ ✅ Precommit hooks ############# - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: From b5dfd24bff7fda6aa5d40d1386bbebf7c6a7acd5 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Fri, 14 Nov 2025 09:56:37 +0000 Subject: [PATCH 7/7] Sync pre-commit YAML config from global/precommitFile --- global/precommitFile/.pre-commit-config.yaml | 4 ++-- golang/precommitFile/.pre-commit-config.yaml | 1 + typescript/precommitFile/.pre-commit-config.yaml | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/global/precommitFile/.pre-commit-config.yaml b/global/precommitFile/.pre-commit-config.yaml index d6b9705..8f782b0 100644 --- a/global/precommitFile/.pre-commit-config.yaml +++ b/global/precommitFile/.pre-commit-config.yaml @@ -1,5 +1,5 @@ repos: - # ✅ Precommit hooks + ############ ✅ Precommit hooks ############# - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: @@ -12,7 +12,7 @@ repos: - id: destroyed-symlinks - id: pretty-format-json - # ✅ golang fmt and go tidey + ########## ✅ golang fmt and go tidey ######### - repo: https://github.com/TekWizely/pre-commit-golang rev: v1.0.0-rc.1 hooks: diff --git a/golang/precommitFile/.pre-commit-config.yaml b/golang/precommitFile/.pre-commit-config.yaml index f2e6eb3..ff1989c 100644 --- a/golang/precommitFile/.pre-commit-config.yaml +++ b/golang/precommitFile/.pre-commit-config.yaml @@ -1,4 +1,5 @@ repos: + ############ ✅ Precommit hooks ############# - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: diff --git a/typescript/precommitFile/.pre-commit-config.yaml b/typescript/precommitFile/.pre-commit-config.yaml index b2920ba..0026bd8 100644 --- a/typescript/precommitFile/.pre-commit-config.yaml +++ b/typescript/precommitFile/.pre-commit-config.yaml @@ -1,4 +1,5 @@ repos: + ############ ✅ Precommit hooks ############# - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.4.0 hooks: