github.com/anuvu/storage@v1.12.13/hack/run_ci_tests.sh (about)

     1  #!/bin/bash
     2  
     3  set -e
     4  
     5  # This script can be run manually - assuming password-less sudo access
     6  # and a docker-daemon running.  To play in the SPC, just
     7  # `export SPCCMD=bash` beforehand.
     8  
     9  SPCCMD="${SPCCMD:-./hack/spc_ci_test.sh}"
    10  DISTRO="${DISTRO:-ubuntu}"
    11  FQIN="docker.io/cevich/travis_${DISTRO}:latest"
    12  
    13  # This can take a while, start it going as early as possible
    14  sudo docker info
    15  sudo docker pull $FQIN &
    16  
    17  REPO_DIR=$(realpath "$(dirname $0)/../")  # assume parent directory of 'hack'
    18  REPO_HOST=${REPO_HOST:-github.com}  # required for go building/testing
    19  # Otherwise undiscoverable, default to parent dir of $REPO_DIR outside of travis
    20  REPO_OWNER=$(echo "$TRAVIS_REPO_SLUG" | cut -d / -f 1)  # may be empty
    21  REPO_OWNER=${REPO_OWNER:-$(basename $(realpath $(dirname $REPO_DIR)))}
    22  REPO_NAME=$(basename $(git rev-parse --show-toplevel))
    23  # In Travis $PWD == $TRAVIS_BUILD_DIR == $HOME/$REPO_OWNER/$REPO_NAME
    24  TRAVIS_BUILD_DIR="/root/$REPO_OWNER/$REPO_NAME"
    25  WORKDIR="/root/go/src/$REPO_HOST/$REPO_OWNER/$REPO_NAME"
    26  
    27  # Volume-mounting the repo into the SPC makes a giant mess of permissions
    28  # on the host.  This really sucks for developers, so make a copy for use
    29  # in the SPC separate from the host, throw it away when this script exits.
    30  echo
    31  echo "Making temporary copy of $REPO_DIR that"
    32  echo "will appear in SPC as $WORKDIR"
    33  TMP_SPC_REPO_COPY=$(mktemp -p '' -d ${REPO_NAME}_XXXXXX)
    34  trap "sudo rm -rf $TMP_SPC_REPO_COPY" EXIT
    35  /usr/bin/rsync --recursive --links --delete-after --quiet \
    36                 --delay-updates --whole-file --safe-links \
    37                 --perms --times "${REPO_DIR}/" "${TMP_SPC_REPO_COPY}/" &
    38  
    39  SPC_ARGS="--interactive --rm --privileged --ipc=host --pid=host --net=host"
    40  
    41  VOL_ARGS="-v $TMP_SPC_REPO_COPY:$WORKDIR
    42            -v /run:/run -v /etc/localtime:/etc/localtime
    43            -v /var/log:/var/log -v /sys/fs/cgroup:/sys/fs/cgroup
    44            -v /var/run/docker.sock:/var/run/docker.sock
    45            --tmpfs /tmp:rw,nosuid,nodev,exec,relatime,mode=1777,size=50%
    46            --workdir $WORKDIR"
    47  
    48  ENV_ARGS="-e GO_VERSION=${GO_VERSION:-stable} -e HOME=/root -e SHELL=/bin/bash
    49            -e SPC=true -e DISTRO=$DISTRO -e REPO=$REPO_HOST/$REPO_OWNER/$REPO_NAME"
    50  
    51  echo
    52  echo "Preparing to run \$SPCMD=$SPCCMD in a \$DISTRO=$DISTRO SPC."
    53  echo "Override either for a different experience."
    54  wait  # for backgrounded processes to finish
    55  echo
    56  set -x
    57  sudo docker run -t $SPC_ARGS $VOL_ARGS $ENV_ARGS $TRAVIS_ENV $FQIN $SPCCMD