tools/run_renderspec: fail on syntax errors in the spec templates

running processes in the background with " &" means that the exit
code will get ignored by the surrounding shell, which causes
issues in renderspec invocation to be ignored by the linter job.

Rewrite the logic to use xargs so that we preserve the parallelism
but still capture the exit codes (although it happens out of band
so it is remaining hard to find in the output). Remove the py3 only
logic and always run it with both flags.

Change-Id: Idb5f9cd3d6264ad86ca5a9905234f072ece622ca
This commit is contained in:
Dirk Mueller 2018-08-09 10:35:04 +02:00
parent 275b9ae68d
commit e2da411fcd

View File

@ -16,25 +16,17 @@ for specstyle in $specstyles; do
rm -rf $OUTPUTDIR/${specstyle}/* rm -rf $OUTPUTDIR/${specstyle}/*
done done
py3onlypackages=("openstack-glance openstack-keystone")
count=0 count=0
echo "run renderspec over specfiles from ${specdir}" echo "run renderspec over specfiles from ${specdir}"
for specstyle in $specstyles; do for specstyle in $specstyles; do
for spec in ${specdir}/**/*.spec.j2; do find ${specdir} -name '*.spec.j2' -type f -print0 | \
echo "run ${spec} for ${specstyle}" xargs -n 1 -0 -P 0 -I __SPEC__ bash -c "
pkg_name=$(pymod2pkg --dist $specstyle $(basename $spec .spec.j2)) set -e
if [[ ! " ${py3onlypackages[@]} " =~ " ${pkg_name} " ]];then skip='--skip-pyversion py3'
skip="--skip-pyversion py3" if grep -q '%package -n python3-' __SPEC__; then
else
skip="" skip=""
fi fi
renderspec --spec-style ${specstyle} ${spec} \ pkg_name=\$(pymod2pkg --dist $specstyle \$(basename __SPEC__ .spec.j2))
--requirements $basedir/global-requirements.txt ${skip} \ renderspec --spec-style $specstyle __SPEC__ \
-o $WORKSPACE/logs/${specstyle}/$pkg_name.spec & \$skip -o $WORKSPACE/logs/$specstyle/\$pkg_name.spec"
let count+=1
[[ count -eq $MAXPROC ]] && wait && count=0
done
done done
wait