From 17a6932be78b3a03baebeb4ca32f23d49bf54bf5 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Sat, 11 Jan 2020 14:10:26 -0500 Subject: [PATCH] Improve check_system_templates() for zuul.d/projects.yaml All projects, that are gated, need to have the system-required template. Signed-off-by: Paul Belanger --- tools/zuul-projects-checks.py | 37 ++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/tools/zuul-projects-checks.py b/tools/zuul-projects-checks.py index da9d16e6..8cc520d1 100755 --- a/tools/zuul-projects-checks.py +++ b/tools/zuul-projects-checks.py @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import re import sys import yaml @@ -47,6 +48,39 @@ def check_projects_sorted(): return errors +def check_system_templates(): + """Check that each repo has a system-required template.""" + + errors = False + print("\nChecking for usage of system-required") + print("=====================================") + for entry in projects: + project = entry['project'] + name = project['name'] + # By default, projects under github.com/ansible-network have + # system-template applied + if re.match("^github.com/ansible-(network|security)/.*", name): + continue + # TODO(pabelanger): We need to make this more dynamic. + if re.match("^github.com/ansible/ansible", name): + continue + try: + correct = False + for template in project['templates']: + if template == 'system-required': + correct = True + if not correct: + raise + except Exception: + print("ERROR: Project %s has no system-required template" % + project['name']) + errors = True + + if not errors: + print("... all fine.") + return errors + + def check_release_jobs(): """Minimal release job checks.""" @@ -172,7 +206,8 @@ def check_only_boilerplate(): def check_all(): - errors = check_projects_sorted() + errors = check_system_templates() + errors = check_projects_sorted() or errors errors = blacklist_jobs() or errors errors = check_release_jobs() or errors errors = check_voting() or errors