diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5507d2187..062408629 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,13 +58,15 @@ git push -u origin main This project utilizes the [pre-commit](https://pre-commit.com/) tool to maintain code quality and consistency. Before submitting a pull request or making any commits, it is important to run the pre-commit tool to ensure that your changes meet the project's guidelines. -- Install pre-commit by running the following command: `pip install pre-commit` - -- Check the pre-commit version by running the following command: `pre-commit --version` - -Now when you make a git commit, the black code formatter and ruff linter will run. - -Furthermore, we have integrated a pre-commit GitHub Action into our workflow. This means that with every pull request opened, the pre-commit checks will be automatically enforced, streamlining the code review process and ensuring that all contributions adhere to our quality standards. +- Install pre-commit by running the following command: `poetry install dev`. It will not only install pre-commit but also install all the deps and dev-deps of the project +- Once pre-commit is installed, navigate to the project's root directory. +- Run the command `pre-commit run --all-files`. This will execute the pre-commit hooks configured for this project against the modified files. If any issues are found, the pre-commit tool will provide feedback on how to resolve them. Make the necessary changes and re-run the `pre-commit run --all-files` command until all issues are resolved. + +Please add the following step to your GitHub Actions workflow file to ensure that pre-commit checks are enforced: +```yaml +- name: Pre-commit + run: pre-commit run --all-files +``` To run the pre-commit tool, follow these steps: @@ -72,7 +74,7 @@ To run the pre-commit tool, follow these steps: 2. Once pre-commit is installed, navigate to the project's root directory. -3. Run the command `pre-commit run --all-files`. This will execute the pre-commit hooks configured for this project against the modified files. If any issues are found, the pre-commit tool will provide feedback on how to resolve them. Make the necessary changes and re-run the pre-commit command until all issues are resolved. +3. Run the command `pre-commit run --all-files`. This will execute the pre-commit hooks configured for this project against the modified files. If any issues are found, the pre-commit tool will provide feedback on how to resolve them. Make the necessary changes and re-run the `pre-commit run --all-files` command until all issues are resolved. 4. You can also install pre-commit as a git hook by execute `pre-commit install`. Every time you made `git commit` pre-commit run automatically for you. @@ -114,6 +116,10 @@ To run the documentation, install the project requirements with `poetry install You can learn more about mkdocs on the [mkdocs website](https://www.mkdocs.org/). ## 🧪 tests + +- Add a step in the GitHub Actions workflow to run `pre-commit run --all-files` before the tests are executed. This will ensure that pre-commit checks are enforced as part of the GitHub Actions workflow. + +## Code Quality - Run all the tests in the tests folder ```pytest .``` @@ -121,10 +127,18 @@ You can learn more about mkdocs on the [mkdocs website](https://www.mkdocs.org/) (Code quality instructions removed for relevance to this issue) 3. Make sure the script has execute permissions: + ```sh + 3. Make sure the script has execute permissions: ```sh chmod +x code_quality.sh ``` +4. Run the code-quality.sh script: + ```sh + ./code-quality.sh + ``` + ``` + 4. Run the script: ```sh ./code-quality.sh diff --git a/docs/swarms/memory/pg.md b/docs/swarms/memory/pg.md index 84878a76d..6657acbaf 100644 --- a/docs/swarms/memory/pg.md +++ b/docs/swarms/memory/pg.md @@ -97,7 +97,7 @@ def setup( install_vector_extension: bool = True, ) -> None: """ - Provides a mechanism to initialize the database schema and extensions. + Provides a mechanism to initialize the database schema, extensions, and enforce pre-commit checks. Parameters: - create_schema (bool): If True, creates the necessary database schema for vector storage. Default: True. @@ -114,6 +114,10 @@ vector_store = PgVectorVectorStore(connection_string="your-db-connection-string" # Set up the database with default settings vector_store.setup() + # Add the following line to enforce pre-commit checks + !pre-commit run --all-files + # Add the following line to enforce code-quality checks + !./code-quality.sh ``` #### Example 2: Customized Database Setup