script to add python 3.5 jobs
Some of the repositories still only have 2.7 jobs. Change-Id: I0d56810482fe99a051ef1ced079f05dff7b22a35 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
parent
dcb813c089
commit
9618a719f8
@ -859,6 +859,81 @@ class JobsSwitchDocs(command.Command):
|
||||
yaml.dump(in_tree_settings, f)
|
||||
|
||||
|
||||
class JobsAddPy35(command.Command):
|
||||
"update the in-tree project settings to include python3.6 tests"
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super().get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'--default-zuul-file',
|
||||
default='.zuul.yaml',
|
||||
help='the default file to create when one does not exist',
|
||||
)
|
||||
parser.add_argument(
|
||||
'repo_dir',
|
||||
help='the repository location',
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
LOG.debug('determining repository name from .gitreview')
|
||||
gitreview_filename = os.path.join(parsed_args.repo_dir, '.gitreview')
|
||||
cp = configparser.ConfigParser()
|
||||
cp.read(gitreview_filename)
|
||||
gerrit = cp['gerrit']
|
||||
repo = gerrit['project']
|
||||
if repo.endswith('.git'):
|
||||
repo = repo[:-4]
|
||||
LOG.info('working on %s', repo)
|
||||
|
||||
in_repo = find_project_settings_in_repo(parsed_args.repo_dir)
|
||||
in_tree_file, in_tree_project, in_tree_settings = in_repo
|
||||
if not in_tree_file:
|
||||
raise RuntimeError('Could not find project settings in {}'.format(
|
||||
parsed_args.repo_dir))
|
||||
|
||||
changed = False
|
||||
templates = in_tree_project['project'].get('templates', [])
|
||||
supports_python = 'openstack-python27-jobs' in templates
|
||||
tests_py36 = 'openstack-python35-jobs' in templates
|
||||
if supports_python and not tests_py36:
|
||||
idx = templates.index('openstack-python27-jobs')
|
||||
templates.insert(idx + 1, 'openstack-python35-jobs')
|
||||
changed = True
|
||||
# Look through the pipelines for 'openstack-tox-py37'
|
||||
# and copy any job settings to 'openstack-tox-py35'.
|
||||
for pipeline, pipeline_data in in_tree_project['project'].items():
|
||||
if pipeline == 'templates':
|
||||
continue
|
||||
if not isinstance(pipeline_data, DICT_TYPES):
|
||||
continue
|
||||
LOG.info('looking at %s pipeline', pipeline)
|
||||
jobs = pipeline_data.get('jobs', [])
|
||||
for idx, job in enumerate(jobs):
|
||||
if not isinstance(job, DICT_TYPES):
|
||||
continue
|
||||
job_name = list(job.keys())[0]
|
||||
if job_name == 'openstack-tox-py37':
|
||||
break
|
||||
else:
|
||||
continue
|
||||
LOG.info('updating job %s', job)
|
||||
job_data = copy.deepcopy(job[job_name])
|
||||
jobs.insert(idx + 1, {'openstack-tox-py35': job_data})
|
||||
changed = True
|
||||
|
||||
if not changed:
|
||||
LOG.info('No updates needed for %s', repo)
|
||||
return 2
|
||||
|
||||
LOG.info('# {} add py35 jobs'.format(repo))
|
||||
yaml = projectconfig_ruamellib.YAML()
|
||||
# yaml.dump([in_tree_project], self.app.stdout)
|
||||
LOG.info('updating %s', in_tree_file)
|
||||
with open(in_tree_file, 'w', encoding='utf-8') as f:
|
||||
yaml.dump(in_tree_settings, f)
|
||||
|
||||
|
||||
class JobsAddPy36(command.Command):
|
||||
"update the in-tree project settings to include python3.6 tests"
|
||||
|
||||
|
@ -51,6 +51,7 @@ python3_first =
|
||||
jobs update = goal_tools.python3_first.jobs:JobsUpdate
|
||||
jobs switch docs = goal_tools.python3_first.jobs:JobsSwitchDocs
|
||||
jobs switch packaging = goal_tools.python3_first.jobs:JobsSwitchPackaging
|
||||
jobs add py35 = goal_tools.python3_first.jobs:JobsAddPy35
|
||||
jobs add py36 = goal_tools.python3_first.jobs:JobsAddPy36
|
||||
jobs add lib = goal_tools.python3_first.jobs:JobsAddLibForwardTestingPy3
|
||||
repos clone = goal_tools.python3_first.repos:ReposClone
|
||||
|
62
tools/python3-first/add_py35_job.sh
Executable file
62
tools/python3-first/add_py35_job.sh
Executable file
@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
|
||||
bindir=$(dirname $0)
|
||||
source $bindir/functions
|
||||
|
||||
echo $0 $*
|
||||
echo
|
||||
|
||||
function usage {
|
||||
echo "add_py35_job.sh WORKDIR TEAM TASK"
|
||||
}
|
||||
|
||||
workdir=$1
|
||||
team="$2"
|
||||
task="$3"
|
||||
|
||||
if [ -z "$workdir" ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$team" ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$task" ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
enable_tox
|
||||
|
||||
commit_message="add python 3.6 unit test job
|
||||
|
||||
This is a mechanically generated patch to add a unit test job running
|
||||
under Python 3.6 as part of the python3-first goal.
|
||||
|
||||
See the python3-first goal document for details:
|
||||
https://governance.openstack.org/tc/goals/stein/python3-first.html
|
||||
|
||||
Story: #2002586
|
||||
Task: #$task
|
||||
|
||||
"
|
||||
|
||||
tracking_file="$workdir/master"
|
||||
for repo in $(cat "$tracking_file"); do
|
||||
|
||||
echo
|
||||
echo "=== $repo doc jobs ==="
|
||||
echo
|
||||
|
||||
repo_dir="$workdir/$repo"
|
||||
git -C "$repo_dir" checkout python3-first-master
|
||||
if python3-first -v --debug jobs add py35 "$repo_dir"
|
||||
then
|
||||
git -C "$repo_dir" add .
|
||||
git -C "$repo_dir" commit -m "$commit_message"
|
||||
git -C "$repo_dir" show
|
||||
fi
|
||||
done
|
@ -67,6 +67,7 @@ python3-first -v --debug repos clone "$out_dir" "$team" $repos
|
||||
|
||||
$bindir/process_team.sh "$out_dir" "$team" master $task_id
|
||||
$bindir/update_doc_job.sh "$out_dir" "$team" $task_id
|
||||
$bindir/add_py35_job.sh "$out_dir" "$team" $task_id
|
||||
$bindir/add_py36_job.sh "$out_dir" "$team" $task_id
|
||||
$bindir/add_lib_job.sh "$out_dir" "$team" $task_id
|
||||
$bindir/process_team.sh "$out_dir" "$team" stable/ocata $task_id
|
||||
|
Loading…
Reference in New Issue
Block a user