Index: bin/autobuild ================================================================== --- bin/autobuild +++ bin/autobuild @@ -45,11 +45,12 @@ # 4. Get a list of branches branches=( $(fossil branch -R "${repository}" list) ) # 5. Get Fossil CI configuration from the trunk branch ## 5.a. Set default config -excludedBranches='' +excludedBranches=() +includedBranches=('') buildCommands=('./autogen.sh || :' ./configure make) testCommands=() releaseCommands=() builderID='' projectName="$(fossil info -R "${repository}" | awk '/^project-name:/{ sub(/^project-name: */, ""); gsub(/ /, ""); print; }')" @@ -75,36 +76,56 @@ if [ -n "${builderID}" ]; then tagSuffix="-${builderID}" fi fi -# 6. For each branch, attempt to build +# 6. Perform any configured initialization +for cmd in "${initCommands[@]}"; do + eval "${cmd}" >/dev/null 2>/dev/null || : +done + +# 7. For each branch, attempt to build for branch in "${branches[@]}"; do - ## 6.a. Ignore excluded branches - case "${branch}" in - ${excludedBranches}) - continue - ;; - esac - - ## 6.b. Find the branch working directory + ## 7.a. Only process specific branches + ignoreBranch='1' + for testBranch in "${includedBranches[@]}"; do + if echo "${branch}" | grep "${testBranch}" >/dev/null; then + ignoreBranch='0' + + break + fi + done + + for testBranch in "${excludedBranches[@]}"; do + if echo "${branch}" | grep "${testBranch}" >/dev/null; then + ignoreBranch='1' + + break + fi + done + + if [ "${ignoreBranch}" = '1' ]; then + continue + fi + + ## 7.b. Find the branch working directory branchdir="$(echo "${branch}" | sed 's@[^A-Za-z0-9-]@_@g')" builddir="${workdir}/build-output/branch-${branchdir}" branchdir="${workdir}/working-copies/branch-${branchdir}" mkdir -p "${branchdir}" - ## 6.c. Determine current checkout ID + ## 7.c. Determine current checkout ID checkout="$(fossil info -R "${repository}" "${branch}" | awk '/^uuid:/{ print $3 "T" $4 "-" $2 }')" builddir="${builddir}/checkout-${checkout}" - ## 6.d. Determine if build even needs to occur + ## 7.d. Determine if build even needs to occur if [ -d "${builddir}" ]; then continue fi mkdir -p "${builddir}" - ## 6.e. Check-out or update the branch + ## 7.e. Check-out or update the branch ( cd "${branchdir}" || exit 1 if [ ! -f '.fslckout' ]; then fossil open "${repository}" "${branch}" --nested @@ -111,21 +132,21 @@ else fossil update "${branch}" fi ) > "${builddir}/update.log" 2>&1 || continue - ## 6.f. Build and log the results, if there are any + ## 7.f. Build and log the results, if there are any build_pass='1' ( cd "${branchdir}" || exit 1 for cmd in "${buildCommands[@]}"; do ( eval "set -x; ${cmd}" ) || exit 1 done ) > "${builddir}/build.log" 2>&1 || build_pass='0' - ### 6.g. Test the branch + ### 7.g. Test the branch if [ "${build_pass}" = '1' ]; then tests_pass='1' ( cd "${branchdir}" || exit 1 @@ -133,11 +154,11 @@ ( eval "set -x; ${cmd}" ) || exit 1 done ) > "${builddir}/test.log" 2>&1 || tests_pass='0' fi - ### 6.h. Tag the branch with + ### 7.h. Tag the branch with tagsToAdd=() if [ "${build_pass}" = '1' ]; then tagsToAdd=("${tagsToAdd[@]}" build-pass) if [ "${tests_pass}" = '1' ]; then @@ -154,14 +175,14 @@ tagsToAddOpts=("${tagsToAddOpts[@]}" --tag "${tagPrefix}${tag}${tagSuffix}") done fossil amend -R "${repository}" "${branch}" "${tagsToAddOpts[@]}" > "${builddir}/update.log" 2>&1 - ### 6.i. Upload the logs somewhere if requested + ### 7.i. Upload the logs somewhere if requested #### XXX:TODO - ### 6.j. Upload build artifacts somewhere if requested + ### 7.j. Upload build artifacts somewhere if requested #### XXX:TODO done -# 7. Clean up any branches that no longer exist +# 8. Clean up any branches that no longer exist ## XXX:TODO