Skip to content

Commit

Permalink
ci: build sdk image for multi-chain test (#10880)
Browse files Browse the repository at this point in the history
closes: #9805

## Description

Build the SDK Docker image so that the multi-chain test can use an up-to-date SDK image instead of the last published one.

### Security Considerations
None

### Scaling Considerations
This will make multichain tests in CI 5 minutes longer until we can amortize build through a shared step and depot runner, or some other explicit image sharing mechanism between pre-requisite jobs.

### Documentation Considerations
None

### Testing Considerations
Manually verify the integration test output of this PR

### Upgrade Considerations
None, testing only
  • Loading branch information
mergify[bot] authored Jan 24, 2025
2 parents 656aba8 + de845ad commit d461b05
Show file tree
Hide file tree
Showing 6 changed files with 455 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .github/actions/starship-action/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Starship Devnet Action (Agoric fork)

This `starship-action` was extracted from https://github.com/hyperweb-io/starship-action/tree/0.3.0

We took:
- action.yaml
- install.sh
- port-forward.sh

Agoric added the `load-docker-images` input parameter to be able to import locally-built Docker images into Starship's Kubernetes cluster.

Also, we ran `yarn prettier --write .github/actions/starship-action` to reformat
the code to our repository's standards.
189 changes: 189 additions & 0 deletions .github/actions/starship-action/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
# https://github.com/hyperweb-io/starship-action/blob/0.3.0/action.yaml
# Agoric: added load-docker-images, then prettified.
name: 'Starship Devnet'
description: 'Run mini cosmos ecosystem via devnet'
branding:
color: blue
icon: anchor

inputs:
values:
description: 'Values yaml raw data of filename for helm that define the topology for the devnet'
required: true
port-forward:
description: 'Flag weather to perform port forwarding as defined in the values file to local ports (default: true)'
required: false
default: 'true'
kubeconfig:
description: 'Kubeconfig file for remote cluster, if set, will be used instead of creating kind cluster'
required: false
default: ''
load-docker-images:
description: 'Space-separated local docker images to load into cluster'
required: false
default: ''
version:
description: 'Version of devnet chart (default: 0.1.45)'
required: false
default: '0.2.3'
chart:
description: 'Name of the help chart to use. Recommended: use default (default: starship/devnet)'
required: false
default: 'starship/devnet'
repo:
description: 'Helm repo to fetch the chart from (default: https://cosmology-tech.github.io/starship)'
required: false
default: 'https://cosmology-tech.github.io/starship'
name:
description: 'Helm chart release name for installing helm chart (default: starship-devnet)'
required: false
default: 'starship-devnet'
namespace:
description: 'Kubernetes namespace to deploy helm charts on (default: ci-{github.repository}-{github.workflow}-{github.ref} )'
required: false
default: ''
timeout:
description: 'Timeout for helm install (default: 10m)'
required: false
default: '10m'

outputs:
namespace:
description: 'Kubernetes namespace to which helm charts were deployed'
value: ${{ steps.set-namespace.outputs.namespace }}
name:
description: 'Helm chart release name for installing helm chart'
value: ${{ inputs.name }}

runs:
using: composite
steps:
- name: Install dependencies
run: |
sudo apt-get install -y make sed wget tar jq
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq
shell: bash

- name: Setup helm
uses: azure/setup-helm@v3
with:
version: v3.10.0

- name: Setup kubectl
uses: azure/setup-kubectl@v3
with:
version: v1.28.0

- name: Setup kind cluster
if: ${{ inputs.kubeconfig == '' }}
uses: helm/[email protected]
with:
cluster_name: kind-starship

- name: Load docker images into the kind-starship cluster
if: ${{ inputs.load-docker-images != '' && inputs.kubeconfig == '' }}
run: |
set -ex
kind load docker-image $LOAD_DOCKER_IMAGES --name kind-starship
env:
LOAD_DOCKER_IMAGES: ${{ inputs.load-docker-images }}
shell: bash

- name: Load docker images into an unkind cluster
if: ${{ inputs.load-docker-images != '' && inputs.kubeconfig != '' }}
run: |
echo "UNIMPLEMENTED: Cannot load docker images into a remote cluster: $LOAD_DOCKER_IMAGES"
exit 1
env:
LOAD_DOCKER_IMAGES: ${{ inputs.load-docker-images }}
shell: bash

- name: Create kubeconfig file
if: ${{ inputs.kubeconfig != '' }}
run: |
mkdir -p ~/.kube
echo -e "${{ inputs.kubeconfig }}" > ~/.kube/config
shell: bash

- name: Create values.yaml
run: |
if [[ "${{ inputs.values }}" == *.yaml || "${{ inputs.values }}" == *.yml ]]
then
cp ${{ inputs.values }} ${{ inputs.name }}-values.yaml
else
echo -e "${{ inputs.values }}" > ${{ inputs.name }}-values.yaml
fi
cat ${{ inputs.name }}-values.yaml
shell: bash

- name: Set namespace
id: set-namespace
run: |
namespace="ci-${{ github.repository }}-${{ github.workflow }}-${{ github.ref }}"
if [ -n "$INPUT_NAMESPACE" ]; then
namespace="$INPUT_NAMESPACE"
fi
namespace="${namespace// /-}"
namespace="${namespace//\//-}"
namespace=$(awk '{print tolower($0)}' <<< $namespace)
(( ${#namespace} > 62 )) && namespace="$(echo $namespace | cut -c1-59)$((RANDOM%1000))"
namespace=$(echo $namespace | cut -c1-60)
echo "Setting namespace to $namespace"
echo "namespace=$namespace" >> $GITHUB_OUTPUT
shell: bash
env:
INPUT_NAMESPACE: ${{ inputs.namespace }}

- name: Setup starship helm repo
run: |
helm version
helm repo add starship ${{ inputs.repo }}
helm repo update
helm search repo starship/devnet
shell: bash

- name: Helm install
id: helm-install-1
continue-on-error: true
run: |
helm delete ${{ inputs.name }} --debug --namespace ${{ steps.set-namespace.outputs.namespace }} --wait || true
sleep 5
${{ github.action_path }}/install.sh --config ${{ inputs.values }} --name ${{ inputs.name }} --chart ${{ inputs.chart }} --version ${{ inputs.version }} --namespace ${{ steps.set-namespace.outputs.namespace }} --timeout ${{ inputs.timeout }}
shell: bash

- name: Logs
if: always()
run: |
kubectl get pods -n $NAMESPACE
for i in `kubectl get po -n $NAMESPACE -o json | jq -r '.items[].metadata.name'`; do
echo "==================================================="
echo "Logs for $i"
kubectl describe pods $i -n $NAMESPACE
kubectl logs $i -n $NAMESPACE --all-containers --tail=800
echo "==================================================="
done
env:
VALUES_FILE: ${{ inputs.name }}-values.yaml
NAMESPACE: ${{ steps.set-namespace.outputs.namespace }}
shell: bash

- name: Helm install again
id: helm-install-2
if: steps.helm-install-1.outcome == 'failure'
run: |
helm delete ${{ inputs.name }} --debug --namespace ${{ steps.set-namespace.outputs.namespace }} --wait || true
sleep 5
kubectl get pods --namespace ${{ steps.set-namespace.outputs.namespace }}
${{ github.action_path }}/install.sh --config ${{ inputs.name }}-values.yaml --name ${{ inputs.name }} --chart ${{ inputs.chart }} --version ${{ inputs.version }} --namespace ${{ steps.set-namespace.outputs.namespace }} --timeout ${{ inputs.timeout }}
shell: bash

- name: Port forward
if: ${{ inputs.port-forward == 'true' }}
run: |
kubectl version
${{ github.action_path }}/port-forward.sh --config=$VALUES_FILE --namespace=$NAMESPACE
shell: bash
env:
VALUES_FILE: ${{ inputs.name }}-values.yaml
NAMESPACE: ${{ steps.set-namespace.outputs.namespace }}
104 changes: 104 additions & 0 deletions .github/actions/starship-action/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/bin/bash
# https://github.com/hyperweb-io/starship-action/blob/0.3.0/install.sh
# Agoric: prettified.

## Script used to install the helm chart for the devnet from a config file
## Usage:
## ./scripts/install.sh --coinfig <config_file>
## Options:
## -c|--config: config file to use (default: config.yaml)
## -v|--version: helm chart version (default: 0.1.43)

set -euo pipefail

# read config file from args into variable
CONFIGFILE="config.yaml"

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
echo "Script dir: ${SCRIPT_DIR}"

# default values
DRY_RUN=""
TIMEOUT=""
NAMESPACE=""
HELM_NAME="starship"
HELM_CHART="starship/devnet"
HELM_CHART_VERSION="0.2.3"

function set_helm_args() {
if [[ $TIMEOUT ]]; then
args="$args --timeout $TIMEOUT --wait --debug"
fi
if [[ $NAMESPACE ]]; then
args="$args --namespace $NAMESPACE --create-namespace"
fi
if [[ $DRY_RUN ]]; then
args="$args --dry-run"
fi
num_chains=$(yq -r ".chains | length - 1" ${CONFIGFILE})
if [[ $num_chains -lt 0 ]]; then
echo "No chains to parse: num: $num_chains"
return 0
fi
for i in $(seq 0 $num_chains); do
scripts=$(yq -r ".chains[$i].scripts" ${CONFIGFILE})
if [[ "$scripts" == "null" ]]; then
return 0
fi
datadir="$(
cd "$(dirname -- "${CONFIGFILE}")" > /dev/null
pwd -P
)"
for script in $(yq -r ".chains[$i].scripts | keys | .[]" ${CONFIGFILE}); do
args="$args --set-file chains[$i].scripts.$script.data=$datadir/$(yq -r ".chains[$i].scripts.$script.file" ${CONFIGFILE})"
done
done
}

function install_chart() {
args=""
set_helm_args
echo "args: $args"
helm install ${HELM_NAME} ${HELM_CHART} --version ${HELM_CHART_VERSION} -f ${CONFIGFILE} $args
}

while [ $# -gt 0 ]; do
case "$1" in
-c | --config)
CONFIGFILE="$2"
shift 2 # past argument=value
;;
-v | --version)
HELM_CHART_VERSION="$2"
shift 2 # past argument
;;
-t | --timeout)
TIMEOUT="$2"
shift 2 # past argument
;;
-n | --name)
HELM_NAME="$2"
shift 2 # past argument
;;
--namespace)
NAMESPACE="$2"
shift 2 # past argument
;;
--chart)
HELM_CHART="$2"
shift 2 # past argument
;;
--dry-run)
DRY_RUN=1
shift 2 # past argument
;;
-* | --*)
echo "Unknown option $1"
exit 1
;;
*) ;;

esac
done

install_chart
Loading

0 comments on commit d461b05

Please sign in to comment.