Skip to content

Commit

Permalink
Cirrus: Add EC2 support to get_ci_vm
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Evich <[email protected]>
  • Loading branch information
cevich committed Aug 26, 2022
1 parent 6613f3a commit 6088f1b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ env:
AARDVARK_DNS_BRANCH: "main"
AARDVARK_DNS_URL: "https://api.cirrus-ci.com/v1/artifact/github/containers/aardvark-dns/success/binary.zip?branch=${AARDVARK_DNS_BRANCH}"
FEDORA_NETAVARK_AARCH64_AMI: "fedora-netavark-aws-arm64-${IMAGE_SUFFIX}"
EC2_INST_TYPE: "t4g.xlarge"


gcp_credentials: ENCRYPTED[d6efdb7d6d4c61e3831df2193ca6348bb02f26cd931695f69d41930b1965f7dab72a838ca0902f6ed8cde66c7deddae2]
Expand Down Expand Up @@ -76,7 +77,7 @@ build_aarch64_task:
alias: "build_aarch64"
ec2_instance: &standard_build_ec2_aarch64
image: "${FEDORA_NETAVARK_AARCH64_AMI}"
type: t4g.xlarge
type: $EC2_INST_TYPE
region: us-east-1
architecture: arm64 # CAUTION: This has to be "arm64", not "aarch64"
cargo_cache: &cargo_cache_aarch64
Expand Down
23 changes: 18 additions & 5 deletions hack/get_ci_vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SCRIPT_FILEPATH=$(realpath "${BASH_SOURCE[0]}")
SCRIPT_DIRPATH=$(dirname "$SCRIPT_FILEPATH")
REPO_DIRPATH=$(realpath "$SCRIPT_DIRPATH/../")

# Help detect if we were called by get_ci_vm container
# Help detect what get_ci_vm container called this script
GET_CI_VM="${GET_CI_VM:-0}"
in_get_ci_vm() {
if ((GET_CI_VM==0)); then
Expand All @@ -27,8 +27,10 @@ in_get_ci_vm() {
# get_ci_vm APIv1 container entrypoint calls into this script
# to obtain required repo. specific configuration options.
if [[ "$1" == "--config" ]]; then
in_get_ci_vm "$1"
cat <<EOF
in_get_ci_vm "$1" # handles GET_CI_VM==0 case
case "$GET_CI_VM" in
1)
cat <<EOF
DESTDIR="/var/tmp/netavark"
UPSTREAM_REPO="https://github.com/containers/netavark.git"
CI_ENVFILE="/etc/ci_environment"
Expand All @@ -40,6 +42,15 @@ GCLOUD_CPUS="2"
GCLOUD_MEMORY="4Gb"
GCLOUD_DISK="200"
EOF
;;
2)
# get_ci_vm APIv2 configuration details
echo "AWS_PROFILE=containers"
;;
*)
echo "Error: Your get_ci_vm container image is too old."
;;
esac
elif [[ "$1" == "--setup" ]]; then
in_get_ci_vm "$1"
# get_ci_vm container entrypoint calls us with this option on the
Expand All @@ -48,16 +59,18 @@ elif [[ "$1" == "--setup" ]]; then
echo "+ Running environment setup" > /dev/stderr
./contrib/cirrus/setup.sh
else
# Create and access VM for specified Cirrus-CI task
# Pass this repo and CLI args into container for VM creation/management
mkdir -p $HOME/.config/gcloud/ssh
mkdir -p $HOME/.aws
podman run -it --rm \
--tz=local \
-e NAME="$USER" \
-e SRCDIR=/src \
-e GCLOUD_ZONE="$GCLOUD_ZONE" \
-e DEBUG="${DEBUG:-0}" \
-e A_DEBUG="${A_DEBUG:-0}" \
-v $REPO_DIRPATH:/src:O \
-v $HOME/.config/gcloud:/root/.config/gcloud:z \
-v $HOME/.config/gcloud/ssh:/root/.ssh:z \
-v $HOME/.aws:/root/.aws:z \
quay.io/libpod/get_ci_vm:latest "$@"
fi

0 comments on commit 6088f1b

Please sign in to comment.