Add tooling to update python jobs on branch creation
Currently, we need to update jobs manually after a branch is created. When a project is branched, the master branch should then be pointing to the new named python3 tests. This should do it. Change-Id: Id58f439052b4ea6b092b87682576a746433dcc27
This commit is contained in:
parent
a8a41f162f
commit
6938731988
@ -0,0 +1,65 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Script to update the zuul python3 jobs on master branch when a
|
||||||
|
# new series is created.
|
||||||
|
#
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
if [[ $# -lt 3 ]]; then
|
||||||
|
echo "Usage: $0 oldseries newseriesname repo_dir"
|
||||||
|
echo
|
||||||
|
echo "Example: $0 stein train openstack/oslo.config"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
OLDSERIES=$1
|
||||||
|
SERIES=$2
|
||||||
|
REPO=$3
|
||||||
|
TOOLSDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
|
cd $REPO
|
||||||
|
|
||||||
|
commit_msg="Add Python3 ${SERIES} unit tests
|
||||||
|
|
||||||
|
This is an automatically generated patch to ensure unit testing
|
||||||
|
is in place for all the of the tested runtimes for ${SERIES}.
|
||||||
|
|
||||||
|
See also the PTI in governance [1].
|
||||||
|
|
||||||
|
[1]: https://governance.openstack.org/tc/reference/project-testing-interface.html
|
||||||
|
"
|
||||||
|
|
||||||
|
git checkout master
|
||||||
|
# Find the appropriate files
|
||||||
|
fnames=$(find . -type f -path '*zuul.d/*'; find . -type f -name '*zuul.yaml')
|
||||||
|
for fname in $fnames; do
|
||||||
|
echo "Checking ${fname}"
|
||||||
|
sed -i \
|
||||||
|
"s/openstack-python3-${OLDSERIES}-jobs/openstack-python3-${SERIES}-jobs/g" \
|
||||||
|
$fname
|
||||||
|
done
|
||||||
|
|
||||||
|
# Only submit patch if files were changed
|
||||||
|
changes=$(git diff-index --name-only HEAD --)
|
||||||
|
if [ -n "$changes" ]; then
|
||||||
|
git checkout -b add-${SERIES}-python-jobtemplates
|
||||||
|
git add .
|
||||||
|
git diff --cached
|
||||||
|
git commit -m "$commit_msg"
|
||||||
|
git show
|
||||||
|
git review --yes -f
|
||||||
|
fi
|
@ -32,6 +32,7 @@ source $TOOLSDIR/functions
|
|||||||
REPO=$1
|
REPO=$1
|
||||||
NEW_BRANCH=$2
|
NEW_BRANCH=$2
|
||||||
START_POINT=$3
|
START_POINT=$3
|
||||||
|
MASTER_BRANCH_NAME=${4:-}
|
||||||
LPROJECT="$PROJECT"
|
LPROJECT="$PROJECT"
|
||||||
|
|
||||||
PROJECT=$(basename $REPO)
|
PROJECT=$(basename $REPO)
|
||||||
@ -79,4 +80,9 @@ if [[ $NEW_BRANCH =~ stable/ ]]; then
|
|||||||
else
|
else
|
||||||
echo "$REPO does not use reno, no update needed"
|
echo "$REPO does not use reno, no update needed"
|
||||||
fi
|
fi
|
||||||
|
# Now propose master branch changes with the new branchname
|
||||||
|
# according to PTI.
|
||||||
|
if [[ ! -z "${MASTER_BRANCH_NAME}" ]]; then
|
||||||
|
$TOOLSDIR/add_master_python3_jobs.sh ${NEW_BRANCH} ${MASTER_BRANCH_NAME} .
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -12,8 +12,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
"""Process all of the release requests in changed files in the commit.
|
"""Process all of the release requests in changed files in the commit."""
|
||||||
"""
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import os.path
|
import os.path
|
||||||
@ -52,6 +51,17 @@ RELEASE_SCRIPT = os.path.join(BINDIR, 'release.sh')
|
|||||||
BRANCH_SCRIPT = os.path.join(BINDIR, 'make_branch.sh')
|
BRANCH_SCRIPT = os.path.join(BINDIR, 'make_branch.sh')
|
||||||
|
|
||||||
|
|
||||||
|
def nextbranchname(branchname, reporoot):
|
||||||
|
"""Returns a string containing the next development branchname."""
|
||||||
|
datafile = 'data/series_status.yaml'
|
||||||
|
with open(os.path.join(reporoot, datafile), 'r') as seriesstatusf:
|
||||||
|
series = yaml.safe_load(seriesstatusf)
|
||||||
|
for nextseries, currentseries in zip(series, series[1:]):
|
||||||
|
if currentseries['name'] == branchname:
|
||||||
|
return nextseries['name']
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def find_modified_deliverable_files(reporoot):
|
def find_modified_deliverable_files(reporoot):
|
||||||
"Return a list of files modified by the most recent commit."
|
"Return a list of files modified by the most recent commit."
|
||||||
results = subprocess.check_output(
|
results = subprocess.check_output(
|
||||||
@ -83,10 +93,21 @@ def tag_release(repo, series_name, version, diff_start, hash,
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def make_branch(repo, name, ref):
|
def make_branch(repo, name, ref, nextbranchname=None):
|
||||||
|
"""Create a branch if needed.
|
||||||
|
|
||||||
|
:param repo: The repo in which to create the branch.
|
||||||
|
:param name: The name of the branch to create.
|
||||||
|
:param ref: The point at which to branch.
|
||||||
|
:param nextbranchname: The name of the expected next series, if known.
|
||||||
|
"""
|
||||||
print('Branching {} in {}'.format(name, repo))
|
print('Branching {} in {}'.format(name, repo))
|
||||||
|
makebranchargs = [BRANCH_SCRIPT, repo, name, ref]
|
||||||
|
# nextbranchname can be null if branch not found (feature branch)
|
||||||
|
if nextbranchname:
|
||||||
|
makebranchargs.append(nextbranchname)
|
||||||
try:
|
try:
|
||||||
subprocess.check_call([BRANCH_SCRIPT, repo, name, ref])
|
subprocess.check_call(makebranchargs)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
# The error output from the script will be
|
# The error output from the script will be
|
||||||
# printed to stderr, so we don't need to do
|
# printed to stderr, so we don't need to do
|
||||||
@ -191,13 +212,16 @@ def process_release_requests(reporoot, filenames, meta_data):
|
|||||||
first_full_release, meta_data,
|
first_full_release, meta_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create branches.
|
# Create branches and adapt master
|
||||||
for branch in deliverable_data.get('branches', []):
|
for branch in deliverable_data.get('branches', []):
|
||||||
|
masterbranchname = nextbranchname(branch['name'], reporoot)
|
||||||
location = branch['location']
|
location = branch['location']
|
||||||
|
|
||||||
if isinstance(location, dict):
|
if isinstance(location, dict):
|
||||||
for repo, sha in sorted(location.items()):
|
for repo, sha in sorted(location.items()):
|
||||||
error_count += make_branch(repo, branch['name'], sha)
|
error_count += make_branch(
|
||||||
|
repo, branch['name'], sha, masterbranchname
|
||||||
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Assume a single location string that is a valid
|
# Assume a single location string that is a valid
|
||||||
@ -205,6 +229,7 @@ def process_release_requests(reporoot, filenames, meta_data):
|
|||||||
for proj in releases_by_version[location]['projects']:
|
for proj in releases_by_version[location]['projects']:
|
||||||
error_count += make_branch(
|
error_count += make_branch(
|
||||||
proj['repo'], branch['name'], branch['location'],
|
proj['repo'], branch['name'], branch['location'],
|
||||||
|
masterbranchname
|
||||||
)
|
)
|
||||||
|
|
||||||
return error_count
|
return error_count
|
||||||
|
Loading…
Reference in New Issue
Block a user