Cirrus CI: Extract prerequisites installation to cirrusci.sh

As preparation for druntime/Phobos CI, so that they can use this file
too instead of having to duplicate these steps in their .cirrus.yml.
This commit is contained in:
Martin Kinkelin 2020-10-13 18:18:41 +02:00
parent 56082c729f
commit ddfb4fbcd7
3 changed files with 50 additions and 32 deletions

View file

@ -1,40 +1,16 @@
common_steps_template: &COMMON_STEPS_TEMPLATE
install_prerequisites_script: |
set -uexo pipefail
if [ "$OS_NAME" == "linux" ]; then
packages="git-core make g++ gdb curl libcurl3 tzdata zip unzip xz-utils"
if [ "$MODEL" == "32" ]; then
dpkg --add-architecture i386
packages="$packages g++-multilib libcurl3-gnutls:i386"
fi
if [ "${DMD:0:4}" == "gdmd" ]; then
packages="$packages sudo software-properties-common wget"
fi
apt-get -q update
apt-get install -yq $packages
elif [ "$OS_NAME" == "darwin" ]; then
# required for install.sh
brew install gnupg
elif [ "$OS_NAME" == "freebsd" ]; then
packages="git gmake bash"
if [ "${D_VERSION:-x}" == "2.079.0" ] ; then
packages="$packages lang/gcc9"
fi
pkg install -y $packages
rm /usr/bin/make
ln -s /usr/local/bin/gmake /usr/bin/make
fi
# create a `dmd` symlink to the repo dir, necessary for druntime/Phobos
ln -s $CIRRUS_WORKING_DIR ../dmd
install_prerequisites_script: ./cirrusci.sh
install_host_compiler_script: |
set -uexo pipefail
# kludge for ci.sh
if [ "${DMD:0:4}" == "gdmd" ]; then export DMD="gdmd"; 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}
./ci.sh setup_repos
set -uexo pipefail
ln -s $CIRRUS_WORKING_DIR ../dmd
BRANCH="${CIRRUS_BASE_BRANCH:-$CIRRUS_BRANCH}" ./ci.sh setup_repos
build_script: ./ci.sh build
test_dmd_script: ./ci.sh test_dmd
test_druntime_script: ./ci.sh test_druntime
@ -46,7 +22,6 @@ environment:
MODEL: 64
DMD: dmd
N: 4
BRANCH: master
OS_NAME: linux
FULL_BUILD: true
@ -103,6 +78,7 @@ task:
timeout_in: 60m
environment:
OS_NAME: freebsd
install_bash_script: pkg install -y bash
<< : *COMMON_STEPS_TEMPLATE
task:
@ -115,4 +91,5 @@ task:
environment:
OS_NAME: freebsd
D_VERSION: 2.079.0
install_bash_script: pkg install -y bash
<< : *COMMON_STEPS_TEMPLATE

4
ci.sh
View file

@ -1,9 +1,8 @@
#!/bin/bash
#!/usr/bin/env bash
set -uexo pipefail
if [ -z ${N+x} ] ; then echo "Variable 'N' needs to be set."; exit 1; fi
if [ -z ${BRANCH+x} ] ; then echo "Variable 'BRANCH' needs to be set."; exit 1; fi
if [ -z ${OS_NAME+x} ] ; then echo "Variable 'OS_NAME' needs to be set."; exit 1; fi
if [ -z ${FULL_BUILD+x} ] ; then echo "Variable 'FULL_BUILD' needs to be set."; exit 1; fi
if [ -z ${MODEL+x} ] ; then echo "Variable 'MODEL' needs to be set."; exit 1; fi
@ -128,6 +127,7 @@ 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
for proj in druntime phobos; do
if [ ! -d ../$proj ]; then
if [ $BRANCH != master ] && [ $BRANCH != stable ] &&

41
cirrusci.sh Executable file
View file

@ -0,0 +1,41 @@
#!/usr/bin/env bash
# Installs the OS-specific prerequisites for Cirrus CI jobs.
# This file is invoked by .cirrus.yml and sets up the machine for
# the later steps with ci.sh.
set -uexo pipefail
# OS_NAME: linux|darwin|freebsd
if [ -z ${OS_NAME+x} ] ; then echo "Variable 'OS_NAME' needs to be set."; exit 1; fi
# MODEL: 32|64
if [ -z ${MODEL+x} ] ; then echo "Variable 'MODEL' needs to be set."; exit 1; fi
# DMD: dmd|ldc|gdmd-<version> (host compiler)
if [ -z ${DMD+x} ] ; then echo "Variable 'DMD' needs to be set."; exit 1; fi
# optional D_VERSION: fixed version of the (DMD) host compiler
if [ "$OS_NAME" == "linux" ]; then
packages="git-core make g++ gdb curl libcurl3 tzdata zip unzip xz-utils"
if [ "$MODEL" == "32" ]; then
dpkg --add-architecture i386
packages="$packages g++-multilib libcurl3-gnutls:i386"
fi
if [ "${DMD:0:4}" == "gdmd" ]; then
# ci.sh uses `sudo add-apt-repository ...` to add a PPA repo
packages="$packages sudo software-properties-common wget"
fi
apt-get -q update
apt-get install -yq $packages
elif [ "$OS_NAME" == "darwin" ]; then
# required for dlang install.sh
brew install gnupg
elif [ "$OS_NAME" == "freebsd" ]; then
packages="git gmake"
if [ "${D_VERSION:-x}" == "2.079.0" ] ; then
packages="$packages lang/gcc9"
fi
pkg install -y $packages
# replace default make by GNU make
rm /usr/bin/make
ln -s /usr/local/bin/gmake /usr/bin/make
fi