rye
rye copied to clipboard
Excluding parent virtual project from `rye test --all` run in monorepo setup
I'd like to raise a suggestion regarding the behavior of the rye test --all
command in a monorepo setup, specifically when using a virtual project as the parent project.
Scenario
I've structured my project as a monorepo using Rye. I initialized the base project with rye init --virtual <name-of-parent>
and then set up multiple subprojects using rye init --script <name-of-the-subproject>
.
Here's a snippet of the pyproject.toml file for the parent virtual project:
[tool.rye]
managed = true
virtual = true
dev-dependencies = []
[tool.rye.workspace]
members = ["subproject-*"]
Issue
When running rye test --all, tests are executed for the parent virtual project, even though it doesn't contain any code. This behavior seems unnecessary since the parent virtual project serves only as a connector for the subprojects within the monorepo.
Current Output
The rye test --all command runs tests for all projects, including the parent virtual project, resulting in unnecessary test runs and output.
Running tests for monorepo (/path/to/monorepo)
======================================================================= test session starts =======================================================================
platform linux -- Python 3.8.13, pytest-8.1.1, pluggy-1.5.0
rootdir: /path/to/monorepo
configfile: pyproject.toml
collected 0 items
====================================================================== no tests ran in 0.01s ======================================================================
Running tests for subproject-2 (/path/to/monorepo/subproject-2)
======================================================================= test session starts =======================================================================
platform linux -- Python 3.8.13, pytest-8.1.1, pluggy-1.5.0
rootdir: /path/to/monorepo/subproject-2
configfile: pyproject.toml
collected 0 items
====================================================================== no tests ran in 0.00s ======================================================================
Running tests for subproject-1 (/path/to/monorepo/subproject-1)
======================================================================= test session starts =======================================================================
platform linux -- Python 3.8.13, pytest-8.1.1, pluggy-1.5.0
rootdir: /path/to/monorepo/subproject-1
configfile: pyproject.toml
collected 1 item
tests/test_init.py . [100%]
======================================================================== 1 passed in 0.02s ========================================================================
Suggested Output
Tests should be executed only for the subprojects within the monorepo, excluding the parent virtual project.
Proposed Solution
Implement a configuration option to exclude the parent virtual project from test runs. This could be set at the base project level and could default to excluding the parent project.
Expected Output (Suggested)
When running rye test --all
, tests should be executed only for the subprojects within the monorepo, excluding the parent virtual project. The output should reflect this exclusion.
Running tests for subproject-2 (/path/to/monorepo/subproject-2)
======================================================================= test session starts =======================================================================
platform linux -- Python 3.8.13, pytest-8.1.1, pluggy-1.5.0
rootdir: /path/to/monorepo/subproject-2
configfile: pyproject.toml
collected 0 items
====================================================================== no tests ran in 0.00s ======================================================================
Running tests for subproject-1 (/path/to/monorepo/subproject-1)
======================================================================= test session starts =======================================================================
platform linux -- Python 3.8.13, pytest-8.1.1, pluggy-1.5.0
rootdir: /path/to/monorepo/subproject-1
configfile: pyproject.toml
collected 1 item
tests/test_init.py . [100%]
======================================================================== 1 passed in 0.02s ========================================================================
I believe implementing this change would improve the efficiency and clarity of test runs in monorepo setups using Rye.
Thank you for considering this suggestion.
Best regards, Adrián
I think you are right, that would be nice!
I have a fix for this in #858 but it seems the issue is also for other command such as lint
as per #973