diff options
-rw-r--r-- | .cirrus.yml | 17 | ||||
-rwxr-xr-x | contrib/gate/entrypoint.sh | 2 | ||||
-rwxr-xr-x | hack/get_ci_vm.sh | 44 |
3 files changed, 41 insertions, 22 deletions
diff --git a/.cirrus.yml b/.cirrus.yml index d097c9f47..7bc00dbb5 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -109,6 +109,7 @@ gating_task: env: CIRRUS_WORKING_DIR: "/usr/src/libpod" + GOSRC: "/go/src/github.com/containers/libpod" # Runs within Cirrus's "community cluster" container: @@ -119,17 +120,20 @@ gating_task: timeout_in: 20m gate_script: + # N/B: entrypoint.sh resets $GOSRC (same as make clean) - '/usr/local/bin/entrypoint.sh validate' - '/usr/local/bin/entrypoint.sh lint' - '${CIRRUS_WORKING_DIR}/${SCRIPT_BASE}/test/test_dot_cirrus_yaml.py' # This task builds Podman with different buildtags to ensure the build does - # not break. + # not break. It also verifies all sub-commands have man pages. build_script: - - '/usr/local/bin/entrypoint.sh clean podman' + - '/usr/local/bin/entrypoint.sh podman' + - 'cd $GOSRC && ./hack/podman-commands.sh' + # N/B: need 'clean' so some commited files are re-generated. - '/usr/local/bin/entrypoint.sh clean podman-remote' - '/usr/local/bin/entrypoint.sh clean podman BUILDTAGS="exclude_graphdriver_devicemapper selinux seccomp"' - - '/usr/local/bin/entrypoint.sh clean podman-remote-darwin' + - '/usr/local/bin/entrypoint.sh podman-remote-darwin' on_failure: master_script: '$CIRRUS_WORKING_DIR/$SCRIPT_BASE/notice_master_failure.sh' @@ -178,13 +182,12 @@ build_each_commit_task: cpu: 2 memory: "4Gb" disk: 40 - matrix: - image_name: "${FEDORA_CACHE_IMAGE_NAME}" + image_name: "${FEDORA_CACHE_IMAGE_NAME}" timeout_in: 30m - script: - - '$SCRIPT_BASE/setup_environment.sh' + setup_environment_script: '$SCRIPT_BASE/setup_environment.sh' + build_each_commit_script: - 'git fetch --depth $CIRRUS_CLONE_DEPTH origin $CIRRUS_BASE_BRANCH' - 'env GOPATH=/var/tmp/go/ make build-all-new-commits GIT_BASE_BRANCH=origin/$CIRRUS_BASE_BRANCH' diff --git a/contrib/gate/entrypoint.sh b/contrib/gate/entrypoint.sh index e16094cc0..0189cf7c5 100755 --- a/contrib/gate/entrypoint.sh +++ b/contrib/gate/entrypoint.sh @@ -10,6 +10,6 @@ # Working from a copy avoids needing to perturb the actual source files mkdir -p "$GOSRC" /usr/bin/rsync --recursive --links --quiet --safe-links \ - --perms --times "${SRCPATH}/" "${GOSRC}/" + --perms --times --delete "${SRCPATH}/" "${GOSRC}/" cd "$GOSRC" make "$@" diff --git a/hack/get_ci_vm.sh b/hack/get_ci_vm.sh index 071b62434..d0325b8ae 100755 --- a/hack/get_ci_vm.sh +++ b/hack/get_ci_vm.sh @@ -24,14 +24,15 @@ ROOTLESS_USER="madcowdog" # Shared tmp directory between container and us TMPDIR=$(mktemp -d --tmpdir $(basename $0)_tmpdir_XXXXXX) -# Command shortcuts save some typing -PGCLOUD="$GCLOUD_SUDO podman run -it --rm -e AS_ID=$UID -e AS_USER=$USER --security-opt label=disable -v /home/$USER:$HOME -v $TMPDIR:/tmp $GCLOUD_IMAGE --configuration=libpod --project=$PROJECT" -SCP_CMD="$PGCLOUD compute scp" - LIBPODROOT=$(realpath "$(dirname $0)/../") # else: Assume $PWD is the root of the libpod repository [[ "$LIBPODROOT" != "/" ]] || LIBPODROOT=$PWD +# Command shortcuts save some typing (asumes $LIBPODROOT is subdir of $HOME) +PGCLOUD="$GCLOUD_SUDO podman run -it --rm -e AS_ID=$UID -e AS_USER=$USER --security-opt label=disable -v $TMPDIR:$HOME -v $HOME/.config/gcloud:$HOME/.config/gcloud -v $HOME/.config/gcloud/ssh:$HOME/.ssh -v $LIBPODROOT:$LIBPODROOT $GCLOUD_IMAGE --configuration=libpod --project=$PROJECT" +SCP_CMD="$PGCLOUD compute scp" + + showrun() { if [[ "$1" == "--background" ]] then @@ -58,6 +59,7 @@ trap cleanup EXIT delvm() { echo -e "\n" echo -e "\n${YEL}Offering to Delete $VMNAME ${RED}(Might take a minute or two)${NOR}" + echo -e "\n${YEL}Note: It's safe to answer N, then re-run script again later.${NOR}" showrun $CLEANUP_CMD # prompts for Yes/No cleanup } @@ -95,16 +97,20 @@ for k,v in env.items(): } parse_args(){ + echo -e "$USAGE_WARNING" + if [[ -z "$1" ]] then show_usage "Must specify at least one command-line parameter." elif [[ "$1" == "-p" ]] then + echo -e "${YEL}Hint: Use -p for package-based dependencies or -s for source-based.${NOR}" DEPS="PACKAGE_DEPS=true SOURCE_DEPS=false" IMAGE_NAME="$2" elif [[ "$1" == "-s" ]] then + echo -e "${RED}Using source-based dependencies.${NOR}" DEPS="PACKAGE_DEPS=false SOURCE_DEPS=true" IMAGE_NAME="$2" elif [[ "$1" == "-r" ]] @@ -112,6 +118,7 @@ parse_args(){ DEPS="ROOTLESS_USER=$ROOTLESS_USER" IMAGE_NAME="$2" else # no -s or -p + echo -e "${RED}Using package-based dependencies.${NOR}" DEPS="$(get_env_vars)" IMAGE_NAME="$1" fi @@ -126,8 +133,6 @@ parse_args(){ show_usage "This script must be run as a regular user." fi - echo -e "$USAGE_WARNING" - SETUP_CMD="env $DEPS $GOSRC/contrib/cirrus/setup_environment.sh" VMNAME="${VMNAME:-${USER}-${IMAGE_NAME}}" CREATE_CMD="$PGCLOUD compute instances create --zone=$ZONE --image=${IMAGE_NAME} --custom-cpu=$CPUS --custom-memory=$MEMORY --boot-disk-size=$DISK --labels=in-use-by=$USER $VMNAME" @@ -137,8 +142,21 @@ parse_args(){ ##### main +[[ "${LIBPODROOT%%${LIBPODROOT##$HOME}}" == "$HOME" ]] || \ + show_usage "Repo clone must be sub-dir of $HOME" + +cd "$LIBPODROOT" + parse_args $@ +# Ensure mount-points and data directories exist on host as $USER. Also prevents +# permission-denied errors during cleanup() b/c `sudo podman` created mount-points +# owned by root. +mkdir -p $TMPDIR/${LIBPODROOT##$HOME} +mkdir -p $TMPDIR/.ssh +mkdir -p {$HOME,$TMPDIR}/.config/gcloud/ssh +chmod 700 {$HOME,$TMPDIR}/.config/gcloud/ssh $TMPDIR/.ssh + cd $LIBPODROOT # Attempt to determine if named 'libpod' gcloud configuration exists @@ -164,10 +182,9 @@ then fi # Couldn't make rsync work with gcloud's ssh wrapper :( -TARBALL_BASENAME=$VMNAME.tar.bz2 -TARBALL=/tmp/$TARBALL_BASENAME +TARBALL=$VMNAME.tar.bz2 echo -e "\n${YEL}Packing up repository into a tarball $VMNAME.${NOR}" -showrun --background tar cjf $TMPDIR/$TARBALL_BASENAME --warning=no-file-changed -C $LIBPODROOT . +showrun --background tar cjf $TMPDIR/$TARBALL --warning=no-file-changed -C $LIBPODROOT . trap delvm INT # Allow deleting VM if CTRL-C during create # This fails if VM already exists: permit this usage to re-init @@ -178,6 +195,7 @@ showrun $CREATE_CMD || true # allow re-running commands below when "delete: N" trap delvm EXIT echo -e "\n${YEL}Waiting up to 30s for ssh port to open${NOR}" +trap 'COUNT=9999' INT ATTEMPTS=10 for (( COUNT=1 ; COUNT <= $ATTEMPTS ; COUNT++ )) do @@ -202,17 +220,15 @@ showrun $SSH_CMD --command "mkdir -p $GOSRC" echo -e "\n${YEL}Transfering tarball to $VMNAME.${NOR}" wait -showrun $SCP_CMD $TARBALL root@$VMNAME:$TARBALL +showrun $SCP_CMD $HOME/$TARBALL root@$VMNAME:/tmp/$TARBALL echo -e "\n${YEL}Unpacking tarball into $GOSRC on $VMNAME.${NOR}" -showrun $SSH_CMD --command "tar xjf $TARBALL -C $GOSRC" +showrun $SSH_CMD --command "tar xjf /tmp/$TARBALL -C $GOSRC" echo -e "\n${YEL}Removing tarball on $VMNAME.${NOR}" -showrun $SSH_CMD --command "rm -f $TARBALL" +showrun $SSH_CMD --command "rm -f /tmp/$TARBALL" echo -e "\n${YEL}Executing environment setup${NOR}" -[[ "$1" == "-p" ]] && echo -e "${RED}Using package-based dependencies.${NOR}" -[[ "$1" == "-s" ]] && echo -e "${RED}Using source-based dependencies.${NOR}" showrun $SSH_CMD --command "$SETUP_CMD" echo -e "\n${YEL}Connecting to $VMNAME ${RED}(option to delete VM upon logout).${NOR}\n" |