Skip to content

Commit

Permalink
Merge branch 'main' into 359-adjust-monthly-upload-limit-for-trialled…
Browse files Browse the repository at this point in the history
…-customers
  • Loading branch information
adrian-codecov authored Sep 7, 2023
2 parents 20c5433 + b360665 commit 17c53d1
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 72 deletions.
22 changes: 22 additions & 0 deletions services/notification/notifiers/mixins/message/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ async def create_message(
section_writer,
)

await self._write_feedback_link(comparison, settings, write)

return [m for m in message if m is not None]

async def _possibly_write_gh_app_login_announcement(
Expand All @@ -172,6 +174,26 @@ async def _possibly_write_gh_app_login_announcement(
write(f":exclamation: {message_to_display}")
write("")

async def _write_feedback_link(
self, comparison: ComparisonProxy, settings: dict, write: Callable
):
hide_project_coverage = settings.get("hide_project_coverage", False)
if hide_project_coverage:
write(
":loudspeaker: Thoughts on this report? [Let us know!]({0}).".format(
"https://about.codecov.io/pull-request-comment-report/"
)
)
else:
repo_service = comparison.repository_service.service
write(
":loudspeaker: Have feedback on the report? [Share it here]({0}).".format(
"https://gitlab.com/codecov-open-source/codecov-user-feedback/-/issues/4"
if repo_service == "gitlab"
else "https://about.codecov.io/codecov-pr-comment-feedback/"
)
)

async def write_section_to_msg(
self, comparison, changes, diff, links, write, section_writer, behind_by=None
):
Expand Down
17 changes: 1 addition & 16 deletions services/notification/notifiers/mixins/message/sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,13 @@ async def write_section(*args, **kwargs):
class NewFooterSectionWriter(BaseSectionWriter):
async def do_write_section(self, comparison, diff, changes, links, behind_by=None):
hide_project_coverage = self.settings.get("hide_project_coverage", False)
if hide_project_coverage:
yield ("")
yield (
":loudspeaker: Thoughts on this report? [Let us know!]({0}).".format(
"https://about.codecov.io/pull-request-comment-report/"
)
)
else:
repo_service = comparison.repository_service.service
if not hide_project_coverage:
yield ("")
yield (
"[:umbrella: View full report in Codecov by Sentry]({0}?src=pr&el=continue). ".format(
links["pull"]
)
)
yield (
":loudspeaker: Have feedback on the report? [Share it here]({0}).".format(
"https://about.codecov.io/codecov-pr-comment-feedback/"
if repo_service == "github"
else "https://gitlab.com/codecov-open-source/codecov-user-feedback/-/issues/4"
)
)


class NewHeaderSectionWriter(BaseSectionWriter):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ async def test_notify(self, sample_comparison, codecov_vcr, mock_configuration):
"> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`",
"> Powered by [Codecov](https://app.codecov.io/gh/joseph-sentry/codecov-demo/pull/9?src=pr&el=footer). Last update [5b174c2...5601846](https://app.codecov.io/gh/joseph-sentry/codecov-demo/pull/9?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).",
"",
f":loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/).",
]
for exp, res in zip(result.data_sent["message"], message):
assert exp == res
Expand Down Expand Up @@ -523,6 +524,7 @@ async def test_notify_gitlab(
"> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`",
"> Powered by [Codecov](https://app.codecov.io/gl/joseph-sentry/example-python/pull/1?src=pr&el=footer). Last update [0fc784a...0b6a213](https://app.codecov.io/gl/joseph-sentry/example-python/pull/1?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).",
"",
f":loudspeaker: Have feedback on the report? [Share it here](https://gitlab.com/codecov-open-source/codecov-user-feedback/-/issues/4).",
]
for exp, res in zip(result.data_sent["message"], message):
assert exp == res
Expand Down Expand Up @@ -590,8 +592,8 @@ async def test_notify_new_layout(
"</details>",
"",
"[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/joseph-sentry/codecov-demo/pull/9?src=pr&el=continue). ",
":loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/).",
"",
":loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/).",
]
for exp, res in zip(result.data_sent["message"], message):
assert exp == res
Expand Down Expand Up @@ -670,8 +672,8 @@ async def test_notify_with_components(
"</details>",
"",
"[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/joseph-sentry/codecov-demo/pull/9?src=pr&el=continue). ",
":loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/).",
"",
":loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/).",
]
for exp, res in zip(result.data_sent["message"], message):
assert exp == res
Expand Down
3 changes: 3 additions & 0 deletions services/notification/notifiers/tests/unit/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,7 @@ async def test_build_default_payload(
f"",
f"... and [1 file with indirect coverage changes](test.example.br/gh/test_build_default_payload/{repo.name}/pull/{sample_comparison.pull.pullid}/indirect-changes?src=pr&el=tree-more)",
f"",
":loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/).",
]
),
},
Expand Down Expand Up @@ -1558,6 +1559,7 @@ async def test_build_default_payload_with_flags(
f"",
f"... and [1 file with indirect coverage changes](test.example.br/gh/test_build_default_payload_with_flags/{repo.name}/pull/{sample_comparison.pull.pullid}/indirect-changes?src=pr&el=tree-more)",
f"",
":loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/).",
]
),
},
Expand Down Expand Up @@ -1608,6 +1610,7 @@ async def test_build_default_payload_with_flags_and_footer(
f"> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`",
f"> Powered by [Codecov](test.example.br/gh/{test_name}/{repo.name}/pull/{sample_comparison.pull.pullid}?src=pr&el=footer). Last update [{base_commit.commitid[:7]}...{head_commit.commitid[:7]}](test.example.br/gh/{test_name}/{repo.name}/pull/{sample_comparison.pull.pullid}?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).",
f"",
":loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/).",
]
),
},
Expand Down
Loading

0 comments on commit 17c53d1

Please sign in to comment.