github.com/containers/podman/v5@v5.1.0-rc1/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 what get_ci_vm container called this script
    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"  # handles GET_CI_VM==0 case
    31      case "$GET_CI_VM" in
    32          1)
    33              cat <<EOF
    34  DESTDIR="/var/tmp/go/src/github.com/containers/podman"
    35  UPSTREAM_REPO="https://github.com/containers/podman.git"
    36  CI_ENVFILE="/etc/ci_environment"
    37  GCLOUD_PROJECT="libpod-218412"
    38  GCLOUD_IMGPROJECT="libpod-218412"
    39  GCLOUD_CFG="libpod"
    40  GCLOUD_ZONE="${GCLOUD_ZONE:-us-central1-a}"
    41  GCLOUD_CPUS="2"
    42  GCLOUD_MEMORY="4Gb"
    43  GCLOUD_DISK="200"
    44  EOF
    45              ;;
    46          2)
    47              # get_ci_vm APIv2 configuration details
    48              echo "AWS_PROFILE=containers"
    49              ;;
    50          *)
    51              echo "Error: Your get_ci_vm container image is too old."
    52              ;;
    53      esac
    54  elif [[ "$1" == "--setup" ]]; then
    55      in_get_ci_vm "$1"
    56      unset GET_CI_VM
    57      # get_ci_vm container entrypoint calls us with this option on the
    58      # Cirrus-CI environment instance, to perform repo.-specific setup.
    59      cd $REPO_DIRPATH
    60      echo "+ Loading ./contrib/cirrus/lib.sh" > /dev/stderr
    61      source ./contrib/cirrus/lib.sh
    62      echo "+ Mimicking .cirrus.yml build_task" > /dev/stderr
    63      make install.tools
    64      make binaries
    65      make docs
    66      echo "+ Running environment setup" > /dev/stderr
    67      ./contrib/cirrus/setup_environment.sh
    68  else
    69      # Pass this repo and CLI args into container for VM creation/management
    70      mkdir -p $HOME/.config/gcloud/ssh
    71      mkdir -p $HOME/.aws
    72      podman run -it --rm \
    73          --tz=local \
    74          -e NAME="$USER" \
    75          -e SRCDIR=/src \
    76          -e GCLOUD_ZONE="$GCLOUD_ZONE" \
    77          -e A_DEBUG="${A_DEBUG:-0}" \
    78          -v $REPO_DIRPATH:/src:O \
    79          -v $HOME/.config/gcloud:/root/.config/gcloud:z \
    80          -v $HOME/.config/gcloud/ssh:/root/.ssh:z \
    81          -v $HOME/.aws:/root/.aws:z \
    82          quay.io/libpod/get_ci_vm:latest "$@"
    83  fi