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

fix: include GHA run link in more bot messages #781

Merged
merged 4 commits into from
Nov 21, 2024
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
10 changes: 6 additions & 4 deletions conda_forge_webservices/github_actions_integration/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,9 @@ def main_finalize_task(task_data_dir):
task_results["lint_error"] = True

if task_results["lint_error"]:
run_link = get_gha_run_link()
_message = dedent_with_escaped_continue(
"""
f"""
Hi! This is the friendly automated conda-forge-linting service.

I failed to even lint the recipe, probably because of a \\
Expand All @@ -451,13 +452,14 @@ def main_finalize_task(task_data_dir):
though. To get a traceback to help figure out what's going on, \\
install conda-smithy and run \\
`conda smithy recipe-lint --conda-forge .` from the recipe \\
directory.
directory. You can also examine the [workflow logs]({run_link}) \\
for more detail.
"""
)
run_link = get_gha_run_link()
_message += (
"\n\n<sub>This message was generated by "
f"GitHub actions workflow run [{run_link}]({run_link}).</sub>\n"
f"GitHub Actions workflow run [{run_link}]({run_link}). "
"Examine the logs at this URL for more detail.</sub>\n"
)
msg = make_lint_comment(gh_repo, pr.number, _message)
status = "bad"
Expand Down
18 changes: 15 additions & 3 deletions conda_forge_webservices/github_actions_integration/linting.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import time

from .utils import dedent_with_escaped_continue
from .utils import dedent_with_escaped_continue, get_gha_run_link


def get_recipes_for_linting(gh, repo, pr_id, lints, hints):
Expand Down Expand Up @@ -108,7 +108,7 @@ def build_and_make_lint_comment(gh, repo, pr_id, lints, hints):
have a merge conflict. Please try to merge or rebase with the base \\
branch to resolve this conflict.

Please ping the 'conda-forge/core' team (using the @ notation in a \\
Please ping the 'conda-forge/core' team (using the `@` notation in a \\
comment) if you believe this is a bug.
""",
)
Expand Down Expand Up @@ -150,6 +150,8 @@ def build_and_make_lint_comment(gh, repo, pr_id, lints, hints):
# Put the recipes in the form "```recipe/a```, ```recipe/b```".
recipe_code_blocks = ", ".join(f"```{r}```" for r in linted_recipes)

run_link = get_gha_run_link()

good = dedent_with_escaped_continue(
f"""
Hi! This is the friendly automated conda-forge-linting service.
Expand All @@ -170,6 +172,11 @@ def build_and_make_lint_comment(gh, repo, pr_id, lints, hints):
"""
).format("\n".join(messages))
)
mixed += (
"\n\n<sub>This message was generated by "
f"GitHub Actions workflow run [{run_link}]({run_link}). "
"Examine the logs at this URL for more detail.</sub>\n"
)

bad = dedent_with_escaped_continue(
f"""
Expand All @@ -183,14 +190,19 @@ def build_and_make_lint_comment(gh, repo, pr_id, lints, hints):
{{}}
"""
).format("\n".join(messages))
bad += (
"\n\n<sub>This message was generated by "
f"GitHub Actions workflow run [{run_link}]({run_link}). "
"Examine the logs at this URL for more detail.</sub>\n"
)

if not all_recipes:
message = dedent_with_escaped_continue(
"""
Hi! This is the friendly automated conda-forge-linting service.

I was trying to look for recipes to lint for you, but couldn't find any.
Please ping the 'conda-forge/core' team (using the @ notation in a \\
Please ping the 'conda-forge/core' team (using the `@` notation in a \\
comment) if you believe this is a bug.
""",
)
Expand Down
10 changes: 6 additions & 4 deletions conda_forge_webservices/github_actions_integration/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ def comment_and_push_if_changed(
Hi! This is the friendly automated conda-forge-webservice.

I tried to {action} for you but ran into some issues. \\
Please check the output logs of the GitHub actions workflow \\
below for more details. You can also ping conda-forge/core \\
for further assistance{help_message}.
Please check the [output logs]({run_link}) of the \\
GitHub Actions workflow \\
below for more details. You can also ping `conda-forge/core` \\
(using the `@` notation) for further assistance{help_message}.
""")
else:
message = dedent_with_escaped_continue(f"""
Expand All @@ -134,7 +135,8 @@ def comment_and_push_if_changed(
if run_link is not None:
message += (
"\n\n<sub>This message was generated by "
f"GitHub actions workflow run [{run_link}]({run_link}).</sub>\n"
f"GitHub Actions workflow run [{run_link}]({run_link}). "
"Examine the logs at this URL for more detail.</sub>\n"
)

pull.create_issue_comment(message)
Expand Down
4 changes: 2 additions & 2 deletions conda_forge_webservices/linting.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def lint_all_recipes(all_recipe_dir: Path, base_recipes: list[Path]) -> tuple[st
Hi! This is the friendly automated conda-forge-linting service.

I was trying to look for recipes to lint for you, but couldn't find any.
Please ping the 'conda-forge/core' team (using the @ notation in a comment) if you believe this is a bug.
Please ping the 'conda-forge/core' team (using the `@` notation in a comment) if you believe this is a bug.
""") # noqa
status = "no recipes"
elif all_pass and hints_found:
Expand Down Expand Up @@ -269,7 +269,7 @@ def compute_lint_message(
I was trying to look for recipes to lint for you, but it appears we have a merge conflict.
Please try to merge or rebase with the base branch to resolve this conflict.

Please ping the 'conda-forge/core' team (using the @ notation in a comment) if you believe this is a bug.
Please ping the 'conda-forge/core' team (using the `@` notation in a comment) if you believe this is a bug.
""") # noqa
status = "merge_conflict"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_conflict_ok_recipe(skip_if_linting_via_gha):
I was trying to look for recipes to lint for you, but it appears we have a merge conflict.
Please try to merge or rebase with the base branch to resolve this conflict.

Please ping the 'conda-forge/core' team (using the @ notation in a comment) if you believe this is a bug.
Please ping the 'conda-forge/core' team (using the `@` notation in a comment) if you believe this is a bug.
""") # noqa

lint = compute_lint_message(
Expand All @@ -134,7 +134,7 @@ def test_conflict_2_ok_recipe(skip_if_linting_via_gha):
I was trying to look for recipes to lint for you, but it appears we have a merge conflict.
Please try to merge or rebase with the base branch to resolve this conflict.

Please ping the 'conda-forge/core' team (using the @ notation in a comment) if you believe this is a bug.
Please ping the 'conda-forge/core' team (using the `@` notation in a comment) if you believe this is a bug.
""") # noqa

lint = compute_lint_message(
Expand Down Expand Up @@ -220,7 +220,7 @@ def test_no_recipe(skip_if_linting_via_gha):
Hi! This is the friendly automated conda-forge-linting service.

I was trying to look for recipes to lint for you, but couldn't find any.
Please ping the 'conda-forge/core' team (using the @ notation in a comment) if you believe this is a bug.
Please ping the 'conda-forge/core' team (using the `@` notation in a comment) if you believe this is a bug.
""") # noqa

lint = compute_lint_message(
Expand Down
8 changes: 4 additions & 4 deletions conda_forge_webservices/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def generate_app_token_for_webservices_only(app_id, raw_pem):
if "GITHUB_ACTIONS" in os.environ and os.environ["GITHUB_ACTIONS"] == "true":
sys.stdout.flush()
print(
"running in github actions",
"running in GitHub Actions",
flush=True,
)
print(f"::add-mask::{raw_pem}", flush=True)
Expand Down Expand Up @@ -157,7 +157,7 @@ def generate_app_token_for_webservices_only(app_id, raw_pem):
gh_token = integration.get_access_token(installation.id).token
if "GITHUB_ACTIONS" in os.environ and os.environ["GITHUB_ACTIONS"] == "true":
sys.stdout.flush()
print("made GITHUB token and masking it for github actions", flush=True)
print("made GITHUB token and masking it for GitHub Actions", flush=True)
print(f"::add-mask::{gh_token}", flush=True)

except Exception:
Expand Down Expand Up @@ -350,7 +350,7 @@ def generate_app_token_for_feedstock(app_id, raw_pem, repo, readonly=False):
if "GITHUB_ACTIONS" in os.environ and os.environ["GITHUB_ACTIONS"] == "true":
sys.stdout.flush()
print(
"running in github actions",
"running in GitHub Actions",
flush=True,
)
print(f"::add-mask::{raw_pem}", flush=True)
Expand Down Expand Up @@ -417,7 +417,7 @@ def generate_app_token_for_feedstock(app_id, raw_pem, repo, readonly=False):

if "GITHUB_ACTIONS" in os.environ and os.environ["GITHUB_ACTIONS"] == "true":
sys.stdout.flush()
print("made GITHUB token and masking it for github actions", flush=True)
print("made GITHUB token and masking it for GitHub Actions", flush=True)
print(f"::add-mask::{gh_token}", flush=True)

except Exception:
Expand Down
Loading