From 3f4d6464ee2463291b5d6b65d8c40d6430c3c360 Mon Sep 17 00:00:00 2001 From: Enrico Tassi Date: Wed, 9 Dec 2020 17:44:03 +0100 Subject: [ci] simplify overlay scripts --- dev/ci/ci-common.sh | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'dev/ci/ci-common.sh') diff --git a/dev/ci/ci-common.sh b/dev/ci/ci-common.sh index 98ad834b4c..fdba690155 100644 --- a/dev/ci/ci-common.sh +++ b/dev/ci/ci-common.sh @@ -49,25 +49,34 @@ ls -l "$CI_BUILD_DIR" || true declare -A overlays -overlay() +# overlay [] +# creates an overlay for project using a given url and branch which is +# active for prnumber or prbranch. prbranch defaults to ref. +function overlay() { local project=$1 local ov_url=$2 local ov_ref=$3 - - if ! is_in_projects "$1"; then - echo "Error: $1 is not a known project which can be overlayed" - exit 1 + local ov_prnumber=$4 + local ov_prbranch=$5 + : "${ov_prbranch:=$ov_ref}" + + if [ "$CI_PULL_REQUEST" = "$ov_prnumber" ] || [ "$CI_BRANCH" = "$ov_prbranch" ]; then + if ! is_in_projects "$project"; then + echo "Error: $1 is not a known project which can be overlayed" + exit 1 + fi + + overlays[${project}_URL]=$ov_url + overlays[${project}_REF]=$ov_ref fi - - overlays[${project}_URL]=$ov_url - overlays[${project}_REF]=$ov_ref } set +x for overlay in "${ci_dir}"/user-overlays/*.sh; do # shellcheck source=/dev/null - . "${overlay}" + # the directoy can be empty + if [ -e "${overlay}" ]; then . "${overlay}"; fi done # shellcheck source=ci-basic-overlay.sh -- cgit v1.2.3