forked from openstack-k8s-operators/architecture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-zuul-jobs.py
executable file
·61 lines (51 loc) · 1.95 KB
/
create-zuul-jobs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python3
import os
import yaml
_AUTO_PATH = 'automation/vars/'
_JOBS = []
_PROJECTS = ['noop']
_BASE_TRIGGER_FILES = [
'lib',
]
def create_job(name, data):
j_name = 'rhoso-architecture-validate-{}'.format(name)
_paths = [p['path'] for p in data['stages']] + _BASE_TRIGGER_FILES
for i in ['va', 'dt']:
if os.path.exists(os.path.join(i, name)):
_paths.append(os.path.join(i, name))
_mock = os.path.join('automation', 'mocks', '{}.yaml'.format(name))
_net_env = os.path.join('automation', 'net-env', '{}.yaml'.format(name))
job = {
'job': {
'name': j_name,
'parent': 'rhoso-architecture-base-job',
'vars': {
'cifmw_architecture_scenario': name
},
}
}
if os.path.exists(_mock):
_paths.append(_mock)
if os.path.exists(_net_env):
_paths.append(_net_env)
job['job']['vars']['cifmw_networking_env_def_file'] = _net_env
job['job']['files'] = sorted(_paths)
_JOBS.append(job)
_PROJECTS.append(j_name)
for fname in [f for f in os.listdir(_AUTO_PATH) if f.endswith('.yaml')]:
with open(os.path.join(_AUTO_PATH, fname), 'r') as y_file:
scenarios = yaml.safe_load(y_file)
for scenario, stages in scenarios['vas'].items():
create_job(scenario, stages)
_sorted_jobs = sorted(_JOBS, key= lambda d: d['job']['name'])
with open('./zuul.d/validations.yaml', 'w+') as zuul_jobs:
yaml.dump(_sorted_jobs, zuul_jobs)
_PROJECTS.sort()
with open('./zuul.d/projects.yaml', 'w+') as zuul_projects:
struct = [{'project': {'github-check': {'jobs': _PROJECTS},
'github-gate': {'jobs': _PROJECTS},
'github-experimental-trigger': {'jobs': ['architecture-downstream-va-hci-trigger-job']}
}
}
]
yaml.dump(struct, zuul_projects)