Skip to content

Conversation

0saurabh0
Copy link
Contributor

@0saurabh0 0saurabh0 commented Aug 25, 2025

Part of GSoC'25

ticket-36620

This PR adds a new GitHub Actions workflow i.e. coverage.yml for testing coverage reporting with diff-cover analysis.

What it does:

  • Runs coverage analysis on PRs (excluding docs/markdown changes)
  • Generates diff coverage reports for changed lines
  • Posts coverage comments on PRs (updating previous comments on every new commit)
  • Keeps main CI unaffected while trialing coverage features

Links:

Implementation:

  • Single workflow file with minimal permissions
  • Concurrency control to prevent duplicate runs
  • Non-blocking coverage warnings only

Checklist

  • This PR targets the main branch.
  • The commit message is written in past tense, mentions the ticket number, and ends with a period.
  • I have checked the "Has patch" ticket flag in the Trac system.
  • I have added or updated relevant tests.
  • I have added or updated relevant docs, including release notes if applicable.
  • I have attached screenshots in both light and dark modes for any UI changes.

@github-actions github-actions bot added the no ticket Based on PR title, no linked Trac ticket label Aug 25, 2025
@sarahboyce sarahboyce changed the title Added coverage workflow for test coverage Fixed #36620 -- Added coverage workflow to comment coverage summary. Sep 30, 2025
@github-actions github-actions bot removed the no ticket Based on PR title, no linked Trac ticket label Sep 30, 2025
Copy link
Contributor

@sarahboyce sarahboyce left a comment

Choose a reason for hiding this comment

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

Thank you for the PR

In the forum I recently mentioned that I think it's worth adding some information on this in our contributing docs

Perhaps we should update the existing code coverage docs in the contributing section to add information on this GitHub action: https://docs.djangoproject.com/en/5.2/internals/contributing/writing-code/unit-tests/#code-coverage

@@ -0,0 +1,102 @@
name: Coverage (Trial)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
name: Coverage (Trial)
name: Coverage

Comment on lines +5 to +7
paths-ignore:
- 'docs/**'
- '**/*.md'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
paths-ignore:
- 'docs/**'
- '**/*.md'
paths:
- 'django/**/*.py'

perhaps

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wouldn't it make the workflow much more restrictive?
It would miss legitimate triggers where coverage behavior might change (e.g., adding new test utilities, updating dependencies, modifying test configuration)?

}

- name: Post/update PR comment
if: success() && github.event_name == 'pull_request_target'
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the workflow_dispatch event? If we remove that would we be able to simplify this?

@0saurabh0
Copy link
Contributor Author

Thanks for the points, will update as soon as I can.

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