From bd6f181f4d7b788d3f1d27cabfeb79d02e4e0154 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Wed, 14 Oct 2020 15:06:32 +0200 Subject: [PATCH] ci.sh: Replace BRANCH env variable by explicit setup_repos command arg --- .cirrus.yml | 2 +- ci.sh | 10 +++++----- semaphoreci.sh | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 09bc07bb79..861ef0eac2 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -8,7 +8,7 @@ common_steps_template: &COMMON_STEPS_TEMPLATE setup_repos_script: | set -uexo pipefail ln -s $CIRRUS_WORKING_DIR ../dmd - BRANCH="${CIRRUS_BASE_BRANCH:-$CIRRUS_BRANCH}" ./ci.sh setup_repos + ./ci.sh setup_repos "${CIRRUS_BASE_BRANCH:-$CIRRUS_BRANCH}" build_script: ./ci.sh build test_dmd_script: ./ci.sh test_dmd test_druntime_script: ./ci.sh test_druntime diff --git a/ci.sh b/ci.sh index 334bbb1dfd..55d27e5459 100755 --- a/ci.sh +++ b/ci.sh @@ -135,15 +135,15 @@ test_dub_package() { # clone druntime/phobos repos if not already available setup_repos() { - if [ -z ${BRANCH+x} ] ; then echo "Variable 'BRANCH' needs to be set."; exit 1; fi + local branch="$1" for proj in druntime phobos; do if [ ! -d ../$proj ]; then - if [ $BRANCH != master ] && [ $BRANCH != stable ] && - ! git ls-remote --exit-code --heads https://github.com/dlang/$proj.git $BRANCH > /dev/null; then + if [ $branch != master ] && [ $branch != stable ] && + ! git ls-remote --exit-code --heads https://github.com/dlang/$proj.git $branch > /dev/null; then # use master as fallback for other repos to test feature branches clone https://github.com/dlang/$proj.git ../$proj master else - clone https://github.com/dlang/$proj.git ../$proj $BRANCH + clone https://github.com/dlang/$proj.git ../$proj $branch fi fi done @@ -206,7 +206,7 @@ install_d() { if [ "$#" -gt 0 ]; then case $1 in install_d) install_d "$2" ;; # ci.sh install_d dmd[-]|ldc[-]|gdmd- - setup_repos) setup_repos ;; + setup_repos) setup_repos "$2" ;; # ci.sh setup_repos build) build ;; rebuild) rebuild "${2:-}" ;; # ci.sh rebuild [1] (use `1` to compare binaries to test reproducible build) test) test ;; diff --git a/semaphoreci.sh b/semaphoreci.sh index f3fc9a346a..4ce5f3d7a9 100755 --- a/semaphoreci.sh +++ b/semaphoreci.sh @@ -28,7 +28,6 @@ if [ -n "${PULL_REQUEST_NUMBER:-}" ]; then else BRANCH="${BRANCH_NAME}" fi -export BRANCH ################################################################################ # Define commands @@ -36,7 +35,7 @@ export BRANCH case $1 in setup) - ./ci.sh setup_repos + ./ci.sh setup_repos "$BRANCH" ;; testsuite) if [ "$DMD" == "gdc" ] || [ "$DMD" == "gdmd" ] ; then