improve error handling

Use error code 2 to indicate that we are exiting a program without
doing any work. This leaves error code 1 to mean that the program
actually had an error, and we can check for those errors and report
them.

Add --debug and -v flag where missing in calls to python3-first app.

Change-Id: Ia6f39dc8eee3505ac573670a9e44ae225ed48334
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2018-08-17 10:44:00 -04:00
parent 8a630755f7
commit 9a66c18e4e
5 changed files with 31 additions and 9 deletions

View File

@ -514,7 +514,7 @@ class JobsUpdate(command.Command):
else:
LOG.warning('Could not find {} in {}'.format(
repo, project_filename))
return 1
return 2
# Remove the items that need to stay in project-config.
find_templates_to_extract(entry['project'], zuul_templates, zuul_jobs)
@ -535,7 +535,7 @@ class JobsUpdate(command.Command):
if not in_tree_project.get('project'):
LOG.info('no settings to write')
return 1
return 2
if not in_tree_settings:
in_tree_settings.append(in_tree_project)
@ -837,7 +837,7 @@ class JobsSwitchDocs(command.Command):
if not changed:
LOG.info('No updates needed for %s', repo)
return 1
return 2
LOG.info('# {} switch docs jobs'.format(repo))
yaml = projectconfig_ruamellib.YAML()
@ -912,7 +912,7 @@ class JobsAddPy36(command.Command):
if not changed:
LOG.info('No updates needed for %s', repo)
return 1
return 2
LOG.info('# {} add py36 jobs'.format(repo))
yaml = projectconfig_ruamellib.YAML()
@ -966,7 +966,7 @@ class JobsAddLibForwardTestingPy3(command.Command):
if not changed:
LOG.info('No updates needed for %s', repo)
return 1
return 2
LOG.info('# {} add lib-forward-testing-python3 jobs'.format(repo))
yaml = projectconfig_ruamellib.YAML()

View File

@ -81,17 +81,23 @@ else
if ! git -C "$repo" checkout -q origin/$branch ; then
echo "Could not check out origin/$branch in $repo"
exit 1
exit 2
fi
git -C "$repo" checkout -b $new_branch
fi
if ! python3-first -v --debug jobs update "$repo"; then
python3-first -v --debug jobs update "$repo"
RC=$?
if [ $RC -eq 2 ]; then
echo "No changes"
exit 1
fi
if [ $RC -ne 0 ]; then
echo "FAIL"
exit $RC
fi
if ! git -C "$repo" diff --ignore-all-space; then
echo "No changes other than whitespace"

View File

@ -39,6 +39,11 @@ task_id=$(grep -e "$team" $bindir/taskids.txt | awk '{print $1}')
echo "Story: $story_id"
echo "Task : $task_id"
if [ -z "$task_id" ]; then
echo "Could not find task for $team"
exit 1
fi
echo
echo "=== Updating extra project settings ==="
echo
@ -53,7 +58,9 @@ echo
echo "=== Cloning $team repositories ==="
echo
python3-first repos clone "$out_dir" "$team"
set -e
python3-first -v --debug repos clone "$out_dir" "$team"
$bindir/process_team.sh "$out_dir" "$team" master $task_id
$bindir/update_doc_job.sh "$out_dir" "$team" $task_id

View File

@ -51,8 +51,15 @@ for repo in $(ls -d $workdir/*/*); do
# it exists. Having it empty is fine.
touch $workdir/$(basename $branch)
if $bindir/do_repo.sh "$repo" "$branch" "$task"; then
$bindir/do_repo.sh "$repo" "$branch" "$task"
RC=$?
if [ $RC -eq 0 ]; then
tracking="$(basename $(dirname $repo))/$(basename $repo)"
echo "$tracking" >> $workdir/$(basename $branch)
elif [ $RC -ne 2 ]; then
echo "FAIL"
exit $RC
fi
done
exit 0

View File

@ -29,6 +29,8 @@ if [ -z "$task" ]; then
exit 1
fi
set -e
enable_tox
commit_message="switch documentation job to new PTI