]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
automation: add a script to build newly pushed commits in Gitlab CI
authorWei Liu <wei.liu2@citrix.com>
Thu, 28 Feb 2019 12:50:02 +0000 (12:50 +0000)
committerWei Liu <wei.liu2@citrix.com>
Fri, 5 Apr 2019 10:15:36 +0000 (11:15 +0100)
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Doug Goldstein <cardoe@cardoe.com>
automation/gitlab-ci/build-each-commit.sh [new file with mode: 0755]

diff --git a/automation/gitlab-ci/build-each-commit.sh b/automation/gitlab-ci/build-each-commit.sh
new file mode 100755 (executable)
index 0000000..6b79984
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# For a newly pushed branch the BEFORE_SHA will be all 0s
+if [[ ${CI_COMMIT_BEFORE_SHA} == 0000000000000000000000000000000000000000 ]]; then
+    echo "Newly pushed branch, skipped"
+    exit 0
+fi
+
+git merge-base --is-ancestor ${CI_COMMIT_BEFORE_SHA} ${CI_COMMIT_SHA}
+if [[ $? -ne 0 ]]; then
+    echo "${CI_COMMIT_SHA} is not a descendent of ${CI_COMMIT_BEFORE_SHA}, skipped"
+    exit 0
+fi
+
+NON_SYMBOLIC_REF=1 ./automation/scripts/build-test.sh ${CI_COMMIT_BEFORE_SHA} ${CI_COMMIT_SHA} \
+    bash -c "make -j4 distclean && ./automation/scripts/build"