Skip to content

Calculate PR-style diff #532

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

Merged
merged 5 commits into from
May 28, 2025

Conversation

stickperson
Copy link
Contributor

@stickperson stickperson commented Apr 21, 2025

Fixes #529

Copy link

End-to-end public repo

Admin commands cheatsheet:

  • /e2e (in approved PR review body): Trigger end-to-end tests on external contributions
  • /invite (in comment): Invite the author & admins to the end-to-end private repo

Copy link

github-actions bot commented Apr 21, 2025

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  coverage_comment
  coverage.py
Project Total  

This report was generated by python-coverage-comment-action

from coverage_comment import subprocess as subprocess_module


def test_get_added_lines(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't believe this is strictly necessary as it's more testing git than get_added_lines. I'm happy to take it out.

Copy link
Member

Choose a reason for hiding this comment

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

I'm good keeping it :)

Copy link
Member

@ewjoachim ewjoachim left a comment

Choose a reason for hiding this comment

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

I'll try to see why the CI is red.

Excellent job though !

import pytest


@pytest.fixture
Copy link
Member

Choose a reason for hiding this comment

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

This and below seems to be copied from test_main, right ?

Could you deduplicate it ? It's ok to move it here, but delete the corresponding copied code from test_main

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. Removed from test_main

Comment on lines 18 to 23
def _check_added_lines():
added_lines = coverage.get_added_lines(git, "main")

assert added_lines == {
relative_file_path: list(range(7, 13)) # Line numbers start at 1
}
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather add 2 duplicated lines inside the test than an inner function (so as to make tests as easy to read as possible)

Also, I believe it's ok if you make it a single line:

assert coverage.get_added_lines(git, "main") == {
    relative_file_path: list(range(7, 13))  # Line numbers start at 1
}

though that's your choice :)

from coverage_comment import subprocess as subprocess_module


def test_get_added_lines(
Copy link
Member

Choose a reason for hiding this comment

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

I'm good keeping it :)

Comment on lines +119 to +122
with:
# New lines are discovered by running a three-dot notation diff on base_ref...head. They must share a common
# ancestor. Setting fetch-depth to 1000 here should ensure that.
fetch-depth: 1000
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll look into the e2e tests to test this since I'm not entirely sure how the actions/checkout action handles this. I wonder if you can get away with not setting fetch_depth here since a git fetch is called later.

Copy link
Member

Choose a reason for hiding this comment

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

Oooooh, that's the comment I missed that caused the issue. I'm sorry @stickperson I completely missed that 😅

@ewjoachim
Copy link
Member

I've pushed a PR that fixes pre-commit that was broken, and it wasn't your fault.

Copy link
Member

@ewjoachim ewjoachim left a comment

Choose a reason for hiding this comment

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

/e2e

Copy link
Member

@ewjoachim ewjoachim left a comment

Choose a reason for hiding this comment

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

/e2e

@ewjoachim
Copy link
Member

ewjoachim commented May 5, 2025

I think if you rebase now, there's a good chance CI will be green :)

@ewjoachim
Copy link
Member

Hey there :) Still interested in getting this merged ?

@stickperson
Copy link
Contributor Author

Yes, apologies! I will take a look on Monday.

@ewjoachim
Copy link
Member

No need for apology :) , I was just worried it slipped your mind, but I'm very fine with a "move slow and don't break people" approach :D

@stickperson stickperson force-pushed the three-dot-comparison branch from 2519fe2 to 2e8dc23 Compare May 26, 2025 15:59
@stickperson stickperson force-pushed the three-dot-comparison branch from a0a9432 to c0575ea Compare May 26, 2025 16:06
@stickperson
Copy link
Contributor Author

Updated!

@ewjoachim ewjoachim merged commit 0abd69a into py-cov-action:main May 28, 2025
2 checks passed
@ewjoachim
Copy link
Member

ewjoachim commented Jun 4, 2025

It seems this PR is causing issues, it's probably my fault, but I'll revert for now.

#554

@ewjoachim
Copy link
Member

I'm working on reapplying this on #573

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.

Unrelated files may appear in comment
2 participants