Skip to content

Commit

Permalink
Slugify branch names in patchwork report
Browse files Browse the repository at this point in the history
patchwork only accepts ASCII letters, numbers, underscores or hyphens in
slugs. Let's replace "." in the branch name, for example md-6.10, with
"_", i.e. md-6_10.

Signed-off-by: Song Liu <[email protected]>
  • Loading branch information
liu-song-6 committed May 15, 2024
1 parent e7f53a1 commit a9a22ca
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions kernel_patches_daemon/branch_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,15 @@ def _is_outdated_pr(pr: PullRequest) -> bool:


class BranchWorker(GithubConnector):
@staticmethod
def slugify_context(s: str):
# According to patchwork rule:
# https://github.com/getpatchwork/patchwork/blob/2aa4742ec88be4cd07f569805d22a35c08a08f40/releasenotes/notes/slugify-check-context-dc586f204b5058a7.yaml
# the context need to be a slug, or a string consisting of only
# ASCII letters, numbers, underscores or hyphens.
# Lets replace all "." with "_"
return s.replace(".", "_")

def __init__(
self,
patchwork: Patchwork,
Expand Down Expand Up @@ -958,7 +967,7 @@ async def sync_checks(self, pr: PullRequest, series: Series) -> None:
# cached state).
pr.update()
# if it's merge conflict - report failure
ctx = f"{CI_DESCRIPTION}-{self.repo_branch}"
ctx = BranchWorker.slugify_context(f"{CI_DESCRIPTION}-{self.repo_branch}")
if _is_pr_flagged(pr):
await series.set_check(
status=Status.CONFLICT,
Expand Down Expand Up @@ -1031,7 +1040,7 @@ async def sync_checks(self, pr: PullRequest, series: Series) -> None:
series.set_check(
status=gh_conclusion_to_status(job.conclusion),
target_url=job.html_url,
context=f"{ctx}-{CI_VMTEST_NAME}-{idx}",
context=BranchWorker.slugify_context(f"{ctx}-{CI_VMTEST_NAME}-{idx}"),
description=f"Logs for {job.name}",
)
for idx, job in enumerate(jobs)
Expand Down

0 comments on commit a9a22ca

Please sign in to comment.