Skip to content
Snippets Groups Projects
.build.ci.sh 1008 B
Newer Older
#!/bin/bash
# This is wrapper to run the build.sh on CI

lintao@ihep.ac.cn's avatar
lintao@ihep.ac.cn committed
echo "CEPCSW_LCG_RELEASE: ${CEPCSW_LCG_RELEASE}"
echo "CEPCSW_LCG_PLATFORM: ${CEPCSW_LCG_PLATFORM}"
echo "CEPCSW_LCG_VERSION: ${CEPCSW_LCG_VERSION}"
echo "CEPCSW_BLDTOOL: ${CEPCSW_BLDTOOL}"
lintao@ihep.ac.cn's avatar
lintao@ihep.ac.cn committed
function build-with-log() {
    buildpid=
    logfile=mylog.txt

    if [ "$CEPCSW_LCG_RELEASE" = "KEY4HEP_STACK" ]; then
        logfile=mylog-k4.sh
        ./build-k4.sh >& ${logfile} &
        buildpid=$!
    else
        source setup.sh
        ./build.sh >& ${logfile} &
        buildpid=$!
    fi

    while ps -p $buildpid 2>/dev/null ; do
        sleep 60
    done &
    echoer=$!
lintao@ihep.ac.cn's avatar
lintao@ihep.ac.cn committed
    trap 'kill $echoer' 0
lintao@ihep.ac.cn's avatar
lintao@ihep.ac.cn committed
    wait $buildpid
    statuspid=$?
lintao@ihep.ac.cn's avatar
lintao@ihep.ac.cn committed
    tail -n100 ${logfile}
lintao@ihep.ac.cn's avatar
lintao@ihep.ac.cn committed
    exit $statuspid
}
lintao@ihep.ac.cn's avatar
lintao@ihep.ac.cn committed
function build-with-stdout() {
    if [ "$CEPCSW_LCG_RELEASE" = "KEY4HEP_STACK" ]; then
        ./build-k4.sh
    else
        source setup.sh
        ./build.sh
    fi
}

if [ -n "${GITHUB_ACTION}" ]; then
    build-with-log
else
    build-with-stdout
fi