Skip to content

HelpersTask597_Configure_Codecov_for_coverage #598

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

Open
wants to merge 31 commits into
base: master
Choose a base branch
from

Conversation

Shaunak01
Copy link
Contributor

Issue: #597

@Shaunak01 Shaunak01 self-assigned this Apr 21, 2025
Copy link

codecov bot commented Apr 21, 2025

Codecov Report

Attention: Patch coverage is 19.56522% with 37 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
helpers/lib_tasks_pytest.py 19.56% 37 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Shaunak01 Shaunak01 requested review from dremdem and gpsaggese April 22, 2025 18:09
Copy link
Contributor

@dremdem dremdem left a comment

Choose a reason for hiding this comment

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

Good job.
Some comments.

@Shaunak01 Shaunak01 requested review from dremdem and gpsaggese April 24, 2025 21:15
Copy link
Contributor

@dremdem dremdem left a comment

Choose a reason for hiding this comment

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

Good job.
Some questions and comments.
I'd propose to make a doc with a pipeline explanation.
For readers and users with zero coverage and Codecov experience will be hard to figure out.

- name: Checkout code
uses: actions/checkout@v3
with:
submodules: true
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's change it to submodules: recursive to prepare for using it as a reusable workflow.

Comment on lines +113 to +114
# Scheduled for Monday (i.e Day 1) or when manually triggered.
if: (github.event_name == 'schedule' && env.DAY_OF_WEEK == '1') || github.event_name == 'workflow_dispatch'
Copy link
Contributor

Choose a reason for hiding this comment

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

It's looking a bit hackish. Let's add a TODO to consider removing it when we turn this workflow into a reusable one.

run: invoke run_superslow_coverage .

- name: Upload Superslow Test Coverage to Codecov
if: (github.event_name == 'schedule' && env.DAY_OF_WEEK == '1') || github.event_name == 'workflow_dispatch'
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd not duplicate the if here, just use
https://stackoverflow.com/questions/60453924/running-a-github-actions-step-only-if-previous-step-has-run

Something like:

  - name: Build app
    id: build
    run: |
      <build command>

  - name: Run tests

  - name: Create artifact of test coverage
    if: steps.build.outcome == 'success'

"""
Run coverage for a given suite (fast/slow/superslow).

:param suite: one of "fast" or "slow"
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add the superslow also.

:param generate_html_report: whether to produce HTML output
:return: xml file named 'coverage.xml'
"""

Copy link
Contributor

Choose a reason for hiding this comment

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

Linter?

hlitauti.run(ctx, test_cmd, use_system=False)
# Move the default ".coverage" file to our suite-specific filename.
hsystem.system(f"mv .coverage {coverage_file}")
hdbg.dassert_file_exists(coverage_file)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd check the existence of .coverage before renaming.

# Move the default ".coverage" file to our suite-specific filename.
hsystem.system(f"mv .coverage {coverage_file}")
hdbg.dassert_file_exists(coverage_file)
# Compute which files/dirs to include and omit in the report.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm lost. What report do you meant here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably it worth to split the pipeline to blocks with comments.

report_cmd: List[str] = [
# Clear out any prior coverage data.
"coverage erase",
# Combine this suite's data into the coverage database.
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, I'm puzzled. Why we need it?

# Export XML coverage report.
report_cmd.append("coverage xml -o coverage.xml")
full_report_cmd: str = " && ".join(report_cmd)
docker_cmd_ = f"invoke docker_cmd --use-bash --cmd '{full_report_cmd}'"
Copy link
Contributor

Choose a reason for hiding this comment

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

Dumb question: why we need to run it inside the Docker container?

return include_in_report, exclude_from_report


def _run_coverage(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we promote it to an invoke target and get rid of:

  • run_fast_coverage
  • run_slow_coverage
  • run_superslow_coverage
    WDYT?

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.

3 participants