Skip to content
This repository was archived by the owner on Jan 4, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 48 additions & 5 deletions tools/zuul-projects-checks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# Copyright 2017 SUSE Linux GmbH
#
Expand All @@ -14,11 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from pathlib import Path
import re
import sys
import yaml

projects_yaml = 'zuul.d/projects.yaml'
projects = yaml.safe_load(open(projects_yaml))
tenants = yaml.safe_load(Path("zuul/tenants.yaml").read_text())
projects = yaml.safe_load(Path("zuul.d/projects.yaml").read_text())
ansible_tenant = tenants[0]["tenant"]


def normalize(s):
Expand Down Expand Up @@ -170,18 +173,58 @@ def check_only_boilerplate():
return errors


def check_project_templates():

print("\nChecking that every project has entries")
print("======================")

untrusted_github_projects = ansible_tenant["source"]["github.com"][
"untrusted-projects"
]
github_projects = [
"github.com/" + i for i in untrusted_github_projects if type(i) == str
]

errors = False
for github_project in github_projects:
templates = []
for project in [i["project"] for i in projects]:
name = project["name"]
if name.startswith("^") and re.match(name, github_project):
templates += project.get("templates", [])
elif github_project == name:
templates += project.get("templates", [])
if not templates:
print(
"No template for project {github_project}".format(
github_project=github_project
)
)
errors = True
if "system-required" not in templates:
print(
(
"system-required template not enabled for "
"{github_project}"
).format(github_project=github_project)
)
errors = True
return errors


def check_all():

errors = check_projects_sorted()
errors = blacklist_jobs() or errors
errors = check_release_jobs() or errors
errors = check_voting() or errors
errors = check_only_boilerplate() or errors
errors = check_project_templates() or errors

if errors:
print("\nFound errors in zuul.d/projects.yaml!\n")
print("\nFound errors in zuul configuration!\n")
else:
print("\nNo errors found in zuul.d/projects.yaml!\n")
print("\nNo errors found in zuul configuration!\n")
return errors


Expand Down
13 changes: 6 additions & 7 deletions zuul.d/projects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
templates:
- system-required

- project:
name: github.com/ansible-collections/amazon.aws
templates:
- system-required

- project:
name: github.com/ansible-collections/ansible.netcommon
templates:
Expand Down Expand Up @@ -164,7 +169,7 @@
- project:
name: github.com/ansible-community/ansible-bender
templates:
- noop-jobs
- system-required

- project:
name: github.com/ansible-community/molecule
Expand Down Expand Up @@ -256,12 +261,6 @@
templates:
- ansible-python-jobs

- project:
name: github.com/ansible-network/aws
default-branch: devel
templates:
- noop-jobs

- project:
name: github.com/ansible-network/azure
default-branch: devel
Expand Down