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

feat: add --srcdir option #306

Merged
merged 1 commit into from
Jul 20, 2021
Merged

Conversation

i386x
Copy link
Contributor

@i386x i386x commented Jun 28, 2021

When the repository of Python project on GitHub has the structure

/myproject
    /src
        /myproject
            __init__.py
            somefile.py
    /docs
        ...
    /tests
        ...
    README.md
    tox.ini
    ...

and CI runs tox where tox.ini has set usedevelop = false and it runs tests with pytest --cov=myproject --cov-report=term-missing tests, where myproject refers to myproject package build and installed by tox, the coverage report will look like this:

----------- coverage: platform linux, python 3.6.8-final-0 -----------
Name                                                          Stmts   Miss  Cover   Missing
------------------------------------------------------------------------------------------------
.tox/py36/lib/python3.6/site-packages/myproject/__init__.py       1      0   100%
.tox/py36/lib/python3.6/site-packages/myproject/somefile.py       2      0   100%
------------------------------------------------------------------------------------------------
TOTAL                                                             3      0   100%

The .tox/py36/lib/python3.6/site-packages can be stripped by recently introduced --basedir option. This pull request introduces --srcdir option that specify the package source directory after --basedir option is applied. With this feature, coveralls.io is able to display the content of project files correctly. To demonstrate it:

coveralls

reports the above coverage report to coveralls.io, but since .tox/py36/lib/python3.6/site-packages/myproject/__init__.py is not a valid path on GitHub, coveralls.io displays no coverage details for __init__.py. Running the coveralls as

coveralls --basedir=.tox/py36/lib/python3.6/site-packages --srcdir=src

do the trick and the coverage details for __init__.py are visible in coveralls.io web UI, since src/myproject/__init__.py is an existing path on GitHub repository.

Together with --basedir option, this feature allows to fix paths of
reported files so coveralls.io is able to find the source at GitHub.
@i386x i386x requested a review from TheKevJames as a code owner June 28, 2021 19:53
Copy link
Owner

@TheKevJames TheKevJames left a comment

Choose a reason for hiding this comment

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

@i386x thanks for the contribution! I appreciate the in-depth description; that use-case makes perfect sense to me.

Your implementation LGTM, I'll get this released as soon as I can!

@TheKevJames TheKevJames merged commit 4120c54 into TheKevJames:master Jul 20, 2021
andy-maier pushed a commit to andy-maier/coveralls-python that referenced this pull request Dec 23, 2022
Together with --basedir option, this feature allows to fix paths of
reported files so coveralls.io is able to find the source at GitHub.
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

Successfully merging this pull request may close these issues.

2 participants