Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ Note: Either `GITHUB_PR_NUMBER` or `GITHUB_REF` is required. `GITHUB_PR_NUMBER`

## Optional Environment Variables

- `SUBPROJECT_ID`: The ID or URL of the subproject or report.
- `MINIMUM_GREEN`: The minimum coverage percentage for green status. Default is 100.
- `MINIMUM_ORANGE`: The minimum coverage percentage for orange status. Default is 70.
- `BRANCH_COVERAGE`: Show branch coverage in the report. Default is False.
Expand Down
1 change: 0 additions & 1 deletion codecov/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class Config:
# Branch to create the comment on (alternate to get PR number if not provided)
# Example Organisation:branch-name (Company:sample-branch) or User:branch-name (user:sample-branch)
GITHUB_REF: str | None = None
SUBPROJECT_ID: str | None = None # Deprecated
MINIMUM_GREEN: decimal.Decimal = decimal.Decimal('100')
MINIMUM_ORANGE: decimal.Decimal = decimal.Decimal('70')
TEST_FRAMEWORK: TestFramework = TestFramework.PYTEST
Expand Down
6 changes: 1 addition & 5 deletions codecov/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self):
self._init_log()
self.github = self._init_github()
self.coverage_module = self._init_coverage_module()
self.marker: str = self._init_marker()
self.marker: str = template.MARKER
self.comment: str = ''
self.coverage: PytestCoverage | JestCoverage
self.diff_coverage: DiffCoverage
Expand Down Expand Up @@ -48,9 +48,6 @@ def _init_coverage_module(self) -> BaseCoverageHandler:
log.error('Error initializing coverage module. Please check the test framework and try again.')
raise CoreProcessingException from e

def _init_marker(self) -> str:
return template.get_marker(marker_id=self.config.SUBPROJECT_ID)

def run(self):
self._process_coverage()
self._render_comment_markdown()
Expand Down Expand Up @@ -105,7 +102,6 @@ def _render_comment_markdown(self) -> None:
self.github.pr_number,
self.github.base_ref,
self.marker,
subproject_id=self.config.SUBPROJECT_ID,
branch_coverage=self.config.BRANCH_COVERAGE,
complete_project_report=self.config.COMPLETE_PROJECT_REPORT,
coverage_report_url=self.config.COVERAGE_REPORT_URL,
Expand Down
6 changes: 1 addition & 5 deletions codecov/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
from codecov.log import log

# TODO: Move all the helpers to utils.py
MARKER = """<!-- This comment was generated by codecov{id_part} -->"""


def get_marker(marker_id: str | None):
return MARKER.format(id_part=f' (id: {marker_id})' if marker_id else '')
MARKER = """<!-- This comment was generated by codecov -->"""


def pluralize(number, singular='', plural='s'):
Expand Down
2 changes: 1 addition & 1 deletion codecov/template_files/comment.md.j2
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

{%- block footer %}
<sub>
This report was generated by <a href="{%- if subproject_id %}{{ subproject_id }}{%- endif -%}">[codecov]</a>
This report was generated by <strong>codecov</strong>
</sub>
{% endblock footer -%}
{{ marker -}}
2 changes: 0 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def test_config_from_environ_sample():
'GITHUB_TOKEN': token,
'GITHUB_PR_NUMBER': '123',
'GITHUB_REF': 'main',
'SUBPROJECT_ID': 'your_subproject_id',
'MINIMUM_GREEN': '90',
'MINIMUM_ORANGE': '70',
'SKIP_COVERAGE': 'False',
Expand All @@ -68,7 +67,6 @@ def test_config_from_environ_sample():
GITHUB_TOKEN=token, # noqa: S106
GITHUB_PR_NUMBER=123,
GITHUB_REF='main',
SUBPROJECT_ID='your_subproject_id',
MINIMUM_GREEN=decimal.Decimal('90'),
MINIMUM_ORANGE=decimal.Decimal('70'),
SKIP_COVERAGE=False,
Expand Down
15 changes: 0 additions & 15 deletions tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,6 @@ def test_pluralize(number, singular, plural, expected):
assert template.pluralize(number=number, singular=singular, plural=plural) == expected


@pytest.mark.parametrize(
'marker_id, result',
[
(None, '<!-- This comment was generated by codecov -->'),
(
'foo',
'<!-- This comment was generated by codecov (id: foo) -->',
),
],
)
def test_get_marker(marker_id, result):
assert template.get_marker(marker_id=marker_id) == result


def test_template_no_marker(coverage_obj, diff_coverage_obj):
with pytest.raises(MissingMarker):
marker = '<!-- foobar -->'
Expand Down Expand Up @@ -234,7 +220,6 @@ def test_template_no_files(coverage_obj):
coverage_files=[],
count_coverage_files=0,
max_files=25,
subproject_id='foo',
)
assert '_This PR does not include changes to coverable code or code with missing coverage.' in result
assert 'code.py' not in result
Expand Down
Loading