Skip to content

Commit

Permalink
ci(starship-action): fork to add load-docker-images
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Jan 23, 2025
1 parent 617cfb6 commit a95bf13
Show file tree
Hide file tree
Showing 2 changed files with 212 additions and 1 deletion.
209 changes: 209 additions & 0 deletions .github/actions/starship-action/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
# Cribbed from cosmology-tech/[email protected]
name: 'Starship Devnet'
description: 'Run mini cosmos ecosystem via devnet'
branding:
color: blue
icon: anchor

inputs:
config:
description: 'Path to the config file'
required: true
cli-version:
description: 'Version of @starship-ci/cli to use: default: 2.10.2'
required: false
default: '2.10.2'
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: ''
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: Create yarn.lock and package.json file if not exists
if: inputs.cli-version != '0.0.0' # Skip if cli-version is 0.0.0, expected to be used for local testing
run: |
if [ ! -f $GITHUB_WORKSPACE/yarn.lock ]; then
echo 'Creating temporary yarn.lock file'
echo '' > $GITHUB_WORKSPACE/yarn.lock
fi
if [ ! -f $GITHUB_WORKSPACE/package.json ]; then
echo 'Creating temporary package.json file'
echo '{}' > $GITHUB_WORKSPACE/package.json
fi
shell: bash

- name: Setup Node.js
uses: actions/setup-node@v4
if: inputs.cli-version != '0.0.0' # Skip if cli-version is 0.0.0, expected to be used for local testing
with:
node-version: '20.x'
cache: 'yarn'

- 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 kind
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 }}

- name: Create kubeconfig file
if: ${{ inputs.kubeconfig != '' }}
run: |
mkdir -p ~/.kube
echo -e "${{ inputs.kubeconfig }}" > ~/.kube/config
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: Create namespace if nonexistent
run: |
kubectl create namespace ${{ steps.set-namespace.outputs.namespace }} || true
shell: bash

- name: Setup starshipjs client
if: inputs.cli-version != '0.0.0' # Skip if cli-version is 0.0.0, expected to be used for local testing
run: |
yarn global add @starship-ci/cli@${{ inputs.cli-version }}
shell: bash

- name: Verify starship cli
run: |
starship --version
shell: bash

- name: Setup starship helm repo
run: |
starship setup \
--config ${{ inputs.config }} \
--name ${{ inputs.name }} \
--namespace ${{ steps.set-namespace.outputs.namespace }} \
--chart ${{ inputs.chart }}
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
starship start \
--config ${{ inputs.config }} \
--name ${{ inputs.name }} \
--namespace ${{ steps.set-namespace.outputs.namespace }} \
--chart ${{ inputs.chart }} \
--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.config }}
NAMESPACE: ${{ steps.set-namespace.outputs.namespace }}
shell: bash

- name: Helm install again
id: helm-install-2
if: steps.helm-install-1.outcome == 'failure'
continue-on-error: true
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 }}
starship start \
--config ${{ inputs.config }} \
--name ${{ inputs.name }} \
--namespace ${{ steps.set-namespace.outputs.namespace }} \
--chart ${{ inputs.chart }} \
--timeout ${{ inputs.timeout }}
shell: bash

- name: Helm install again, 3rd time is the charm
id: helm-install-3
if: steps.helm-install-2.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 }}
starship start \
--config ${{ inputs.config }} \
--name ${{ inputs.name }} \
--namespace ${{ steps.set-namespace.outputs.namespace }} \
--chart ${{ inputs.chart }} \
--timeout ${{ inputs.timeout }}
shell: bash
4 changes: 3 additions & 1 deletion .github/workflows/multichain-e2e-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ jobs:

- name: Setup Starship Infrastructure
id: starship-infra
uses: cosmology-tech/[email protected]
# uses: cosmology-tech/[email protected]
uses: ./.github/actions/starship-action
with:
values: ./agoric-sdk/multichain-testing/${{ inputs.config }}
port-forward: true
version: 0.2.20
timeout: 30m
load-docker-images: ghcr.io/agoric/agoric-sdk:unreleased
namespace: ${{ env.NAMESPACE }}
repo: https://hyperweb-io.github.io/starship

Expand Down

0 comments on commit a95bf13

Please sign in to comment.