Skip to content

Conversation

@nammn
Copy link
Collaborator

@nammn nammn commented Dec 10, 2025

Summary

  • introducing pre-commit and migrating our self written pre-commit hook to it
  • introducing common pre-commit hooks
  • i changed isort to use 120 to match what black does, apparently we didn't before
  • changed snippet validator to skip git ignored folders
  • why: we decided to migrate to a common used tool for better support, composability and maintenance

core changes (out of all files): can be seen in the first commit, all the subsequent commits are fixing those

Next

  • activate file and whitespace linter in the next pr which will also change tons of files

Proof of Work

  • green ci: patch
  • red ci when something is wrong from the first commit: patch

Checklist

  • Have you linked a jira ticket and/or is the ticket in the title?
  • Have you checked whether your jira ticket required DOCSP changes?
  • Have you added changelog file?

@nammn nammn added the skip-changelog Use this label in Pull Request to not require new changelog entry file label Dec 10, 2025
@nammn nammn force-pushed the pre-commit branch 2 times, most recently from d3ddcb8 to 53ed895 Compare December 11, 2025 07:25
nammn added a commit that referenced this pull request Dec 11, 2025
This branch contains only the core implementation files for review.
The full PR (#642) includes additional auto-formatted files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
nammn added a commit that referenced this pull request Dec 11, 2025
This branch contains only the core implementation files for review.
The full PR (#642) includes additional auto-formatted files.
@nammn nammn force-pushed the pre-commit branch 2 times, most recently from 922b4cd to c3113c3 Compare December 11, 2025 09:13
@github-actions
Copy link

github-actions bot commented Dec 11, 2025

⚠️ (this preview might not be accurate if the PR is not rebased on current master branch)

MCK 1.6.2 Release Notes

@@ -0,0 +1,213 @@
#!/usr/bin/env bash
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thyis is mostly cp and paste from pre-commit

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in later pr i plan to enable newlines and trailing whitespace fixer, but then we will need to ensure that all generated files follow this - otherwise, pre-commit will fail if pre-commit needs to fix it

source scripts/dev/set_env_context.sh
source scripts/funcs/printing

# Strip trailing whitespace from files to ensure clean generation output
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we don't do this, then we generate and then pre-commit runs and fixes them and then it fails as it changed something

@nammn nammn marked this pull request as ready for review December 11, 2025 11:48
@nammn nammn requested review from a team and vinilage as code owners December 11, 2025 11:48
@nammn nammn force-pushed the pre-commit branch 4 times, most recently from f4fde10 to 1c4f4be Compare December 11, 2025 12:28
@nammn nammn marked this pull request as draft December 11, 2025 12:42
@nammn nammn force-pushed the pre-commit branch 4 times, most recently from 224f8a2 to d68a102 Compare December 11, 2025 14:26
@nammn nammn marked this pull request as ready for review December 12, 2025 12:23
@nammn nammn requested a review from m1kola December 12, 2025 12:28
@nammn nammn force-pushed the pre-commit branch 4 times, most recently from be1c93a to 0b8d1f6 Compare December 12, 2025 13:45
@nammn nammn marked this pull request as draft December 12, 2025 14:00
@nammn nammn marked this pull request as ready for review December 12, 2025 14:27
…framework

- Add .pre-commit-config.yaml with hooks for golangci-lint, shellcheck, black, isort, etc.
- Add generate_files.sh and regenerate_multicluster_rbac.sh scripts
- Update Makefile, pyproject.toml, requirements.txt for pre-commit integration
- Update evergreen scripts for pre-commit checks
- Run pre-commit generation jobs in parallel
- Auto-format Python files with black and isort
- Apply shellcheck fixes to shell scripts
@evergreen-ci-prod
Copy link

There is an existing patch(es) for this commit SHA:

Please note that the status that is posted is not in the context of this PR but rather the (latest) existing patch and that may affect some tests that may depend on the particular PR. If your tests do not rely on any PR-specific values (like base or head branch name) then your tests will report the same status. If you would like a patch to run in the context of this PR and abort the other(s), comment 'evergreen retry'.


default_stages: [pre-commit]

repos:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is mostly suggested and generated by llms

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
# TODO: Enable these hooks in a follow-up PR - they modify 200+ files
Copy link
Collaborator Author

@nammn nammn Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented them out for later prs, the same for yamllinter

@nammn nammn requested review from Julien-Ben and Copilot December 18, 2025 22:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces pre-commit framework integration to standardize code quality checks and formatting, replacing the custom pre-commit hook with a widely-supported tool. The changes include migrating existing validation logic, applying auto-formatting fixes, and configuring common linting hooks.

  • Migrated from custom .githooks/pre-commit script to pre-commit framework
  • Applied automated formatting fixes from black, isort, and shellcheck across Python and shell scripts
  • Updated isort configuration to match black's 120-character line length

Reviewed changes

Copilot reviewed 122 out of 123 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.pre-commit-config.yaml New pre-commit framework configuration with hooks for black, isort, shellcheck, golangci-lint, and custom generation tasks
.githooks/pre-commit Simplified to delegate to pre-commit framework, maintaining backwards compatibility
scripts/dev/generate_files.sh New script consolidating file generation logic previously in pre-commit hook
scripts/evergreen/check_precommit.sh Updated to use pre-commit framework instead of custom hook
pyproject.toml Added line_length=120 to isort configuration
Python files (scripts/release/, docker/mongodb-kubernetes-tests/tests/) Applied isort formatting to condense multi-line imports
Shell scripts (multi_cluster/tools/, docker/mongodb-agent/, etc.) Applied shellcheck fixes for variable quoting and braces
scripts/release/build/image_build_process.py Applied black formatting to method signatures and statements
scripts/code_snippets/validate_snippets.py Added git-ignore checking to skip ignored folders
Makefile Updated precommit targets to use pre-commit framework

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Julien-Ben
Copy link
Collaborator

LGTM ! Good to migrate to a proper framework, and I like the parallelization !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Use this label in Pull Request to not require new changelog entry file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants