Index: bin/autobuild ================================================================== --- bin/autobuild +++ bin/autobuild @@ -46,10 +46,11 @@ # 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 +### 5.a.i. Set default variables excludedBranches=() includedBranches=('') buildCommands=('./autogen.sh || :' ./configure make) initCommands=() postCommands=() @@ -57,12 +58,42 @@ testCommands=() builderID='' projectName="$(fossil info -R "${repository}" | awk '/^project-name:/{ sub(/^project-name: */, ""); gsub(/ /, ""); print; }')" tagSuffix='' tagPrefix='' -tagOmitRedundant='0' -tagOmitPass='0' +# tagOmit='all|pass|redundant|none' +tagOmit='none' +# buildResultsUpload='fail|all|none' +buildResultsUpload='fail' +# testResultsUpload='fail|all|none' +testResultsUpload='fail' + +### 5.a.ii. Default functions +function uploadBuildResults() { + ### XXX:TODO + : +} + +function uploadTestResults() { + ### XXX:TODO + : +} + +function uploadBuildArtifacts() { + ### XXX:TODO + : +} + +function fossilSetWikiPage() { + ### XXX:TODO + : +} + +function fossilUploadUV() { + ### XXX:TODO + : +} ## 5.b. Read config config="$(fossil cat -R "${repository}" -r trunk "${fossilCIDir}/config" 2>/dev/null)" || : ## 5.c Load config @@ -74,18 +105,10 @@ if [ -f ~/.fossil-ci/"${projectName}"/config ]; then . ~/.fossil-ci/"${projectName}"/config fi -## 5.d. Post-process config -### 5.d.i. Add builderID as a tag suffix if none was given -if [ -z "${tagSuffix}" ]; then - if [ -n "${builderID}" ]; then - tagSuffix="-${builderID}" - fi -fi - # 6. Perform any configured initialization for cmd in "${initCommands[@]}"; do eval "${cmd}" >/dev/null 2>/dev/null || : done @@ -149,10 +172,11 @@ ( eval "set -x; ${cmd}" ) || exit 1 done ) > "${builddir}/build.log" 2>&1 || build_pass='0' ### 7.g. Test the branch + tests_pass='-1' if [ "${build_pass}" = '1' ]; then tests_pass='1' ( cd "${branchdir}" || exit 1 @@ -163,18 +187,26 @@ fi ### 7.h. Tag the branch with tagsToAdd=() if [ "${build_pass}" = '1' ]; then - if [ "${tagOmitRedundant}" != '1' -a "${tagOmitPass}" != '1' ]; then - tagsToAdd=("${tagsToAdd[@]}" build-pass) - fi + case "${tagOmit}" in + all|pass|redundant) + ;; + *) + tagsToAdd=("${tagsToAdd[@]}" build-pass) + ;; + esac if [ "${tests_pass}" = '1' ]; then - if [ "${tagOmitPass}" != '1' ]; then - tagsToAdd=("${tagsToAdd[@]}" tests-pass) - fi + case "${tagOmit}" in + all|pass) + ;; + *) + tagsToAdd=("${tagsToAdd[@]}" tests-pass) + ;; + esac else tagsToAdd=("${tagsToAdd[@]}" tests-fail) fi else tagsToAdd=("${tagsToAdd[@]}" build-fail) @@ -186,14 +218,34 @@ done fossil amend -R "${repository}" "${branch}" "${tagsToAddOpts[@]}" > "${builddir}/update.log" 2>&1 ### 7.i. Upload the logs somewhere if requested - #### XXX:TODO + uploadBuildResults='0' + case "${buildResultsUpload}-${build_pass}" in + all-0|all-1|fail-0|pass-1) + uploadBuildResults='1' + ;; + esac + + uploadTestResults='0' + case "${buildResultsUpload}-${tests_pass}" in + all-0|all-1|fail-0|pass-1) + uploadTestResults='1' + ;; + esac + + if [ "${uploadBuildResults}" ]; then + uploadBuildResults "${branch}" "${checkout}" "${builddir}/build.log" || : + fi + + if [ "${uploadBuildResults}" ]; then + uploadTestResults "${branch}" "${checkout}" "${builddir}/test.log" || : + fi ### 7.j. Upload build artifacts somewhere if requested - #### XXX:TODO + uploadBuildArtifacts "${branch}" "${checkout}" "${branchdir}" || : ### 7.k. Get a list of tags tags=( $(fossil tag -R "${repository}" list "${branch}") ) # 8. Perform post-build work (e.g., for release engineering)