ci.sh: Replace BRANCH env variable by explicit setup_repos command arg

This commit is contained in:
Martin Kinkelin 2020-10-14 15:06:32 +02:00
parent f1c0b2736a
commit bd6f181f4d
3 changed files with 7 additions and 8 deletions

View file

@ -8,7 +8,7 @@ common_steps_template: &COMMON_STEPS_TEMPLATE
setup_repos_script: | setup_repos_script: |
set -uexo pipefail set -uexo pipefail
ln -s $CIRRUS_WORKING_DIR ../dmd 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 build_script: ./ci.sh build
test_dmd_script: ./ci.sh test_dmd test_dmd_script: ./ci.sh test_dmd
test_druntime_script: ./ci.sh test_druntime test_druntime_script: ./ci.sh test_druntime

10
ci.sh
View file

@ -135,15 +135,15 @@ test_dub_package() {
# clone druntime/phobos repos if not already available # clone druntime/phobos repos if not already available
setup_repos() { 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 for proj in druntime phobos; do
if [ ! -d ../$proj ]; then if [ ! -d ../$proj ]; then
if [ $BRANCH != master ] && [ $BRANCH != stable ] && if [ $branch != master ] && [ $branch != stable ] &&
! git ls-remote --exit-code --heads https://github.com/dlang/$proj.git $BRANCH > /dev/null; then ! 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 # use master as fallback for other repos to test feature branches
clone https://github.com/dlang/$proj.git ../$proj master clone https://github.com/dlang/$proj.git ../$proj master
else else
clone https://github.com/dlang/$proj.git ../$proj $BRANCH clone https://github.com/dlang/$proj.git ../$proj $branch
fi fi
fi fi
done done
@ -206,7 +206,7 @@ install_d() {
if [ "$#" -gt 0 ]; then if [ "$#" -gt 0 ]; then
case $1 in case $1 in
install_d) install_d "$2" ;; # ci.sh install_d dmd[-<version>]|ldc[-<version>]|gdmd-<version> install_d) install_d "$2" ;; # ci.sh install_d dmd[-<version>]|ldc[-<version>]|gdmd-<version>
setup_repos) setup_repos ;; setup_repos) setup_repos "$2" ;; # ci.sh setup_repos <git branch>
build) build ;; build) build ;;
rebuild) rebuild "${2:-}" ;; # ci.sh rebuild [1] (use `1` to compare binaries to test reproducible build) rebuild) rebuild "${2:-}" ;; # ci.sh rebuild [1] (use `1` to compare binaries to test reproducible build)
test) test ;; test) test ;;

View file

@ -28,7 +28,6 @@ if [ -n "${PULL_REQUEST_NUMBER:-}" ]; then
else else
BRANCH="${BRANCH_NAME}" BRANCH="${BRANCH_NAME}"
fi fi
export BRANCH
################################################################################ ################################################################################
# Define commands # Define commands
@ -36,7 +35,7 @@ export BRANCH
case $1 in case $1 in
setup) setup)
./ci.sh setup_repos ./ci.sh setup_repos "$BRANCH"
;; ;;
testsuite) testsuite)
if [ "$DMD" == "gdc" ] || [ "$DMD" == "gdmd" ] ; then if [ "$DMD" == "gdc" ] || [ "$DMD" == "gdmd" ] ; then