flake8 chroot-installation.yaml.py (nop changes)

Signed-off-by: Mattia Rizzolo's avatarMattia Rizzolo <mattia@debian.org>
parent b19d6b2c
......@@ -2,13 +2,8 @@
# -*- coding: utf-8 -*-
import sys
import os
from string import join
from yaml import load, dump
try:
from yaml import CLoader as Loader, CDumper as Dumper
except ImportError:
from yaml import Loader, Dumper
import yaml
import string
base_distros = [
......@@ -99,32 +94,34 @@ all_targets = [
'design-desktop-web',
]
#
# not all packages are available in all distros
#
def is_target_in_distro(distro, target):
# education-ltsp-server and education-roaming-workstation are only available since stretch…
if distro in ('jessie') and target in ('education-ltsp-server', 'education-roaming-workstation'):
return False
# education-thin-client-server is obsolete since stretch…
elif distro in ('sid', 'buster', 'stretch') and target == 'education-thin-client-server':
return False
# education-services is obsolete since buster…
elif distro in ('sid', 'buster') and target == 'education-services':
return False
# lxqt is only available since stretch
elif distro in ('jessie') and target == 'lxqt':
return False
# education-lang-* packages only exist in stretch
elif distro not in ('stretch') and target[:15] == 'education-lang-':
return False
# parl-desktop* and design-desktop* packages only exist since stretch
elif distro in ('jessie') and (target[:12] == 'parl-desktop' or target[:14] == 'design-desktop'):
return False
# education-desktop-lxqt, education-primaryschool and education-video packages only exist since buster
elif distro in ('jessie', 'stretch') and target in ('education-desktop-lxqt', 'education-primaryschool', 'education-video'):
return False
return True
# education-ltsp-server and education-roaming-workstation are only available since stretch…
if distro in ('jessie') and target in ('education-ltsp-server', 'education-roaming-workstation'):
return False
# education-thin-client-server is obsolete since stretch…
elif distro in ('sid', 'buster', 'stretch') and target == 'education-thin-client-server':
return False
# education-services is obsolete since buster…
elif distro in ('sid', 'buster') and target == 'education-services':
return False
# lxqt is only available since stretch
elif distro in ('jessie') and target == 'lxqt':
return False
# education-lang-* packages only exist in stretch
elif distro not in ('stretch') and target[:15] == 'education-lang-':
return False
# parl-desktop* and design-desktop* packages only exist since stretch
elif distro in ('jessie') and (target[:12] == 'parl-desktop' or target[:14] == 'design-desktop'):
return False
# education-desktop-lxqt, education-primaryschool and education-video packages only exist since buster
elif distro in ('jessie', 'stretch') and target in ('education-desktop-lxqt', 'education-primaryschool', 'education-video'):
return False
return True
#
# who gets mail for which target
......@@ -145,6 +142,7 @@ def get_recipients(target):
else:
return 'jenkins+debian-qa qa-jenkins-scm@lists.alioth.debian.org'
#
# views for different targets
#
......@@ -159,6 +157,7 @@ def get_view(target, distro):
else:
return 'chroot-installation'
#
# special descriptions used for some targets
#
......@@ -178,17 +177,19 @@ spoken_names = {
'debconf-video': 'all packages relevant for the DebConf videoteam',
}
def get_spoken_name(target):
if target[:12] == 'parl-desktop':
return 'the Debian Parl metapackage '+target
return 'the Debian Parl metapackage '+target
elif target[:14] == 'design-desktop':
return 'the Debian Parl metapackage '+target
return 'the Debian Parl metapackage '+target
elif target[:10] == 'education-':
return 'the Debian Edu metapackage '+target
return 'the Debian Edu metapackage '+target
elif target in spoken_names:
return spoken_names[target]
return spoken_names[target]
else:
return target
return target
#
# nothing to edit below
......@@ -198,29 +199,33 @@ def get_spoken_name(target):
# This structure contains the differences between the default, upgrade and upgrade_apt+dpkg_first jobs
#
jobspecs = [
{ 'j_ext': '',
'd_ext': '',
's_ext': '',
'dist_func': (lambda d: d),
'distfilter': (lambda d: tuple(set(d))),
'skiptaryet': (lambda t: False)
{
'j_ext': '',
'd_ext': '',
's_ext': '',
'dist_func': (lambda d: d),
'distfilter': (lambda d: tuple(set(d))),
'skiptaryet': (lambda t: False)
},
{ 'j_ext': '_upgrade_to_{dist2}',
'd_ext': ', then upgrade to {dist2}',
's_ext': ' {dist2}',
'dist_func': (lambda d: [{dist: {'dist2': distro_upgrades[dist]}} for dist in d]),
'distfilter': (lambda d: tuple(set(d) & set(distro_upgrades))),
'skiptaryet': (lambda t: False)
{
'j_ext': '_upgrade_to_{dist2}',
'd_ext': ', then upgrade to {dist2}',
's_ext': ' {dist2}',
'dist_func': (lambda d: [{dist: {'dist2': distro_upgrades[dist]}} for dist in d]),
'distfilter': (lambda d: tuple(set(d) & set(distro_upgrades))),
'skiptaryet': (lambda t: False)
},
]
# some functions first…
#
# return the list of targets, filtered to be those present in 'distro'
#
def get_targets_in_distro(distro):
return [t for t in all_targets if is_target_in_distro(distro, t)]
return [t for t in all_targets if is_target_in_distro(distro, t)]
#
# given a target, returns a list of ([dist], key) tuples, so we can handle the
......@@ -228,7 +233,7 @@ def get_targets_in_distro(distro):
#
# this groups all the distros that have matching views
#
def get_dists_per_key(target,get_distro_key):
def get_dists_per_key(target, get_distro_key):
dists_per_key = {}
for distro in base_distros:
if is_target_in_distro(distro, target):
......@@ -245,55 +250,54 @@ data = []
jobs = []
data.append(
{ 'defaults': { 'builders': [{ 'shell': '{my_shell}'}],
'description': '{my_description}{do_not_edit}',
'logrotate': { 'artifactDaysToKeep': -1,
'artifactNumToKeep': -1,
'daysToKeep': 90,
'numToKeep': 30},
'name': 'chroot-installation',
'properties': [ { 'sidebar': { 'icon': '/userContent/images/debian-swirl-24x24.png',
'text': 'About jenkins.debian.net',
'url': 'https://jenkins.debian.net/userContent/about.html'}},
{ 'sidebar': { 'icon': '/userContent/images/debian-jenkins-24x24.png',
'text': 'All {my_view} jobs',
'url': 'https://jenkins.debian.net/view/{my_view}/'}},
{ 'sidebar': { 'icon': '/userContent/images/profitbricks-24x24.png',
'text': 'Sponsored by Profitbricks',
'url': 'http://www.profitbricks.co.uk'}},
{ 'priority-sorter': { 'priority': '{my_prio}'}},
],
'publishers': [ { 'trigger': { 'project': '{my_trigger}'}},
{ 'email-ext': { 'attach-build-log': False,
'body': 'See $BUILD_URL/console or just $BUILD_URL for more information.',
'first-failure': False,
'second-failure': True,
'failure': False,
'fixed': True,
'recipients': '{my_recipients}',
'subject': '$BUILD_STATUS: $JOB_NAME/$BUILD_NUMBER'}},
{ 'logparser': { 'parse-rules': '/srv/jenkins/logparse/chroot-installation.rules',
'unstable-on-warning': True,}},
{ 'naginator': { 'progressive-delay-increment': 5,
'progressive-delay-maximum': 15,
'max-failed-builds': 3,
'regular-expression': '^E: (Couldn.t download .*/Packages|Unable to fetch some archives|Failed getting release file|Failed getting release signature file)'}}],
'triggers': [{ 'timed': '{my_time}'}],
'wrappers': [{ 'timeout': { 'timeout': 360}}],
'node': 'profitbricks10',
{'defaults': {'builders': [{'shell': '{my_shell}'}],
'description': '{my_description}{do_not_edit}',
'logrotate': {'artifactDaysToKeep': -1,
'artifactNumToKeep': -1,
'daysToKeep': 90,
'numToKeep': 30},
'name': 'chroot-installation',
'properties': [{'sidebar': {'icon': '/userContent/images/debian-swirl-24x24.png',
'text': 'About jenkins.debian.net',
'url': 'https://jenkins.debian.net/userContent/about.html'}},
{'sidebar': {'icon': '/userContent/images/debian-jenkins-24x24.png',
'text': 'All {my_view} jobs',
'url': 'https://jenkins.debian.net/view/{my_view}/'}},
{'sidebar': {'icon': '/userContent/images/profitbricks-24x24.png',
'text': 'Sponsored by Profitbricks',
'url': 'http://www.profitbricks.co.uk'}},
{'priority-sorter': {'priority': '{my_prio}'}}],
'publishers': [{'trigger': {'project': '{my_trigger}'}},
{'email-ext': {'attach-build-log': False,
'body': 'See $BUILD_URL/console or just $BUILD_URL for more information.',
'first-failure': False,
'second-failure': True,
'failure': False,
'fixed': True,
'recipients': '{my_recipients}',
'subject': '$BUILD_STATUS: $JOB_NAME/$BUILD_NUMBER'}},
{'logparser': {'parse-rules': '/srv/jenkins/logparse/chroot-installation.rules',
'unstable-on-warning': True}},
{'naginator': {'progressive-delay-increment': 5,
'progressive-delay-maximum': 15,
'max-failed-builds': 3,
'regular-expression': '^E: (Couldn.t download .*/Packages|Unable to fetch some archives|Failed getting release file|Failed getting release signature file)'}}],
'triggers': [{'timed': '{my_time}'}],
'wrappers': [{'timeout': {'timeout': 360}}],
'node': 'profitbricks10',
}})
data.append(
{ 'job-template': { 'defaults': 'chroot-installation',
'name': '{name}_{dist}_{action}'}})
{'job-template': {'defaults': 'chroot-installation',
'name': '{name}_{dist}_{action}'}})
data.append(
{ 'job-template': { 'defaults': 'chroot-installation',
'name': '{name}_{dist}_install_{target}'}})
{'job-template': {'defaults': 'chroot-installation',
'name': '{name}_{dist}_install_{target}'}})
data.append(
{ 'job-template': { 'defaults': 'chroot-installation',
'name': '{name}_{dist}_{action}_upgrade_to_{dist2}'}})
{'job-template': {'defaults': 'chroot-installation',
'name': '{name}_{dist}_{action}_upgrade_to_{dist2}'}})
data.append(
{ 'job-template': { 'defaults': 'chroot-installation',
'name': '{name}_{dist}_install_{target}_upgrade_to_{dist2}'}})
{'job-template': {'defaults': 'chroot-installation',
'name': '{name}_{dist}_install_{target}_upgrade_to_{dist2}'}})
# maintenance jobs
maint_distros = []
for base_distro in sorted(base_distros):
......@@ -301,17 +305,17 @@ for base_distro in sorted(base_distros):
if base_distro in distro_upgrades.values():
trigger = 'chroot-installation_{dist}_bootstrap'
for item in distro_upgrades.items():
if item[1]==base_distro and base_distro in distro_upgrades:
if item[1] == base_distro and base_distro in distro_upgrades:
trigger = trigger+', chroot-installation_{dist}_bootstrap_upgrade_to_{dist2}'
dist2 = distro_upgrades[base_distro]
else:
trigger = 'chroot-installation_{dist}_bootstrap_upgrade_to_{dist2}'
dist2 = distro_upgrades[base_distro]
maint_distros.append({ base_distro: {
maint_distros.append({base_distro: {
'my_time': trigger_times[base_distro],
'dist2': dist2,
'my_trigger': trigger}})
jobs.append({ '{name}_{dist}_{action}': {
jobs.append({'{name}_{dist}_{action}': {
'action': 'maintenance',
'dist': maint_distros,
'my_description': 'Maintainance job for chroot-installation_{dist}_* jobs, do some cleanups and monitoring so that there is a predictable environment.',
......@@ -322,8 +326,8 @@ jobs.append({ '{name}_{dist}_{action}': {
# bootstrap jobs
js_dists_trigs = [{},{},{}]
for trigs, dists in get_dists_per_key('bootstrap',(lambda d: tuple(sorted(get_targets_in_distro(d))))).items():
js_dists_trigs = [{}, {}, {}]
for trigs, dists in get_dists_per_key('bootstrap', (lambda d: tuple(sorted(get_targets_in_distro(d))))).items():
for jobindex, jobspec in enumerate(jobspecs):
js_dists = jobspec['distfilter'](dists)
if (js_dists):
......@@ -332,12 +336,12 @@ for trigs, dists in get_dists_per_key('bootstrap',(lambda d: tuple(sorted(get_ta
for jobindex, jobspec in enumerate(jobspecs):
jobs.extend([{ '{name}_{dist}_{action}'+jobspec['j_ext']: {
jobs.extend([{'{name}_{dist}_{action}'+jobspec['j_ext']: {
'action': 'bootstrap',
'dist': list(dists) if jobspec['j_ext'] == '' else
[{dist: {'dist2': distro_upgrades[dist]}} for dist in dists],
'my_trigger': join(['chroot-installation_{dist}_install_'+t+jobspec['j_ext']
for t in list(trigs)], ', '),
[{dist: {'dist2': distro_upgrades[dist]}} for dist in dists],
'my_trigger': string.join(['chroot-installation_{dist}_install_'+t+jobspec['j_ext']
for t in list(trigs)], ', '),
'my_description': 'Debootstrap {dist}'+jobspec['d_ext']+'.',
'my_prio': 131,
'my_time': '',
......@@ -345,12 +349,12 @@ for jobindex, jobspec in enumerate(jobspecs):
'my_shell': '/srv/jenkins/bin/jenkins_master_wrapper.sh {dist} none'+jobspec['s_ext'],
'my_view': get_view('bootstrap', None),
}}
for (dists, trigs) in js_dists_trigs[jobindex].keys()])
for (dists, trigs) in js_dists_trigs[jobindex].keys()])
# now all the other jobs
targets_per_distview = [{},{},{}]
targets_per_distview = [{}, {}, {}]
for target in sorted(all_targets):
for view, dists in get_dists_per_key(target,(lambda d: get_view(target, d))).items():
for view, dists in get_dists_per_key(target, (lambda d: get_view(target, d))).items():
for jobindex, jobspec in enumerate(jobspecs):
if jobspec['skiptaryet'](target):
continue
......@@ -363,7 +367,7 @@ for target in sorted(all_targets):
targets_per_distview[jobindex][distview].append(target)
for jobindex, jobspec in enumerate(jobspecs):
jobs.extend([{ '{name}_{dist}_install_{target}'+jobspec['j_ext']: {
jobs.extend([{'{name}_{dist}_install_{target}'+jobspec['j_ext']: {
'dist': jobspec['dist_func'](list(dists)),
'target': [{t: {
'my_spokenname': get_spoken_name(t),
......@@ -373,7 +377,7 @@ for jobindex, jobspec in enumerate(jobspecs):
'my_shell': '/srv/jenkins/bin/jenkins_master_wrapper.sh {dist} {target}'+jobspec['s_ext'],
'my_view': view,
}}
for (dists, view), dv_targs in targets_per_distview[jobindex].items()])
for (dists, view), dv_targs in targets_per_distview[jobindex].items()])
data.append({'project': {
'name': 'chroot-installation',
......@@ -383,4 +387,4 @@ data.append({'project': {
'my_time': '',
'jobs': jobs}})
sys.stdout.write(dump(data, Dumper=Dumper))
sys.stdout.write(yaml.dump(data))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment