Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set namespace based on github context, update test #9

Merged
merged 2 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ on:
branches:
- main

env:
NAMESPACE: "starship"

jobs:
test-with-values:
runs-on: ubuntu-latest
Expand All @@ -20,6 +17,7 @@ jobs:
- uses: actions/checkout@v2

- uses: ./
id: starship
with:
port-forward: true
name: test-with-values
Expand Down Expand Up @@ -57,6 +55,8 @@ jobs:
for chain in wasmd osmosis-1; do
kubectl get pods $chain-genesis-0 --namespace $NAMESPACE
done
env:
NAMESPACE: ${{ steps.starship.outputs.namespace }}

- name: Check port forwarded status
run: |
Expand All @@ -70,9 +70,13 @@ jobs:
fi
done

- name: Delete helm chart
- name: Cleanup cluster
run: |
helm delete test-with-values --debug --namespace ${{ env.NAMESPACE }}
helm delete $NAME --debug --namespace $NAMESPACE --wait
kubectl delete namespace $NAMESPACE --wait=true
env:
NAMESPACE: ${{ steps.starship.outputs.namespace }}
NAME: ${{ steps.starship.outputs.name }}

test-with-remote-cluster:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -103,6 +107,7 @@ jobs:
path: /tmp/kubeconfig

- uses: ./
id: starship
with:
port-forward: true
name: test-kubeconfig
Expand All @@ -125,11 +130,17 @@ jobs:

- name: Check kubectl pods
run: |
kubectl get pods osmosis-1-genesis-0 --namespace ${{ env.NAMESPACE }}
kubectl get pods osmosis-1-genesis-0 --namespace $NAMESPACE
env:
NAMESPACE: ${{ steps.starship.outputs.namespace }}

- name: Delete helm chart
- name: Cleanup cluster
run: |
helm delete test-kubeconfig --debug --namespace ${{ env.NAMESPACE }}
helm delete $NAME --debug --namespace $NAMESPACE --wait
kubectl delete namespace $NAMESPACE --wait=true
env:
NAMESPACE: ${{ steps.starship.outputs.namespace }}
NAME: ${{ steps.starship.outputs.name }}

test-with-no-portforward:
runs-on: ubuntu-latest
Expand All @@ -138,6 +149,7 @@ jobs:
- uses: actions/checkout@v2

- uses: ./
id: starship
with:
port-forward: false
name: test-no-portforward
Expand All @@ -157,9 +169,16 @@ jobs:
- name: Check kubectl pods
run: |
for chain in osmosis-1; do
kubectl get pods $chain-genesis-0 --namespace ${{ env.NAMESPACE }}
kubectl get pods $chain-genesis-0 --namespace $NAMESPACE
done
env:
NAMESPACE: ${{ steps.starship.outputs.namespace }}

- name: Delete helm chart

- name: Cleanup cluster
run: |
helm delete test-no-portforward --debug --namespace ${{ env.NAMESPACE }}
helm delete $NAME --debug --namespace $NAMESPACE --wait
kubectl delete namespace $NAMESPACE --wait=true
env:
NAMESPACE: ${{ steps.starship.outputs.namespace }}
NAME: ${{ steps.starship.outputs.name }}
31 changes: 24 additions & 7 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ 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"
Expand All @@ -15,10 +16,6 @@ inputs:
description: "Kubeconfig file for remote cluster, if set, will be used instead of creating kind cluster"
required: false
default: ""
namespace:
description: "Kubernetes namespace to which helm charts will be deployed. If not found, namespace will be created. (default: starship)"
required: false
default: "starship"
version:
description: "Version of devnet chart (default: 0.1.22)"
required: false
Expand All @@ -35,6 +32,15 @@ inputs:
description: "Helm chart release name for installing helm chart (default: starship-devnet)"
required: false
default: "starship-devnet"

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:
Expand Down Expand Up @@ -78,6 +84,17 @@ runs:
cat ${{ inputs.name }}-values.yaml
shell: bash

- name: Set namespace
id: set-namespace
run: |
namespace="ci-${{ github.repository }}-${{ github.workflow }}-${{ github.ref }}"
namespace="${namespace// /-}"
namespace="${namespace//\//-}"
namespace=$(awk '{print tolower($0)}' <<< $namespace)
echo "Setting namespace to $namespace"
echo "namespace=$namespace" >> $GITHUB_OUTPUT
shell: bash

- name: Setup starship helm repo
run: |
helm version
Expand All @@ -88,12 +105,12 @@ runs:

- name: Helm delete before install
run: |
helm delete ${{ inputs.name }} --debug --namespace ${{ inputs.namespace }} --wait || true
helm delete ${{ inputs.name }} --debug --namespace ${{ steps.set-namespace.outputs.namespace }} --wait || true
shell: bash

- name: Helm install
run: |
helm install -f ${{ inputs.name }}-values.yaml ${{ inputs.name }} ${{ inputs.chart }} --wait --debug --version ${{ inputs.version }} --timeout 30m0s --namespace ${{ inputs.namespace }} --create-namespace
helm install -f ${{ inputs.name }}-values.yaml ${{ inputs.name }} ${{ inputs.chart }} --wait --debug --version ${{ inputs.version }} --timeout 30m0s --namespace ${{ steps.set-namespace.outputs.namespace }} --create-namespace
shell: bash

- name: Port forward
Expand All @@ -102,4 +119,4 @@ runs:
shell: bash
env:
VALUES_FILE: ${{ inputs.name }}-values.yaml
NAMESPACE: ${{ inputs.namespace }}
NAMESPACE: ${{ steps.set-namespace.outputs.namespace }}