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

Links to files with dunder/double underscores are broken #118

Closed
icj217 opened this issue Feb 24, 2023 · 2 comments · Fixed by #121
Closed

Links to files with dunder/double underscores are broken #118

icj217 opened this issue Feb 24, 2023 · 2 comments · Fixed by #121

Comments

@icj217
Copy link

icj217 commented Feb 24, 2023

I noticed in testing out this action that links don't seem to work properly to files that contain dunders, e.g. __init__.py. See below for details.

My XML report shows the filenames correctly:

<?xml version="1.0" ?>
<coverage version="6.4.4" timestamp="1677247940858" lines-valid="4" lines-covered="3" line-rate="0.75" branches-valid="0" branches-covered="0" branch-rate="1" complexity="0">
	<!-- Generated by coverage.py: https://coverage.readthedocs.io -->
	<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
	<sources>
		<source>REDACTED</source>
	</sources>
	<packages>
		<package name="src.my_cool_lib" line-rate="0.75" branch-rate="1" complexity="0">
			<classes>
				<class name="__init__.py" filename="src/my_cool_lib/__init__.py" complexity="0" line-rate="1" branch-rate="1">
					<methods/>
					<lines>
						<line number="3" hits="1"/>
					</lines>
				</class>
				<class name="__main__.py" filename="src/my_cool_lib/__main__.py" complexity="0" line-rate="0" branch-rate="1">
					<methods/>
					<lines>
						<line number="2" hits="0"/>
					</lines>
				</class>
				<class name="example.py" filename="src/my_cool_lib/example.py" complexity="0" line-rate="1" branch-rate="1">
					<methods/>
					<lines>
						<line number="4" hits="1"/>
						<line number="11" hits="1"/>
					</lines>
				</class>
			</classes>
		</package>
	</packages>
</coverage>

And here's my action configuration:

- uses: MishaKav/pytest-coverage-comment@main
  with:
    title: Unit Test Coverage Report
    badge-title: Unit Test Coverage
    pytest-xml-coverage-path: reports/unittest-cov.xml
    junitxml-path: reports/unittest.xml

The comment is generated properly:

Screen Shot 2023-02-24 at 9 26 09 AM

But the links to the __init__.py and __main__.py are the following:

https://github.com/myorg/myrepo/blob/60330af0c8dd07545e84d15ae15405b6c408e969/src/my_cool_lib//_/_init/_/_.py
https://github.com/myorg/myrepo/blob/60330af0c8dd07545e84d15ae15405b6c408e969/src/my_cool_lib//_/_main/_/_.py

Oddly enough, the link to line 2 of __main__.py is correct:

https://github.com/myorg/myrepo/blob/60330af0c8dd07545e84d15ae15405b6c408e969/src/my_cool_lib/__main__.py#L2
@MishaKav
Copy link
Owner

Thanks for the detailed example, I will check the issue and provide a fix soon.

@MishaKav MishaKav linked a pull request Mar 3, 2023 that will close this issue
@MishaKav
Copy link
Owner

MishaKav commented Mar 3, 2023

I fix this bug, you can use:

- name: Pytest Coverage Comment
  uses: MishaKav/pytest-coverage-comment@main

or use a specific version

- name: Pytest Coverage Comment
  uses: MishaKav/pytest-coverage-comment@v1.1.46
  • The bug was that __ is used for italic text in markdown format, so I escape them all :)

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 a pull request may close this issue.

2 participants