Skip to content

Commit

Permalink
Show tier in buildbot failure message (#583)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk authored Mar 1, 2025
1 parent c1892be commit 6ab531a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
27 changes: 26 additions & 1 deletion master/custom/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
# Tier-2 builder.
UNSTABLE = "unstable"

# https://peps.python.org/pep-0011/ defines Platfom Support Tiers
# https://peps.python.org/pep-0011/ defines Platform Support Tiers
TIER_1 = "tier-1"
TIER_2 = "tier-2"
TIER_3 = "tier-3"
Expand Down Expand Up @@ -331,6 +331,31 @@ def get_builders(settings):
return all_builders


def get_builder_tier(builder: str) -> str:
# Strip trailing branch name
import re
builder = re.sub(r" 3\.[x\d]+$", "", builder)

for builders, tier in (
(STABLE_BUILDERS_TIER_1, TIER_1),
(STABLE_BUILDERS_TIER_2,TIER_2),
(STABLE_BUILDERS_TIER_3, TIER_3),
(STABLE_BUILDERS_NO_TIER, NO_TIER),
(UNSTABLE_BUILDERS_TIER_1, TIER_1),
(UNSTABLE_BUILDERS_TIER_2, TIER_2),
(UNSTABLE_BUILDERS_TIER_3, TIER_3),
(UNSTABLE_BUILDERS_NO_TIER, NO_TIER),
):
for name, _, _ in builders:
if name == builder:
if tier == NO_TIER:
return "no tier"
else:
return tier

return "unknown tier"


# Match builder name (excluding the branch name) of builders that should only
# run on the main and PR branches.
ONLY_MAIN_BRANCH = (
Expand Down
7 changes: 5 additions & 2 deletions master/custom/discord_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
from buildbot.plugins import reporters
from buildbot.reporters.utils import getDetailsForBuild

from custom.builders import get_builder_tier
from custom.testsuite_utils import get_logs_and_tracebacks_from_build

MESSAGE = """\
:warning: **Buildbot failure** :warning:
The buildbot **{buildername}** has failed when building commit {sha}(https://github.com/python/cpython/commit/{sha}).
The buildbot **{buildername}** ({tier}) has failed when building commit {sha}(https://github.com/python/cpython/commit/{sha}).
You can take a look at the buildbot page here:
Expand Down Expand Up @@ -149,9 +150,11 @@ def createReport(
sha,
logs,
):
buildername = build["builder"]["name"]

message = MESSAGE.format(
buildername=build["builder"]["name"],
buildername=buildername,
tier=get_builder_tier(buildername),
build_url=self._getURLForBuild(
build["builder"]["builderid"], build["number"]
),
Expand Down
7 changes: 5 additions & 2 deletions master/custom/pr_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
from buildbot.plugins import reporters
from buildbot.reporters.utils import getDetailsForBuild

from custom.builders import get_builder_tier
from custom.testsuite_utils import get_logs_and_tracebacks_from_build

PR_MESSAGE = """\
:warning::warning::warning: Buildbot failure :warning::warning::warning:
------------------------------------------------------------------------
Hi! The buildbot **{buildername}** has failed when building commit {sha}.
Hi! The buildbot **{buildername}** ({tier}) has failed when building commit {sha}.
What do you need to do:
Expand Down Expand Up @@ -212,9 +213,11 @@ def createStatus(
tracebacks=None,
logs=None,
):
buildername = build["builder"]["name"]

message = PR_MESSAGE.format(
buildername=build["builder"]["name"],
buildername=buildername,
tier=get_builder_tier(buildername),
build_url=self._getURLForBuild(
build["builder"]["builderid"], build["number"]
),
Expand Down

0 comments on commit 6ab531a

Please sign in to comment.