github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/hack/get_ci_vm.sh (about) 1 #!/usr/bin/env bash 2 3 # 4 # For help and usage information, simply execute the script w/o any arguments. 5 # 6 # This script is intended to be run by Red Hat podman developers who need 7 # to debug problems specifically related to Cirrus-CI automated testing. 8 # It requires that you have been granted prior access to create VMs in 9 # google-cloud. For non-Red Hat contributors, VMs are available as-needed, 10 # with supervision upon request. 11 12 set -e 13 14 SCRIPT_FILEPATH=$(realpath "${BASH_SOURCE[0]}") 15 SCRIPT_DIRPATH=$(dirname "$SCRIPT_FILEPATH") 16 REPO_DIRPATH=$(realpath "$SCRIPT_DIRPATH/../") 17 18 # Help detect if we were called by get_ci_vm container 19 GET_CI_VM="${GET_CI_VM:-0}" 20 in_get_ci_vm() { 21 if ((GET_CI_VM==0)); then 22 echo "Error: $1 is not intended for use in this context" 23 exit 2 24 fi 25 } 26 27 # get_ci_vm APIv1 container entrypoint calls into this script 28 # to obtain required repo. specific configuration options. 29 if [[ "$1" == "--config" ]]; then 30 in_get_ci_vm "$1" 31 cat <<EOF 32 DESTDIR="/var/tmp/go/src/github.com/containers/podman" 33 UPSTREAM_REPO="https://github.com/containers/podman.git" 34 CI_ENVFILE="/etc/ci_environment" 35 GCLOUD_PROJECT="libpod-218412" 36 GCLOUD_IMGPROJECT="libpod-218412" 37 GCLOUD_CFG="libpod" 38 GCLOUD_ZONE="${GCLOUD_ZONE:-us-central1-a}" 39 GCLOUD_CPUS="2" 40 GCLOUD_MEMORY="4Gb" 41 GCLOUD_DISK="200" 42 EOF 43 elif [[ "$1" == "--setup" ]]; then 44 in_get_ci_vm "$1" 45 # get_ci_vm container entrypoint calls us with this option on the 46 # Cirrus-CI environment instance, to perform repo.-specific setup. 47 cd $REPO_DIRPATH 48 echo "+ Loading ./contrib/cirrus/lib.sh" > /dev/stderr 49 source ./contrib/cirrus/lib.sh 50 echo "+ Mimicking .cirrus.yml build_task" > /dev/stderr 51 make install.tools 52 make binaries 53 make docs 54 echo "+ Running environment setup" > /dev/stderr 55 ./contrib/cirrus/setup_environment.sh 56 else 57 # Create and access VM for specified Cirrus-CI task 58 mkdir -p $HOME/.config/gcloud/ssh 59 podman run -it --rm \ 60 --tz=local \ 61 -e NAME="$USER" \ 62 -e SRCDIR=/src \ 63 -e GCLOUD_ZONE="$GCLOUD_ZONE" \ 64 -e A_DEBUG="${A_DEBUG:-0}" \ 65 -v $REPO_DIRPATH:/src:O \ 66 -v $HOME/.config/gcloud:/root/.config/gcloud:z \ 67 -v $HOME/.config/gcloud/ssh:/root/.ssh:z \ 68 quay.io/libpod/get_ci_vm:latest "$@" 69 fi