| # Copyright 2019 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import functools |
| |
| from PB.go.chromium.org.luci.cv.api.config.v2 import config as config_pb2 |
| from recipe_engine import recipe_api |
| |
| |
| class CommitQueueApi(recipe_api.RecipeApi): |
| """Module for polling parsing commit-queue.cfg.""" |
| |
| @functools.lru_cache(maxsize=None) |
| def _load(self, project, config_name=None): |
| return self.m.luci_config.commit_queue(project=project, config_name=config_name) |
| |
| def all_tryjobs( |
| self, |
| project=None, |
| include_experimental=False, |
| include_unrestricted=True, |
| include_restricted=False, |
| include_mode_allowlisted=False, |
| config_name=None, |
| ): |
| cfg = self._load(project, config_name=config_name) |
| |
| builders = set() |
| if cfg: |
| for group in cfg.config_groups: |
| for builder in group.verifiers.tryjob.builders: |
| if ( |
| not include_unrestricted |
| and builder.result_visibility |
| != config_pb2.COMMENT_LEVEL_RESTRICTED |
| ): |
| continue |
| if ( |
| not include_restricted |
| and builder.result_visibility |
| == config_pb2.COMMENT_LEVEL_RESTRICTED |
| ): |
| continue |
| |
| if not include_experimental and ( |
| builder.experiment_percentage or builder.includable_only |
| ): |
| continue |
| # Tricium analyzers are in a different bucket from other |
| # tryjobs, so we can't support launching them from the |
| # recipe_testing module until it supports launching builds |
| # in other buckets. |
| if not include_mode_allowlisted and builder.mode_allowlist: |
| continue |
| |
| builders.add(builder.name) |
| |
| builders = sorted(builders) |
| self.m.step.empty("all tryjobs").presentation.logs["tryjobs"] = builders |
| return builders |