Make ci.sh accept a command

In order not to have to `source` it multiple times, leading to ugly
clutter in CI logs.
This commit is contained in:
Martin Kinkelin 2020-10-13 17:53:29 +02:00
parent 4979c54605
commit 0be663512e
3 changed files with 41 additions and 27 deletions

View file

@ -27,26 +27,18 @@ common_steps_template: &COMMON_STEPS_TEMPLATE
# create a `dmd` symlink to the repo dir, necessary for druntime/Phobos
ln -s $CIRRUS_WORKING_DIR ../dmd
install_host_compiler_script: |
source ci.sh
# kludge
# kludge for ci.sh
if [ "${DMD:0:4}" == "gdmd" ]; then export DMD="gdmd"; fi
if [ -z "${D_VERSION+x}" ]; then install_d "$DMD"; else install_d "$DMD-$D_VERSION"; fi
compiler="$DMD"
if [ -n "${D_VERSION+x}" ]; then compiler="$DMD-$D_VERSION"; fi
./ci.sh install_d "$compiler"
setup_repos_script: |
export BRANCH=${CIRRUS_BASE_BRANCH:-$CIRRUS_BRANCH}
source ci.sh
setup_repos
build_script: |
source ci.sh
build
test_dmd_script: |
source ci.sh
test_dmd
test_druntime_script: |
set -uexo pipefail
make -j$N -C ../druntime -f posix.mak MODEL=$MODEL unittest
test_phobos_script: |
set -uexo pipefail
make -j$N -C ../phobos -f posix.mak MODEL=$MODEL unittest
./ci.sh setup_repos
build_script: ./ci.sh build
test_dmd_script: ./ci.sh test_dmd
test_druntime_script: ./ci.sh test_druntime
test_phobos_script: ./ci.sh test_phobos
environment:
CIRRUS_CLONE_DEPTH: 50

32
ci.sh
View file

@ -12,8 +12,6 @@ if [ -z ${DMD+x} ] ; then echo "Variable 'DMD' needs to be set."; exit 1; fi
CURL_USER_AGENT="DMD-CI $(curl --version | head -n 1)"
build_path=generated/$OS_NAME/release/$MODEL
build_path=generated/$OS_NAME/release/$MODEL
# use faster ld.gold linker on linux
if [ "$OS_NAME" == "linux" ]; then
mkdir -p linker
@ -78,8 +76,8 @@ rebuild() {
# test druntime, phobos, dmd
test() {
test_dub_package
make -j$N -C ../druntime -f posix.mak MODEL=$MODEL unittest
make -j$N -C ../phobos -f posix.mak MODEL=$MODEL unittest
test_druntime
test_phobos
test_dmd
}
@ -93,6 +91,14 @@ test_dmd() {
fi
}
test_druntime() {
make -j$N -C ../druntime -f posix.mak MODEL=$MODEL unittest
}
test_phobos() {
make -j$N -C ../phobos -f posix.mak MODEL=$MODEL unittest
}
# test dub package
test_dub_package() {
source ~/dlang/*/activate # activate host compiler
@ -182,3 +188,21 @@ install_d() {
CURL_USER_AGENT="$CURL_USER_AGENT" bash "$install_sh" "$1"
fi
}
# Define commands
if [ "$#" -gt 0 ]; then
case $1 in
install_d) install_d "$2" ;;
setup_repos) setup_repos ;;
build) build ;;
rebuild) rebuild "${2:-}" ;;
test) test ;;
test_dmd) test_dmd ;;
test_druntime) test_druntime ;;
test_phobos) test_phobos ;;
test_dub_package) test_dub_package ;;
testsuite) testsuite ;;
*) echo "Unknown command: $1" >&2; exit 1 ;;
esac
fi

View file

@ -30,19 +30,17 @@ else
fi
export BRANCH
source ci.sh
################################################################################
# Always source a DMD instance
# Install D host compiler
################################################################################
install_d "$DMD"
./ci.sh install_d "$DMD"
################################################################################
# Define commands
################################################################################
case $1 in
setup) setup_repos ;;
testsuite) testsuite ;;
setup) ./ci.sh setup_repos ;;
testsuite) ./ci.sh testsuite ;;
esac