Skip to content
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

Move feedback link out of footer section and always include at the bottom of a comment #91

Merged
merged 1 commit into from
Sep 7, 2023
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
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
Loading