Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excluding parent virtual project from rye test --all run in monorepo setup #1037

Open
abaenaDSET opened this issue Apr 23, 2024 · 2 comments

Comments

@abaenaDSET
Copy link

abaenaDSET commented Apr 23, 2024

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

@RotaN8
Copy link

RotaN8 commented May 14, 2024

I think you are right, that would be nice!

@hyyking
Copy link
Contributor

hyyking commented May 25, 2024

I have a fix for this in #858 but it seems the issue is also for other command such as lint as per #973

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants