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

feat: Link flag and component names in PR comment back to dashboard pages #61

Merged
merged 1 commit into from
Aug 14, 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
19 changes: 15 additions & 4 deletions services/notification/notifiers/mixins/message/sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,10 @@ async def do_write_section(self, comparison, diff, changes, links, behind_by=Non
+ ("---|" if has_carriedforward_flags else "")
)

yield ("| Flag " + table_header)
yield (
"| [Flag]({href}/flags?src=pr&el=flags) ".format(href=links["pull"])
+ table_header
)
yield (table_layout)
for flag in sorted(flags, key=lambda f: f["name"]):
carriedforward, carriedforward_from = (
Expand Down Expand Up @@ -660,7 +663,10 @@ async def do_write_section(self, comparison, diff, changes, links, behind_by=Non

yield (
"| {name} {metrics}{cf}".format(
name=flag["name"],
name="[{flag_name}]({href}/flags?src=pr&el=flag)".format(
flag_name=flag["name"],
href=links["pull"],
),
metrics=make_metrics(
flag["before"],
flag["after"],
Expand Down Expand Up @@ -721,13 +727,18 @@ async def do_write_section(
)

# Table header and layout
yield "| Components | Coverage \u0394 | |"
yield "| [Components]({href}/components?src=pr&el=components) | Coverage \u0394 | |".format(
href=links["pull"],
)
yield "|---|---|---|"
# The interesting part
for component_data in component_data_to_show:
yield (
"| {name} {metrics}".format(
name=component_data["name"],
name="[{component_name}]({href}/components?src=pr&el=component)".format(
component_name=component_data["name"],
href=links["pull"],
),
metrics=make_metrics(
component_data["before"],
component_data["after"],
Expand Down
34 changes: 17 additions & 17 deletions services/notification/notifiers/tests/integration/test_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,10 @@ async def test_notify(self, sample_comparison, codecov_vcr, mock_configuration):
"- Partials 0 1 +1 ",
"```",
"",
"| Flag | Coverage Δ | Complexity Δ | |",
"| [Flag](https://app.codecov.io/gh/ThiagoCodecov/example-python/pull/15/flags?src=pr&el=flags) | Coverage Δ | Complexity Δ | |",
"|---|---|---|---|",
"| integration | `?` | `?` | |",
"| unit | `100.00% <ø> (?)` | `0.00 <ø> (?)` | |",
"| [integration](https://app.codecov.io/gh/ThiagoCodecov/example-python/pull/15/flags?src=pr&el=flag) | `?` | `?` | |",
"| [unit](https://app.codecov.io/gh/ThiagoCodecov/example-python/pull/15/flags?src=pr&el=flag) | `100.00% <ø> (?)` | `0.00 <ø> (?)` | |",
"",
"Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.",
"",
Expand Down Expand Up @@ -431,7 +431,7 @@ async def test_notify_upload_limited(
):
mock_configuration._params["setup"] = {
"codecov_url": None,
"codecov_dashboard_url": "test.example.br",
"codecov_dashboard_url": "https://app.codecov.io",
}
comparison = sample_comparison_for_limited_upload
notifier = CommentNotifier(
Expand All @@ -447,10 +447,10 @@ async def test_notify_upload_limited(
assert result.notification_successful
assert result.explanation is None
expected_message = [
f"## [Codecov](test.example.br/plan/gh/test-acc9) upload limit reached :warning:",
f"## [Codecov](https://app.codecov.io/plan/gh/test-acc9) upload limit reached :warning:",
f"This org is currently on the free Basic Plan; which includes 250 free private repo uploads each rolling month.\
This limit has been reached and additional reports cannot be generated. For unlimited uploads,\
upgrade to our [pro plan](test.example.br/plan/gh/test-acc9).",
upgrade to our [pro plan](https://app.codecov.io/plan/gh/test-acc9).",
f"",
f"**Do you have questions or need help?** Connect with our sales team today at ` [email protected] `",
]
Expand Down Expand Up @@ -507,10 +507,10 @@ async def test_notify_gitlab(
"- Partials 0 1 +1 ",
"```",
"",
"| Flag | Coverage Δ | Complexity Δ | |",
"| [Flag](https://app.codecov.io/gl/joseph-sentry/example-python/pull/1/flags?src=pr&el=flags) | Coverage Δ | Complexity Δ | |",
"|---|---|---|---|",
"| integration | `?` | `?` | |",
"| unit | `100.00% <ø> (?)` | `0.00 <ø> (?)` | |",
"| [integration](https://app.codecov.io/gl/joseph-sentry/example-python/pull/1/flags?src=pr&el=flag) | `?` | `?` | |",
"| [unit](https://app.codecov.io/gl/joseph-sentry/example-python/pull/1/flags?src=pr&el=flag) | `100.00% <ø> (?)` | `0.00 <ø> (?)` | |",
"",
"Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.",
"",
Expand Down Expand Up @@ -578,10 +578,10 @@ async def test_notify_new_layout(
"- Partials 0 1 +1 ",
"```",
"",
"| Flag | Coverage Δ | Complexity Δ | |",
"| [Flag](https://app.codecov.io/gh/ThiagoCodecov/example-python/pull/15/flags?src=pr&el=flags) | Coverage Δ | Complexity Δ | |",
"|---|---|---|---|",
"| integration | `?` | `?` | |",
"| unit | `100.00% <ø> (?)` | `0.00 <ø> (?)` | |",
"| [integration](https://app.codecov.io/gh/ThiagoCodecov/example-python/pull/15/flags?src=pr&el=flag) | `?` | `?` | |",
"| [unit](https://app.codecov.io/gh/ThiagoCodecov/example-python/pull/15/flags?src=pr&el=flag) | `100.00% <ø> (?)` | `0.00 <ø> (?)` | |",
"",
"Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.",
"",
Expand Down Expand Up @@ -653,18 +653,18 @@ async def test_notify_with_components(
"- Partials 0 1 +1 ",
"```",
"",
"| Flag | Coverage Δ | Complexity Δ | |",
"| [Flag](https://app.codecov.io/gh/codecove2e/example-python/pull/4/flags?src=pr&el=flags) | Coverage Δ | Complexity Δ | |",
"|---|---|---|---|",
"| integration | `?` | `?` | |",
"| unit | `100.00% <ø> (?)` | `0.00 <ø> (?)` | |",
"| [integration](https://app.codecov.io/gh/codecove2e/example-python/pull/4/flags?src=pr&el=flag) | `?` | `?` | |",
"| [unit](https://app.codecov.io/gh/codecove2e/example-python/pull/4/flags?src=pr&el=flag) | `100.00% <ø> (?)` | `0.00 <ø> (?)` | |",
"",
"Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more.",
"",
"[see 2 files with indirect coverage changes](https://app.codecov.io/gh/codecove2e/example-python/pull/4/indirect-changes?src=pr&el=tree-more)",
"",
"| Components | Coverage Δ | |",
"| [Components](https://app.codecov.io/gh/codecove2e/example-python/pull/4/components?src=pr&el=components) | Coverage Δ | |",
"|---|---|---|",
"| go_files | `62.50% <ø> (+12.50%)` | :arrow_up: |",
"| [go_files](https://app.codecov.io/gh/codecove2e/example-python/pull/4/components?src=pr&el=component) | `62.50% <ø> (+12.50%)` | :arrow_up: |",
"",
"</details>",
"",
Expand Down
Loading
Loading