]> xenbits.xensource.com Git - xen-guest-agent.git/commitdiff
ci: don't fail the pipeline when a WIP commit does not build
authorYann Dirson <yann.dirson@vates.fr>
Wed, 29 Nov 2023 14:17:30 +0000 (15:17 +0100)
committerYann Dirson <yann.dirson@vates.fr>
Wed, 29 Nov 2023 17:29:27 +0000 (18:29 +0100)
.gitlab-ci.yml
devscripts/gitlab-ci-runbuild.sh

index 561683d42838a3240c49ed8f9c28c09bf0c9cb3a..7c469eb374e4acbd760883679ac451dbe45b5cbb 100644 (file)
@@ -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}'
 
index 72c6d5f6f9aa78c6d5fe8796ef801f3b8c676820..ac61378e1e48708465ae67da1f8cfac49d0b117c 100755 (executable)
@@ -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"