| # 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. |
| |
| from PB.go.chromium.org.luci.cq.api.config.v2 import cq as config_pb2 |
| from recipe_engine import recipe_api |
| |
| |
| class CommitQueueApi(recipe_api.RecipeApi): |
| """Module for polling parsing commit-queue.cfg.""" |
| |
| def __init__(self, *args, **kwargs): |
| super(CommitQueueApi, self).__init__(*args, **kwargs) |
| self._cfg = None |
| |
| def _load(self, project): |
| if not self._cfg: |
| self._cfg = self.m.luci_config.commit_queue(project=project) |
| |
| def all_tryjobs( |
| self, |
| project=None, |
| include_experimental=False, |
| include_public=True, |
| include_private=False, |
| ): |
| self._load(project) |
| |
| builders = set() |
| if self._cfg: |
| for group in self._cfg.config_groups: |
| for builder in group.verifiers.tryjob.builders: |
| if ( |
| not include_public |
| and builder.result_visibility |
| != config_pb2.COMMENT_LEVEL_RESTRICTED |
| ): |
| continue |
| if ( |
| not include_private |
| and builder.result_visibility |
| == config_pb2.COMMENT_LEVEL_RESTRICTED |
| ): |
| continue |
| |
| if not include_experimental and ( |
| builder.experiment_percentage or builder.includable_only |
| ): |
| continue |
| |
| builders.add(builder.name) |
| |
| builders = sorted(builders) |
| step = self.m.step("all tryjobs", None) |
| step.presentation.logs["tryjobs"] = builders |
| return builders |