Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit c8424c8

Browse files
committed
Cirrus: Add modern get_ci_vm support
Previously `ci/get_vm.sh` was duplicated from other containers-org repos. This became difficult to maintain, so a shared implementation was developed in a container image. Using it from a special `hack/get_ci_vm.sh` requires some changes to `.cirrus.yml` to work properly. Signed-off-by: Chris Evich <[email protected]>
1 parent 6b7339d commit c8424c8

File tree

3 files changed

+65
-225
lines changed

3 files changed

+65
-225
lines changed

.cirrus.yml

+3-8
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
env:
44
DEST_BRANCH: "master"
55
GOPATH: "/var/tmp/go"
6-
CIRRUS_WORKING_DIR: "${GOPATH}/src/github.com/containers/oci-seccomp-bpf-hook"
6+
CIRRUS_WORKING_DIR: "${GOPATH}/src/github.com/containers/dnsname"
77
GOSRC: "$CIRRUS_WORKING_DIR"
8-
SCRIPT_BASE: "./contrib/cirrus"
98
CIRRUS_SHELL: "/bin/bash"
109
IMAGE_PROJECT: "libpod-218412"
1110
HOME: "/root" # not set by default
@@ -64,10 +63,8 @@ meta_task:
6463

6564
validate_task:
6665

67-
env:
68-
PATH: "$PATH:/var/tmp/go/bin"
69-
7066
validate_script:
67+
- export PATH="$PATH:$GOPATH/bin"
7168
- make validate
7269
- make vendor
7370
- ./hack/tree_status.sh
@@ -88,9 +85,7 @@ test_task:
8885
gce_instance:
8986
image_name: ${UBUNTU_CACHE_IMAGE_NAME}
9087

91-
env:
92-
PATH: "$PATH:/var/tmp/go/bin"
93-
9488
test_script:
89+
- export PATH="$PATH:$GOPATH/bin"
9590
- make
9691
- make test

ci/get_vm.sh

-217
This file was deleted.

hack/get_ci_vm.sh

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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 dnsname 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/dnsname"
33+
UPSTREAM_REPO="https://github.com/containers/dnsname.git"
34+
CI_ENVFILE="/etc/ci_environment"
35+
GCLOUD_PROJECT="dnsname-8675309"
36+
GCLOUD_IMGPROJECT="libpod-218412"
37+
GCLOUD_CFG="dnsname"
38+
GCLOUD_ZONE="${GCLOUD_ZONE:-us-central1-c}"
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+
echo "+ Setting up environment" > /dev/stderr
48+
echo 'PATH=$PATH:$GOPATH/bin' > /etc/ci_environment
49+
else
50+
# Create and access VM for specified Cirrus-CI task
51+
mkdir -p $HOME/.config/gcloud/ssh
52+
podman run -it --rm \
53+
--tz=local \
54+
-e NAME="$USER" \
55+
-e SRCDIR=/src \
56+
-e GCLOUD_ZONE="$GCLOUD_ZONE" \
57+
-e DEBUG="${DEBUG:-0}" \
58+
-v $REPO_DIRPATH:/src:O \
59+
-v $HOME/.config/gcloud:/root/.config/gcloud:z \
60+
-v $HOME/.config/gcloud/ssh:/root/.ssh:z \
61+
quay.io/libpod/get_ci_vm:latest "$@"
62+
fi

0 commit comments

Comments
 (0)