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

use colcon option for pytest coverage instead of custom pytest-cov options #109

Merged
merged 8 commits into from
Jul 10, 2020

Conversation

mikaelarguedas
Copy link
Contributor

This results in the following pytest-args:

  • --cov=<PATH/TO/ROS/PACKAGE>
  • --cov-report=html:<PATH/TO/PKG/BUILD/DIR>/coverage.html
  • --cov-report=xml:<PATH/TO/PKG/BUILD/DIR>/coverage.xml
  • --cov-branch

https://github.com/colcon/colcon-core/blob/af7fa089962a9e9a35926734e17b00cfb4c780a6/colcon_core/task/python/test/pytest.py#L85-L100

The main advantage is that it prevents action-ros-ci to overwrite the output location of the coverage.xml (colcon places it in the build directory of the package) and to have branch coverage in the report.

Note: this needs colcon-core 0.5.1 so doesnt work as is as setup-ros pins colcon version to 0.4.3.
Should I open a separate issue to request a version bump of colcon packages in setup-ros?

@piraka9011
Copy link

piraka9011 commented Mar 19, 2020

Should I open a separate issue to request a version bump of colcon packages in setup-ros?

Yes but you will need to update the associated colcon extensions as well to make sure they are also compatible with the version you are pinning against.
They are minor version bumps but they do introduce breaking changes FYI.

@piraka9011
Copy link

The CI seems to be failing for a different reason...

Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com>
@mikaelarguedas mikaelarguedas force-pushed the pytest-coverage branch 2 times, most recently from 330463a to 50ba1e9 Compare April 1, 2020 14:13
@@ -32,7 +32,7 @@ jobs:
- run: npm ci
- run: npm run build

- uses: ros-tooling/setup-ros@0.0.16
- uses: mikaelarguedas/setup-ros@bump-colcon
Copy link
Member

Choose a reason for hiding this comment

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

You'll need to revert that now :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup! just wanted to get someone to witness it did pass CI before removing that commit ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Commit removed

@Arnatious
Copy link

This has been stale for about a month now, can we get this merged in? It's quite important for being able to get codecov results up.

@christophebedard
Copy link
Member

This is just a suggestion, but you could also use the coverage-pytest mixin: https://github.com/colcon/colcon-mixin-repository/blob/1ddb69bedfd1f04c2f000e95452f7c24a4d6176b/coverage.mixin#L14

@mikaelarguedas
Copy link
Contributor Author

mikaelarguedas commented Jun 30, 2020

Indeed I created the coverage-pytest mixin at the same time as this PR because I was not a fan of the way it was hard-coded in here.

I haven't tested recently but IIRC the fact that action-ros-ci hard-codes the pytest-cov parameters was still a problem even though there is a mixin for it.

I could update this PR to make use of the mixin by default, but given that this has been months approved and not merged for no apparent reason I'm not convinced it's worth the effort.

@mikaelarguedas
Copy link
Contributor Author

@emersonknapp @thomas-moulard is there anything I can do to get this over the line ?

@thomas-moulard
Copy link
Member

@mikaelarguedas thanks for the reminder, updated the branch, let's merge if the CI is OK.

@mikaelarguedas
Copy link
Contributor Author

2 jobs failed. They don't seem related to this change.
MacOS latest -> fail on vcs import
log_workflow_status_to_cloudwatch -> looks like a missing argument: Input required and not supplied: aws-region

@piraka9011
Copy link

@mikaelarguedas Now that #247 is in, are there any changes that need to be made to this?

@mikaelarguedas
Copy link
Contributor Author

Not that I know of. I'm not familiar with colcon-coveragepy-result but I would assume it picks up the coverage files inside the packages as well, @christophebedard would know more.

@christophebedard
Copy link
Member

Not that I know of. I'm not familiar with colcon-coveragepy-result but I would assume it picks up the coverage files inside the packages as well

Yep! It was made to work with the usual way(s) colcon and ament set up Python code coverage generation, so it's all good.

@piraka9011
Copy link

@christophebedard to clarify: All good as in no longer needed or all good as in this is still necessary? :)

It seems that colcon-coveragepy-result will pick up the coverage files so we don't need to specify them here.

@christophebedard
Copy link
Member

christophebedard commented Jul 9, 2020

@christophebedard to clarify: All good as in no longer needed or all good as in this is still necessary? :)

It seems that colcon-coveragepy-result will pick up the coverage files so we don't need to specify them here.

@piraka9011 sorry! Not sure what you mean by "don't need to specify them here," but this PR is still necessary. We still need to tell colcon to tell ament to generate Python code coverage using the default behaviour/settings. Otherwise, with the way it is set up without this PR, colcon-coveragepy-result won't be able to find the data.

@piraka9011 piraka9011 merged commit bbdb643 into ros-tooling:master Jul 10, 2020
@mikaelarguedas mikaelarguedas deleted the pytest-coverage branch July 10, 2020 20:27
jikawa-az pushed a commit that referenced this pull request Jul 22, 2020
Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com>
Signed-off-by: Jesse Ikawa <jikawa@amazon.com>
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.

7 participants