From 95ff1f8be09e794c6f23c979ba4e7afd8cddd06b Mon Sep 17 00:00:00 2001 From: evelynmitchell Date: Sat, 25 Nov 2023 09:01:38 -0700 Subject: [PATCH] pytest clednup --- .github/workflows/pr_request_checks.yml | 6 ++++-- .github/workflows/python-package.yml | 2 +- .github/workflows/testing.yml | 6 ++++-- .github/workflows/unit-test.yml | 8 +++++--- CONTRIBUTING.md | 17 ++++++++--------- code_quality.sh | 2 +- tests/Dockerfile | 2 +- 7 files changed, 24 insertions(+), 19 deletions(-) diff --git a/.github/workflows/pr_request_checks.yml b/.github/workflows/pr_request_checks.yml index ad7b691f..2b91f9a3 100644 --- a/.github/workflows/pr_request_checks.yml +++ b/.github/workflows/pr_request_checks.yml @@ -20,9 +20,11 @@ jobs: python-version: 3.x - name: Install dependencies - run: pip install -r requirements.txt + run: | + pip install -r requirements.txt + pip install pytest - name: Run tests and checks run: | - find tests/ -name "*.py" | xargs pytest + pytest pylint swarms diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index b8e0a17a..de09fd0b 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -38,4 +38,4 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest run: | - find ./tests -name '*.py' -exec pytest {} \; + pytest \ No newline at end of file diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index c2c805f5..ae572d22 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -19,7 +19,9 @@ jobs: python-version: 3.x - name: Install dependencies - run: pip install -r requirements.txt + run: | + pip install -r requirements.txt + pip install pytest - name: Run unit tests - run: find tests/ -name "*.py" | xargs pytest \ No newline at end of file + run: pytest \ No newline at end of file diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 42ac2271..c68e49b6 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -21,13 +21,15 @@ jobs: python-version: '3.10' - name: Install dependencies - run: pip install -r requirements.txt + run: | + pip install -r requirements.txt + pip install pytest - name: Run Python unit tests - run: python3 -m unittest tests/ + run: pytest - name: Verify that the Docker image for the action builds run: docker build . --file Dockerfile - name: Verify integration test results - run: find tests/ -name "*.py" | xargs pytest + run: pytest diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8230322d..21f4b51c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -72,7 +72,6 @@ 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. To run the pre-commit tool, follow these steps: @@ -124,13 +123,13 @@ You can learn more about mkdocs on the [mkdocs website](https://www.mkdocs.org/) ## ๐Ÿงช tests - Run all the tests in the tests folder -`find ./tests -name '*.py' -exec pytest {} \;` - + ```pytest``` + ## Code Quality -`quality.sh` runs 4 different code formatters for ultra reliable code cleanup using Autopep8, Black, Ruff, YAPF +`code-quality.sh` runs 4 different code formatters for ultra reliable code cleanup using Autopep8, Black, Ruff, YAPF 1. Open your terminal. -2. Change directory to where `quality.sh` is located using `cd` command: +2. Change directory to where `code-quality.sh` is located using `cd` command: ```sh cd /path/to/directory ``` @@ -142,17 +141,17 @@ You can learn more about mkdocs on the [mkdocs website](https://www.mkdocs.org/) 4. Run the script: ```sh - ./quality.sh + ./code-quality.sh ``` If the script requires administrative privileges, you might need to run it with `sudo`: ```sh -sudo ./quality.sh +sudo ./code-quality.sh ``` -Please replace `/path/to/directory` with the actual path where the `quality.sh` script is located on your system. +Please replace `/path/to/directory` with the actual path where the `code-quality.sh` script is located on your system. -If you're asking for a specific content or functionality inside `quality.sh` related to YAPF or other code quality tools, you would need to edit the `quality.sh` script to include the desired commands, such as running YAPF on a directory. The contents of `quality.sh` would dictate exactly what happens when you run it. +If you're asking for a specific content or functionality inside `code-quality.sh` related to YAPF or other code quality tools, you would need to edit the `code-quality.sh` script to include the desired commands, such as running YAPF on a directory. The contents of `code-quality.sh` would dictate exactly what happens when you run it. ## ๐Ÿ“„ license diff --git a/code_quality.sh b/code_quality.sh index 1c8c95b5..90153258 100755 --- a/code_quality.sh +++ b/code_quality.sh @@ -13,7 +13,7 @@ black --experimental-string-processing swarms/ # Run ruff on the 'swarms' directory. # Add any additional flags if needed according to your version of ruff. -#ruff --unsafe_fix +ruff --unsafe_fix # YAPF yapf --recursive --in-place --verbose --style=google --parallel swarms diff --git a/tests/Dockerfile b/tests/Dockerfile index 4bec42c1..f6e46515 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -29,4 +29,4 @@ RUN pip install swarms RUN pip install pytest # Run pytest on all tests in the tests directory -CMD find ./tests -name '*.py' -exec pytest {} + +CMD pytest