diff --git a/master/custom/builders.py b/master/custom/builders.py index d020b750..f2d4812a 100644 --- a/master/custom/builders.py +++ b/master/custom/builders.py @@ -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" @@ -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 = ( diff --git a/master/custom/discord_reporter.py b/master/custom/discord_reporter.py index 6cd4c8ee..535730df 100644 --- a/master/custom/discord_reporter.py +++ b/master/custom/discord_reporter.py @@ -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: @@ -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"] ), diff --git a/master/custom/pr_reporter.py b/master/custom/pr_reporter.py index 86e51fe7..3e2fd8ad 100644 --- a/master/custom/pr_reporter.py +++ b/master/custom/pr_reporter.py @@ -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: @@ -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"] ),