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

[DPE-6042] Make tox commands resilient to white-space paths #678

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

sinclert-canonical
Copy link
Contributor

This PR fixes tox.ini commands when the repository is cloned on a white-space containing path. The proposed approach quotes the paths where they are defined (central place), instead of where they are used (distributed throughout the file). However, we could go with the other approach if preferred.

How to reproduce:

$ mkdir -p "Projects/Canonical/Data Platform/PostgreSQL"
$ cd "Projects/Canonical/Data Platform/PostgreSQL"
$ git clone https://github.com/canonical/postgresql-operator
$ cd postgresql-operator
$ tox run -e format
> ...
> /Users/<USERNAME>/Projects/Canonical/Data:1:1: E902 No such file or directory (os error 2)
> Platform/PostgreSQL/postgresql-operator/src:1:1: E902 No such file or directory (os error 2)
> Platform/PostgreSQL/postgresql-operator/tests:1:1: E902 No such file or directory (os error 2)

Additional considerations

Using the quoted paths to set up the PYTHONPATH does not work. This can be tested by running the unit tests.

References

Copy link

codecov bot commented Nov 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.40%. Comparing base (3f31bbf) to head (c74d66b).
Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #678   +/-   ##
=======================================
  Coverage   71.40%   71.40%           
=======================================
  Files          13       13           
  Lines        3189     3189           
  Branches      475      475           
=======================================
  Hits         2277     2277           
  Misses        797      797           
  Partials      115      115           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@sinclert-canonical sinclert-canonical marked this pull request as ready for review November 18, 2024 16:00
@sinclert-canonical sinclert-canonical changed the title Make tox commands resilient to white-space paths [DPE-6042] Make tox commands resilient to white-space paths Nov 18, 2024
Copy link
Member

@marceloneppel marceloneppel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, @sinclert-canonical! I saw that the unit tox environment still fails because it has another path variable in the following command:

poetry run coverage run --source={[vars]src_path} \
        -m pytest -v --tb native -s {posargs} {[vars]tests_path}/unit

@sinclert-canonical
Copy link
Contributor Author

I am confused. Both {[vars]src_path} and {[vars]tests_path} parts of the command are quoted already.

Running the unit test command locally, in this branch, works, as well as the CI job associated with this changes (reference). Could you share the CLI entry-point you are executing to that failure?

Copy link
Member

@marceloneppel marceloneppel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I believe that in one of my tests yesterday I probably forgot to checkout the PR branch again. Now it's working.

@sinclert-canonical
Copy link
Contributor Author

Thanks folks! Will go ahead and merge it.

Just FYI: I think this tiny fix could be applied to, literally, all the MySQL / PostgreSQL codebases. So, if you agree if the chosen approach, prepare for a myriad of tiny PRs 😄

@dragomirp
Copy link
Contributor

Just FYI: I think this tiny fix could be applied to, literally, all the MySQL / PostgreSQL codebases. So, if you agree if the chosen approach, prepare for a myriad of tiny PRs 😄

Yes, do you have a list of all the repos to tweak?

@sinclert-canonical sinclert-canonical merged commit 02367ec into main Nov 19, 2024
97 checks passed
@sinclert-canonical sinclert-canonical deleted the sinclert/quote-tox-paths branch November 19, 2024 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants