def jobs(self): """[(job, job_path)] sequence""" for path, _, filenames in os.walk( os.path.dirname(bootstrap.job_script(JOB))): for job in filenames: job_path = os.path.join(path, job) yield job, job_path
def jobs(self): """[(job, job_path)] sequence""" for path, _, filenames in os.walk( os.path.dirname(bootstrap.job_script(JOB))): for job in filenames: job_path = os.path.join(path, job) yield job, job_path
def jobs(self): """[(job, job_path)] sequence""" dirname = os.path.dirname(bootstrap.job_script(JOB)) for filenames in os.listdir(dirname): for job in filenames: if job.endswith('.sh'): job_path = os.path.join(dirname, job) yield job, job_path
def CheckBootstrapYaml(self, path, check): with open(os.path.join(os.path.dirname(__file__), path)) as fp: doc = yaml.safe_load(fp) project = None defined_templates = set() for item in doc: if not isinstance(item, dict): continue if isinstance(item.get('job-template'), dict): defined_templates.add(item['job-template']['name']) if not isinstance(item.get('project'), dict): continue project = item['project'] self.assertIn('bootstrap-', project.get('name')) break else: self.fail('Could not find bootstrap-pull-jobs project') self.assertIn('jobs', project) used_templates = {j for j in project['jobs']} msg = '\nMissing templates: %s\nUnused templates: %s' % ( ','.join(used_templates - defined_templates), ','.join(defined_templates - used_templates)) self.assertEquals(defined_templates, used_templates, msg) jobs = project.get('suffix') if not jobs or not isinstance(jobs, list): self.fail('Could not find suffix list in %s' % project) for job in jobs: # Things to check on all bootstrap jobs if not isinstance(job, dict): self.fail('suffix items should be dicts', jobs) self.assertEquals(1, len(job), job) name = job.keys()[0] real_job = job[name] path = bootstrap.job_script(real_job.get('job-name')) self.assertTrue(os.path.isfile(path), path) for key, value in real_job.items(): if not isinstance(value, (basestring, int)): self.fail('Jobs may not contain child objects %s: %s' % (key, value)) if '{' in str(value): self.fail('Jobs may not contain {expansions}' % (key, value)) # Use simple strings # Things to check on specific flavors. self.assertIn('repo-name', real_job) self.assertIn('.', real_job['repo-name']) # Has domain job_name = check(real_job, name) self.assertTrue(job_name) self.assertEquals(job_name, real_job.get('job-name'))
def CheckBootstrapYaml(self, path, check, suffix='suffix'): with open(os.path.join( os.path.dirname(__file__), path)) as fp: doc = yaml.safe_load(fp) project = None defined_templates = set() for item in doc: if not isinstance(item, dict): continue if isinstance(item.get('job-template'), dict): defined_templates.add(item['job-template']['name']) if not isinstance(item.get('project'), dict): continue project = item['project'] self.assertIn('bootstrap-', project.get('name')) break else: self.fail('Could not find bootstrap-pull-jobs project') self.assertIn('jobs', project) used_templates = {j for j in project['jobs']} msg = '\nMissing templates: %s\nUnused templates: %s' % ( ','.join(used_templates - defined_templates), ','.join(defined_templates - used_templates)) self.assertEquals(defined_templates, used_templates, msg) jobs = project.get(suffix) if not jobs or not isinstance(jobs, list): self.fail('Could not find %s list in %s' % (suffix, project)) for job in jobs: # Things to check on all bootstrap jobs if not isinstance(job, dict): self.fail('suffix items should be dicts', jobs) self.assertEquals(1, len(job), job) name = job.keys()[0] real_job = job[name] path = bootstrap.job_script(real_job.get('job-name')) self.assertTrue(os.path.isfile(path), name) for key, value in real_job.items(): if not isinstance(value, (basestring, int)): self.fail('Jobs may not contain child objects %s: %s' % ( key, value)) if '{' in str(value): self.fail('Jobs may not contain {expansions}' % ( key, value)) # Use simple strings # Things to check on specific flavors. job_name = check(real_job, name) self.assertTrue(job_name) self.assertEquals(job_name, real_job.get('job-name'))