From: Yann Dirson Date: Wed, 29 Nov 2023 14:17:30 +0000 (+0100) Subject: ci: don't fail the pipeline when a WIP commit does not build X-Git-Tag: 0.3.0~15^2 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=dc4b844a500103f5dde11b8a9d7db63a0a6e8965;p=xen-guest-agent.git ci: don't fail the pipeline when a WIP commit does not build --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 561683d..7c469eb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -96,7 +96,10 @@ build-linux-everycommit: - !reference [.debian-build-template,before_script] - printf "\e[0Ksection_end:$(date +%s):before_script\r\e[0K\n" script: - # let git-rebase run the build for each commit + # let git-rebase run the build for each commit, but not fail with + # commit subject starts with "WIP" (gitlab also uses this string + # to switch a PR back to draft, mitigating the risk to push a + # failing commit) - git rebase --rebase-merges $CI_MERGE_REQUEST_DIFF_BASE_SHA --exec 'devscripts/gitlab-ci-runbuild.sh cargo build ${FEATURES} ${CARGO_FLAGS}' diff --git a/devscripts/gitlab-ci-runbuild.sh b/devscripts/gitlab-ci-runbuild.sh index 72c6d5f..ac61378 100755 --- a/devscripts/gitlab-ci-runbuild.sh +++ b/devscripts/gitlab-ci-runbuild.sh @@ -13,9 +13,23 @@ printf "\e[0Ksection_start:$(date +%s):${FOOTER_ID}[collapsed=true]\r\e[0K\e[1;3 # trace, but not outside of collapsed section set -x -"$@" +IGNORED_ERROR=0 +if ! "$@"; then + ret=$?; + case "$(git show --summary --format=format:%s)" in + WIP*) + IGNORED_ERROR=1 + ;; + *) + exit $ret + ;; + esac +fi # stop traces before closing collapsed section set +x # collapsable footer printf "\e[0Ksection_end:$(date +%s):${FOOTER_ID}\r\e[0K\n" + +# make any ignored error visible outside of collapsed section +[ $IGNORED_ERROR = 0 ] || printf "\e[1;31mIgnoring failure for WIP commit\e[1;0m\n"