Fixes based on review feedback
Thanks @rhatdan and @lsm5 Signed-off-by: Chris Evich <cevich@redhat.com>
This commit is contained in:
parent
3c0cc05e1c
commit
31b5191e6f
|
|
@ -1,18 +1,45 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script can be run manually (assuming docker-daemon access) as-is.
|
||||
# Or, export SPCCMD=bash to get your hands less clean.
|
||||
set -e
|
||||
|
||||
set -ex
|
||||
# This script can be run manually - assuming password-less sudo access
|
||||
# and a docker-daemon running.
|
||||
|
||||
FQIN="${FQIN:-docker.io/cevich/travis_ubuntu:latest}"
|
||||
SPCCMD="${SPCCMD:-./.spc_ci_test.sh}"
|
||||
FQIN="docker.io/cevich/travis_ubuntu:latest"
|
||||
|
||||
REPO_HOST='github.com'
|
||||
REPO_OWNER='containers'
|
||||
|
||||
REPO_NAME=$(basename $(git rev-parse --show-toplevel))
|
||||
REPO_VOL_DEST="/root/go/src/$REPO_HOST/$REPO_OWNER/$REPO_NAME"
|
||||
|
||||
# Volume-mounting the repo into the SPC makes a giant mess of permissions
|
||||
# on the host. This really sucks for developers, so make a copy for use
|
||||
# in the SPC separate from the host, throw it away when this script exits.
|
||||
echo
|
||||
echo "Making temporary copy of $PWD that will appear in SPC as $REPO_VOL_DEST"
|
||||
TMP_SPC_REPO_COPY=$(mktemp -p '' -d ${REPO_NAME}_XXXXXX)
|
||||
trap "sudo rm -rf $TMP_SPC_REPO_COPY" EXIT
|
||||
/usr/bin/rsync --recursive --links --delete-after --quiet \
|
||||
--delay-updates --whole-file --safe-links \
|
||||
--perms --times --checksum "${PWD}/" "${TMP_SPC_REPO_COPY}/" &
|
||||
|
||||
SPC_ARGS="--interactive --rm --privileged --ipc=host --pid=host --net=host"
|
||||
VOL_ARGS="-v ${REPO_VOL:-$PWD}:${REPO_VOL:-$PWD}:z
|
||||
|
||||
# In Travis $PWD == $TRAVIS_BUILD_DIR == a subdir of $HOME == /home/travis/
|
||||
VOL_ARGS="-v $TMP_SPC_REPO_COPY:$REPO_VOL_DEST
|
||||
-v /run:/run -v /etc/localtime:/etc/localtime
|
||||
-v /var/log:/var/log -v /sys/fs/cgroup:/sys/fs/cgroup
|
||||
-v /var/run/docker.sock:/var/run/docker.sock
|
||||
--workdir ${TRAVIS_BUILD_DIR:-$PWD}"
|
||||
ENV_ARGS="-e HOME=${REPO_VOL:-$PWD} -e GO_VERSION=${GO_VERSION:-stable}"
|
||||
--workdir $REPO_VOL_DEST"
|
||||
|
||||
ENV_ARGS="-e GO_VERSION=${GO_VERSION:-stable} -e HOME=/root -e SHELL=/bin/bash"
|
||||
|
||||
echo
|
||||
echo "Preparing to run $SPCCMD in a $FQIN SPC."
|
||||
echo "Override either, for a different experience (e.g. SPCCMD=bash)"
|
||||
set -x
|
||||
sudo docker pull $FQIN
|
||||
wait # for rsync if not finished
|
||||
sudo docker run -t $SPC_ARGS $VOL_ARGS $ENV_ARGS $TRAVIS_ENV $FQIN $SPCCMD
|
||||
|
|
|
|||
|
|
@ -1,50 +1,53 @@
|
|||
#!/bin/bash
|
||||
|
||||
# N/B: This script is intended to be executed in an SPC by .run_ci_tests.sh
|
||||
# Using it otherwise may result in unplesent side-effects
|
||||
# Using it otherwise may result in unplesent side-effects.
|
||||
|
||||
# Additional packages needed that aren't already in the base image
|
||||
DEBS="btrfs-tools libdevmapper-dev"
|
||||
DEBS="${DEBS:-btrfs-tools libdevmapper-dev}"
|
||||
|
||||
export GO_VERSION="${GO_VERSION:-stable}"
|
||||
|
||||
# Don't want to see this spam...unless it breaks
|
||||
echo
|
||||
echo "Updating/Installing: $DEBS"
|
||||
TMPFILE=$(mktemp)
|
||||
set +e
|
||||
echo "Updating/Installing: $DEBS"
|
||||
(
|
||||
set -x
|
||||
apt-get -qq update && apt-get install -qq $DEBS
|
||||
) &> $TMPFILE
|
||||
set -e
|
||||
if [[ "$?" -gt "0" ]]
|
||||
then
|
||||
cat $TMPFILE
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
export HOME="/repo_copy"
|
||||
echo "Copying everything to $HOME so volume isn't cluttered up"
|
||||
mkdir -p "$HOME"
|
||||
rsync --recursive --links --delay-updates --whole-file \
|
||||
--safe-links --perms --times --checksum ./ "${HOME}/"
|
||||
cd "$HOME"
|
||||
|
||||
# FIXME: All a total guess, someone intelligent should fix this
|
||||
export GOPATH="$HOME/"
|
||||
export PATH="${PATH}:${GOPATH//://bin:}/bin"
|
||||
|
||||
echo "Setting up for go $GO_VERSION - export GO_VERSION=whatever for something different"
|
||||
# Ref: https://github.com/travis-ci/gimme/blob/master/README.md
|
||||
mkdir -p "$HOME/bin"
|
||||
curl -sL -o $HOME/bin/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme
|
||||
chmod +x $HOME/bin/gimme
|
||||
GIMME_OUTPUT="$($HOME/bin/gimme $GO_VERSION | tee -a $HOME/.bashrc)" && eval "$GIMME_OUTPUT"
|
||||
echo
|
||||
echo "Setting up for go version \"$GO_VERSION\" (export GO_VERSION=something for that instead)"
|
||||
if [[ ! -d "$HOME/.gimme" ]]
|
||||
then
|
||||
# Ref: https://github.com/travis-ci/gimme/blob/master/README.md
|
||||
mkdir -p "$HOME/bin"
|
||||
curl -sL -o $HOME/bin/gimme https://raw.githubusercontent.com/travis-ci/gimme/master/gimme
|
||||
chmod +x $HOME/bin/gimme
|
||||
# Set env. vars here and for any future bash sessions
|
||||
X=$(echo 'export GOPATH="$HOME/go"' | tee -a $HOME/.bashrc) && eval "$X"
|
||||
X=$(echo 'export PATH="${PATH}:$HOME/bin:${GOPATH//://bin:}/bin"' | tee -a $HOME/.bashrc) && eval "$X"
|
||||
X="$($HOME/bin/gimme $GO_VERSION | tee -a $HOME/.bashrc)" && eval "$X"
|
||||
unset X
|
||||
fi
|
||||
source "$HOME/.bashrc"
|
||||
|
||||
echo
|
||||
echo "Build Environment:"
|
||||
env
|
||||
go env
|
||||
echo "PATH=$PATH"
|
||||
echo "PWD=$PWD"
|
||||
|
||||
echo
|
||||
echo "Building/Running tests"
|
||||
|
||||
make install.tools
|
||||
make local-binary docs local-cross local-validate
|
||||
make local-test-unit local-test-integration
|
||||
|
|
|
|||
|
|
@ -12,11 +12,10 @@ services:
|
|||
|
||||
env:
|
||||
global:
|
||||
# In Travis $PWD == $TRAVIS_BUILD_DIR == subdir of $HOME, this makes that happen
|
||||
- REPO_VOL=$HOME
|
||||
- TRAVIS_ENV="-e TRAVIS=$TRAVIS
|
||||
-e CI=$CI
|
||||
-e TRAVIS_COMMIT=$TRAVIS_COMMIT
|
||||
-e TRAVIS_COMMIT_RANGE=$TRAVIS_COMMIT_RANGE
|
||||
-e TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG
|
||||
-e TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST
|
||||
-e TRAVIS_PULL_REQUEST_SHA=$TRAVIS_PULL_REQUEST_SHA
|
||||
|
|
@ -28,7 +27,6 @@ env:
|
|||
- GO_VERSION="stable"
|
||||
- GO_VERSION="1.9"
|
||||
- GO_VERSION="1.8"
|
||||
- GO_VERSION="1.7"
|
||||
|
||||
before_install:
|
||||
- sudo apt-get -qq update
|
||||
|
|
@ -36,5 +34,6 @@ before_install:
|
|||
script:
|
||||
- echo "Travis/host environment:"
|
||||
- env
|
||||
- echo "Running tests in SPC"
|
||||
- echo
|
||||
- echo "Running tests in SPC using ./.run_ci_tests.sh"
|
||||
- ./.run_ci_tests.sh
|
||||
|
|
|
|||
Loading…
Reference in New Issue