From 329b961b6346d517db240ce825c712fe30b69a25 Mon Sep 17 00:00:00 2001 From: Sina Atalay Date: Sun, 8 Dec 2024 05:34:23 -0500 Subject: [PATCH] remove tests environment and use the default environment for tests --- .github/workflows/test.yaml | 8 ++--- docs/developer_guide/index.md | 20 +++++-------- docs/developer_guide/testing.md | 6 ++-- pyproject.toml | 52 ++++++++++++--------------------- 4 files changed, 32 insertions(+), 54 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ff74a6b6..da0e8c8c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -57,7 +57,7 @@ jobs: uses: pypa/hatch@install - name: Test - run: hatch run test:coverage run -m pytest + run: hatch run coverage run -m pytest - name: Rename the coverage file run: mv .coverage .coverage.${{ matrix.python-version }}.${{ matrix.os }} @@ -96,9 +96,9 @@ jobs: - name: Combine coverage files run: | - hatch run test:coverage combine coverage - hatch run test:coverage report - hatch run test:coverage html --show-contexts --title "RenderCV coverage for ${{ github.sha }}" + hatch run coverage combine coverage + hatch run coverage report + hatch run coverage html --show-contexts --title "RenderCV coverage for ${{ github.sha }}" - name: Upload the coverage report to smokeshow run: | diff --git a/docs/developer_guide/index.md b/docs/developer_guide/index.md index 83516d95..323710e3 100644 --- a/docs/developer_guide/index.md +++ b/docs/developer_guide/index.md @@ -22,16 +22,14 @@ There are two ways of developing RenderCV: locally or with GitHub Codespaces. cd rendercv ``` 5. RenderCV uses three virtual environments: - - `default`: For the development. It contains packages like [Ruff](https://github.com/astral-sh/ruff), [Black](https://github.com/psf/black), etc. + - `default`: For the development and testing. It contains packages like [Ruff](https://github.com/astral-sh/ruff), [Black](https://github.com/psf/black), [pytest](https://github.com/pytest-dev/pytest) etc. - `docs`: For building the documentation. - - `test`: For testing RenderCV. Create the virtual environments with the following commands. ```bash hatch env create default hatch env create docs - hatch env create test ``` 6. To use the virtual environments, either @@ -45,10 +43,6 @@ There are two ways of developing RenderCV: locally or with GitHub Codespaces. hatch shell docs ``` - ```bash - hatch shell test - ``` - - Select one of the virtual environments in your Integrated Development Environment (IDE). === "Visual Studio Code" @@ -77,27 +71,27 @@ These commands are defined in the [`pyproject.toml`](https://github.com/sinaatal - Format the code with [Black](https://github.com/psf/black) ```bash - hatch run default:format + hatch run format ``` - Lint the code with [Ruff](https://github.com/astral-sh/ruff) ```bash - hatch run default:lint + hatch run lint ``` - Sort the imports with [isort](https://github.com/timothycrosley/isort/) ```bash - hatch run default:sort-imports + hatch run sort-imports ``` - Check the types with [Pyright](https://github.com/RobertCraigie/pyright-python) ```bash - hatch run default:check-types + hatch run check-types ``` - Run the tests ```bash - hatch run test:run + hatch run test ``` - Run the tests and generate a coverage report ```bash - hatch run test:run-and-report + hatch run test-and-report ``` - Start the development server for the documentation ```bash diff --git a/docs/developer_guide/testing.md b/docs/developer_guide/testing.md index b8fef719..6aaeab2a 100644 --- a/docs/developer_guide/testing.md +++ b/docs/developer_guide/testing.md @@ -3,15 +3,15 @@ After updating the code, ensure that all tests pass. To run the tests, use the following command. ```bash -hatch run test:run +hatch run test ``` -If you would like to run the tests in your IDE, use the `test` virtual environment. +If you would like to run the tests in your IDE, use the `default` virtual environment. To generate a coverage report with the tests, run the following command. ```bash -hatch run test:run-and-report +hatch run test-and-report ``` Once new commits are pushed to the `main` branch, the [`test.yaml`](https://github.com/sinaatalay/rendercv/blob/main/.github/workflows/test.yaml) workflow will be automatically triggered, and the tests will run. diff --git a/pyproject.toml b/pyproject.toml index 9b0fe6c7..60d2afdc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,16 +70,16 @@ requires-python = '>=3.10' # RenderCV depends on these packages. They will be installed automatically when RenderCV # is installed: dependencies = [ - 'Jinja2==3.1.4', # to generate LaTeX and Markdown files - 'phonenumbers==8.13.50', # to validate phone numbers - 'email-validator==2.2.0', # to validate email addresses + 'Jinja2==3.1.4', # to generate LaTeX and Markdown files + 'phonenumbers==8.13.50', # to validate phone numbers + 'email-validator==2.2.0', # to validate email addresses 'pydantic==2.10.2', # to validate and parse the input file 'pydantic-extra-types==2.10.0', # to validate some extra types - 'ruamel.yaml==0.18.6', # to parse YAML files - 'typer==0.15.1', # to create the command-line interface - "markdown==3.7", # to convert Markdown to HTML - "PyMuPDF==1.24.14", # to convert PDF files to images - "watchdog==6.0.0", # to poll files for updates + 'ruamel.yaml==0.18.6', # to parse YAML files + 'typer==0.15.1', # to create the command-line interface + "markdown==3.7", # to convert Markdown to HTML + "PyMuPDF==1.24.14", # to convert PDF files to images + "watchdog==6.0.0", # to poll files for updates ] classifiers = [ "Intended Audience :: Science/Research", @@ -132,11 +132,11 @@ rendercv = 'rendercv.cli:app' [tool.hatch.envs.default] # Dependencies to be installed in the `default` virtual environment. dependencies = [ - "ruff", # to lint the code - "black", # to format the code - "ipython", # for ipython shell - "isort", # to sort the imports - "pyright", # to check the types + "ruff", # to lint the code + "black", # to format the code + "ipython", # for ipython shell + "isort", # to sort the imports + "pyright", # to check the types "pytest==8.3.2", # to run the tests "coverage==7.6.1", # to generate coverage reports "time-machine==2.15.0", # to select an arbitrary date and time for testing @@ -154,6 +154,11 @@ lint = "ruff check rendercv && ruff check tests" # hatch run lint sort-imports = "isort rendercv && isort docs && isort tests" # hatch run sort-imports # Check types in the `rendercv` package with `pyright`: check-types = "pyright rendercv && pyright tests" # hatch run check-types +# Run the tests: +test = "pytest" # hatch run test +# Run the tests and generate the coverage report as HTML: +test-and-report = "coverage run -m pytest && coverage report && coverage html --show-contexts" # hatch run test-and-report + [tool.hatch.envs.docs] # Dependencies to be installed in the `docs` virtual environment. @@ -177,27 +182,6 @@ update-examples = "python docs/update_examples.py" # hatch run docs:update-examp # Update entry figures in "Structure of the YAML File" page: update-entry-figures = "python docs/update_entry_figures.py" # hatch run docs:update-entry-figures -[tool.hatch.envs.test] -# Dependencies to be installed in the `test` virtual environment. -dependencies = [ - "pytest==8.3.2", # to run the tests - "coverage==7.6.1", # to generate coverage reports - "time-machine==2.15.0", # to select an arbitrary date and time for testing - "pypdf==4.3.1", # to read PDF files - # "hatch==1.12.0", # to test hatch scripts -] -path = ".venv-test" -# [[tool.hatch.envs.test.matrix]] -# # We can specify the Python versions that we want to test RenderCV with. Hatch will -# # create three different virtual environments for each Python version. -# # They will be named as test.py3.10, test.py3.11, and test.py3.12. -# python = ["3.10", "3.11", "3.12"] -[tool.hatch.envs.test.scripts] -# Run the tests: -run = "pytest" # hatch run test:run -# Run the tests and generate the coverage report as HTML: -run-and-report = "coverage run -m pytest && coverage report && coverage html --show-contexts" # hatch run test:coverage - # ====================================================================================== # Virtual Environments Above =========================================================== # ======================================================================================