From 055bfbc394799b33eb3f70b1aae0a93da2092d20 Mon Sep 17 00:00:00 2001 From: Anmol1696 Date: Sun, 9 Jun 2024 14:41:34 +0530 Subject: [PATCH 01/15] start to create github action using starshipjs --- action.yaml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/action.yaml b/action.yaml index 92e11bd..b028e6e 100644 --- a/action.yaml +++ b/action.yaml @@ -53,12 +53,11 @@ 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 Node.js + uses: actions/setup-node@v4 + with: + node-version: "20.x" + cache: "yarn" - name: Setup helm uses: azure/setup-helm@v3 @@ -112,8 +111,15 @@ runs: env: INPUT_NAMESPACE: ${{ inputs.namespace }} + - name: Setup starshipjs client + run: | + yarn global add @starship-ci/cli + starship --version + shell: bash + - name: Setup starship helm repo run: | + starship setup --helmName ${{ inputs.name }} --helmVersion helm version helm repo add starship ${{ inputs.repo }} helm repo update From 078140712cf9aac704bd6cc6368129ba5efab96e Mon Sep 17 00:00:00 2001 From: Anmol1696 Date: Tue, 11 Jun 2024 18:00:15 +0530 Subject: [PATCH 02/15] try and set check-latest to false to avoid checking for yarn.lock file --- action.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index b028e6e..e332150 100644 --- a/action.yaml +++ b/action.yaml @@ -58,6 +58,7 @@ runs: with: node-version: "20.x" cache: "yarn" + check-latest: false - name: Setup helm uses: azure/setup-helm@v3 @@ -113,7 +114,7 @@ runs: - name: Setup starshipjs client run: | - yarn global add @starship-ci/cli + yarn add @starship-ci/cli starship --version shell: bash From 578f1af8a90395201fae85382025436be8a57abb Mon Sep 17 00:00:00 2001 From: Anmol1696 Date: Tue, 11 Jun 2024 18:19:54 +0530 Subject: [PATCH 03/15] add empty package.json and yarn.lock file --- .gitignore | 5 +++++ action.yaml | 1 - package.json | 8 ++++++++ yarn.lock | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 package.json create mode 100644 yarn.lock diff --git a/.gitignore b/.gitignore index e131255..80263b8 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,8 @@ bin-release/ # Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties` # should NOT be excluded as they contain compiler settings and other important # information for Eclipse / Flash Builder. +**/node_modules/ +**/.DS_Store +**/dist +**/yarn-error.log +lerna-debug.log diff --git a/action.yaml b/action.yaml index e332150..1f2345d 100644 --- a/action.yaml +++ b/action.yaml @@ -58,7 +58,6 @@ runs: with: node-version: "20.x" cache: "yarn" - check-latest: false - name: Setup helm uses: azure/setup-helm@v3 diff --git a/package.json b/package.json new file mode 100644 index 0000000..7ca6eb3 --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "name": "starship-action", + "version": "1.0.0", + "main": "index.js", + "repository": "git@github.com:cosmology-tech/starship-action.git", + "author": "Anmol1696 ", + "license": "MIT" +} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..fb57ccd --- /dev/null +++ b/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + From cd9708a99ae1fdbaffb8578eddefeeb21ee45e0c Mon Sep 17 00:00:00 2001 From: Anmol1696 Date: Tue, 11 Jun 2024 18:28:49 +0530 Subject: [PATCH 04/15] add global starshipcli --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 1f2345d..b028e6e 100644 --- a/action.yaml +++ b/action.yaml @@ -113,7 +113,7 @@ runs: - name: Setup starshipjs client run: | - yarn add @starship-ci/cli + yarn global add @starship-ci/cli starship --version shell: bash From b06843a97361bb35c46e5e8cb56dd46eaab1e949 Mon Sep 17 00:00:00 2001 From: Anmol1696 Date: Tue, 11 Jun 2024 18:38:09 +0530 Subject: [PATCH 05/15] use starship start command instead of install and port-forward scripts --- action.yaml | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/action.yaml b/action.yaml index b028e6e..1b9f632 100644 --- a/action.yaml +++ b/action.yaml @@ -119,11 +119,13 @@ runs: - name: Setup starship helm repo run: | - starship setup --helmName ${{ inputs.name }} --helmVersion - helm version - helm repo add starship ${{ inputs.repo }} - helm repo update - helm search repo starship/devnet + starship setup \ + --helmName ${{ inputs.name }} \ + --helmVersion ${{ inputs.version }} \ + --helmFile ${{ inputs.values }}-values.yaml \ + --helmNamespace ${{ steps.set-namespace.outputs.namespace }} \ + --helmRepo ${{ inputs.repo }} \ + --helmChart ${{ inputs.chart }} shell: bash - name: Helm install @@ -132,7 +134,13 @@ runs: 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 }} + starship start \ + --helmName ${{ inputs.name }} \ + --helmVersion ${{ inputs.version }} \ + --helmFile ${{ inputs.values }}-values.yaml \ + --helmNamespace ${{ steps.set-namespace.outputs.namespace }} \ + --helmRepo ${{ inputs.repo }} \ + --helmChart ${{ inputs.chart }} shell: bash - name: Logs @@ -158,15 +166,11 @@ runs: 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 }} + starship start \ + --helmName ${{ inputs.name }} \ + --helmVersion ${{ inputs.version }} \ + --helmFile ${{ inputs.values }}-values.yaml \ + --helmNamespace ${{ steps.set-namespace.outputs.namespace }} \ + --helmRepo ${{ inputs.repo }} \ + --helmChart ${{ inputs.chart }} 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 }} From 3d993c7080ffe0ed5947e3ebd18ac9e057d8413a Mon Sep 17 00:00:00 2001 From: Anmol1696 Date: Tue, 11 Jun 2024 18:41:13 +0530 Subject: [PATCH 06/15] fix helmFile path to correct value --- action.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yaml b/action.yaml index 1b9f632..78a140f 100644 --- a/action.yaml +++ b/action.yaml @@ -122,7 +122,7 @@ runs: starship setup \ --helmName ${{ inputs.name }} \ --helmVersion ${{ inputs.version }} \ - --helmFile ${{ inputs.values }}-values.yaml \ + --helmFile ${{ inputs.name }}-values.yaml \ --helmNamespace ${{ steps.set-namespace.outputs.namespace }} \ --helmRepo ${{ inputs.repo }} \ --helmChart ${{ inputs.chart }} @@ -137,7 +137,7 @@ runs: starship start \ --helmName ${{ inputs.name }} \ --helmVersion ${{ inputs.version }} \ - --helmFile ${{ inputs.values }}-values.yaml \ + --helmFile ${{ inputs.name }}-values.yaml \ --helmNamespace ${{ steps.set-namespace.outputs.namespace }} \ --helmRepo ${{ inputs.repo }} \ --helmChart ${{ inputs.chart }} @@ -169,7 +169,7 @@ runs: starship start \ --helmName ${{ inputs.name }} \ --helmVersion ${{ inputs.version }} \ - --helmFile ${{ inputs.values }}-values.yaml \ + --helmFile ${{ inputs.name }}-values.yaml \ --helmNamespace ${{ steps.set-namespace.outputs.namespace }} \ --helmRepo ${{ inputs.repo }} \ --helmChart ${{ inputs.chart }} From 77a627f3a65e4bd9c890ff9b3e632eea44dedd9d Mon Sep 17 00:00:00 2001 From: Anmol1696 Date: Tue, 11 Jun 2024 18:56:39 +0530 Subject: [PATCH 07/15] add github workspace var --- action.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/action.yaml b/action.yaml index 78a140f..5469e0a 100644 --- a/action.yaml +++ b/action.yaml @@ -19,7 +19,7 @@ inputs: version: description: "Version of devnet chart (default: 0.1.45)" required: false - default: "0.2.3" + default: "v0.2.3" chart: description: "Name of the help chart to use. Recommended: use default (default: starship/devnet)" required: false @@ -122,7 +122,7 @@ runs: starship setup \ --helmName ${{ inputs.name }} \ --helmVersion ${{ inputs.version }} \ - --helmFile ${{ inputs.name }}-values.yaml \ + --helmFile $GITHUB_WORKSPACE/${{ inputs.name }}-values.yaml \ --helmNamespace ${{ steps.set-namespace.outputs.namespace }} \ --helmRepo ${{ inputs.repo }} \ --helmChart ${{ inputs.chart }} @@ -137,7 +137,7 @@ runs: starship start \ --helmName ${{ inputs.name }} \ --helmVersion ${{ inputs.version }} \ - --helmFile ${{ inputs.name }}-values.yaml \ + --helmFile $GITHUB_WORKSPACE/${{ inputs.name }}-values.yaml \ --helmNamespace ${{ steps.set-namespace.outputs.namespace }} \ --helmRepo ${{ inputs.repo }} \ --helmChart ${{ inputs.chart }} @@ -169,7 +169,7 @@ runs: starship start \ --helmName ${{ inputs.name }} \ --helmVersion ${{ inputs.version }} \ - --helmFile ${{ inputs.name }}-values.yaml \ + --helmFile $GITHUB_WORKSPACE/${{ inputs.name }}-values.yaml \ --helmNamespace ${{ steps.set-namespace.outputs.namespace }} \ --helmRepo ${{ inputs.repo }} \ --helmChart ${{ inputs.chart }} From a7d0682a3885b62919790b97c8685d53ada1a09c Mon Sep 17 00:00:00 2001 From: Anmol1696 Date: Tue, 11 Jun 2024 19:00:14 +0530 Subject: [PATCH 08/15] remove incorrect use of inputs.repo --- action.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/action.yaml b/action.yaml index 5469e0a..82d7d69 100644 --- a/action.yaml +++ b/action.yaml @@ -124,7 +124,6 @@ runs: --helmVersion ${{ inputs.version }} \ --helmFile $GITHUB_WORKSPACE/${{ inputs.name }}-values.yaml \ --helmNamespace ${{ steps.set-namespace.outputs.namespace }} \ - --helmRepo ${{ inputs.repo }} \ --helmChart ${{ inputs.chart }} shell: bash @@ -139,7 +138,6 @@ runs: --helmVersion ${{ inputs.version }} \ --helmFile $GITHUB_WORKSPACE/${{ inputs.name }}-values.yaml \ --helmNamespace ${{ steps.set-namespace.outputs.namespace }} \ - --helmRepo ${{ inputs.repo }} \ --helmChart ${{ inputs.chart }} shell: bash @@ -171,6 +169,5 @@ runs: --helmVersion ${{ inputs.version }} \ --helmFile $GITHUB_WORKSPACE/${{ inputs.name }}-values.yaml \ --helmNamespace ${{ steps.set-namespace.outputs.namespace }} \ - --helmRepo ${{ inputs.repo }} \ --helmChart ${{ inputs.chart }} shell: bash From 150008b55792b8f4505f4515e15c4d8fdf7798ab Mon Sep 17 00:00:00 2001 From: Anmol1696 Date: Wed, 12 Jun 2024 13:32:08 +0530 Subject: [PATCH 09/15] fix chart name --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 82d7d69..28f97ab 100644 --- a/action.yaml +++ b/action.yaml @@ -23,7 +23,7 @@ inputs: chart: description: "Name of the help chart to use. Recommended: use default (default: starship/devnet)" required: false - default: "starship/devnet" + default: "devnet" repo: description: "Helm repo to fetch the chart from (default: https://cosmology-tech.github.io/starship)" required: false From 4d5188526c185636e57b83e77131c97f56c405eb Mon Sep 17 00:00:00 2001 From: Anmol1696 Date: Wed, 12 Jun 2024 13:37:43 +0530 Subject: [PATCH 10/15] add step to create namespce with kubectl --- action.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/action.yaml b/action.yaml index 28f97ab..ffac251 100644 --- a/action.yaml +++ b/action.yaml @@ -111,6 +111,11 @@ runs: 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 run: | yarn global add @starship-ci/cli From 0942ff7e00fda892e732fd10c15fc470860375b9 Mon Sep 17 00:00:00 2001 From: Anmol1696 Date: Wed, 12 Jun 2024 14:00:00 +0530 Subject: [PATCH 11/15] remove input for port-forward bool, add cli-version to fetch correct starship-cli client --- action.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/action.yaml b/action.yaml index ffac251..1d0bc7e 100644 --- a/action.yaml +++ b/action.yaml @@ -8,10 +8,6 @@ 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 @@ -20,6 +16,10 @@ inputs: description: "Version of devnet chart (default: 0.1.45)" required: false default: "v0.2.3" + cli-version: + description: "Version of @starship-ci/cli to use: default: 2.3.0" + required: false + default: "2.3.0" chart: description: "Name of the help chart to use. Recommended: use default (default: starship/devnet)" required: false @@ -118,7 +118,7 @@ runs: - name: Setup starshipjs client run: | - yarn global add @starship-ci/cli + yarn global add @starship-ci/cli@${{ inputs.cli-version }} starship --version shell: bash From 84707b9d84151cb1548ab8b93c11fb9d0b41d706 Mon Sep 17 00:00:00 2001 From: Anmol1696 Date: Wed, 12 Jun 2024 14:01:06 +0530 Subject: [PATCH 12/15] re-shuffle version and cli-version --- action.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/action.yaml b/action.yaml index 1d0bc7e..e6da770 100644 --- a/action.yaml +++ b/action.yaml @@ -8,18 +8,18 @@ inputs: values: description: "Values yaml raw data of filename for helm that define the topology for the devnet" required: true - kubeconfig: - description: "Kubeconfig file for remote cluster, if set, will be used instead of creating kind cluster" - required: false - default: "" version: - description: "Version of devnet chart (default: 0.1.45)" + description: "Version of devnet chart (default: v0.2.3)" required: false default: "v0.2.3" cli-version: description: "Version of @starship-ci/cli to use: default: 2.3.0" required: false default: "2.3.0" + kubeconfig: + description: "Kubeconfig file for remote cluster, if set, will be used instead of creating kind cluster" + required: false + default: "" chart: description: "Name of the help chart to use. Recommended: use default (default: starship/devnet)" required: false From f1f0437152f02655eb2b5ea31c9ada53efe4750f Mon Sep 17 00:00:00 2001 From: Anmol1696 Date: Wed, 12 Jun 2024 14:13:18 +0530 Subject: [PATCH 13/15] set cli version 2.4.0 and set chart --- action.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index e6da770..ecbd5f4 100644 --- a/action.yaml +++ b/action.yaml @@ -15,7 +15,7 @@ inputs: cli-version: description: "Version of @starship-ci/cli to use: default: 2.3.0" required: false - default: "2.3.0" + default: "2.4.0" kubeconfig: description: "Kubeconfig file for remote cluster, if set, will be used instead of creating kind cluster" required: false @@ -23,7 +23,7 @@ inputs: chart: description: "Name of the help chart to use. Recommended: use default (default: starship/devnet)" required: false - default: "devnet" + default: "starship/devnet" repo: description: "Helm repo to fetch the chart from (default: https://cosmology-tech.github.io/starship)" required: false From 364f7f2a19170b468f98dad762c6a54125fcb95f Mon Sep 17 00:00:00 2001 From: Anmol1696 Date: Wed, 12 Jun 2024 14:14:57 +0530 Subject: [PATCH 14/15] remove port-forward from test gh-action --- .github/workflows/test.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index be14e96..4212509 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -52,7 +52,6 @@ jobs: - uses: ./ id: starship with: - port-forward: true name: test-with-values values: config.yaml @@ -130,7 +129,6 @@ jobs: - uses: ./ id: starship with: - port-forward: true name: test-kubeconfig kubeconfig: ${{ steps.kubeconfig.outputs.content }} values: config.yaml @@ -170,7 +168,6 @@ jobs: - uses: ./ id: starship with: - port-forward: false name: test-no-portforward values: config.yaml From cc8ad724d882c88e4eae1beba2dc39a8a7a1aaae Mon Sep 17 00:00:00 2001 From: Anmol1696 Date: Wed, 12 Jun 2024 14:22:03 +0530 Subject: [PATCH 15/15] update readme, cleanup action --- .github/workflows/test.yaml | 2 +- README.md | 6 +- action.yaml | 4 -- install.sh | 99 -------------------------- port-forward.sh | 135 ------------------------------------ 5 files changed, 4 insertions(+), 242 deletions(-) delete mode 100755 install.sh delete mode 100755 port-forward.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4212509..5181ac5 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -147,7 +147,7 @@ jobs: NAMESPACE: ${{ steps.starship.outputs.namespace }} NAME: ${{ steps.starship.outputs.name }} - test-with-no-portforward: + test-with-no-ports: runs-on: ubuntu-latest steps: diff --git a/README.md b/README.md index 0a6fccc..cd0777e 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,12 @@ For more information, reference the GitHub Help Documentation for [Creating a wo For more information on inputs, see the [API Documentation](https://developer.github.com/v3/repos/releases/#input) - `values`: Required, config for helm chart for starship devnet inputs -- `port-forward`: Optional, toggle to perform local port-forwarding, based on the `values.yaml` (default: `false`) +- `version`: Optional, version of devnet helm chart from starship (default: `0.2.3`) +- `cli-version`: Optional, version of @starship-ci/cli to use (default: `2.4.0`) - `kubeconfig`: Optional, Kubeconfig for remote cluster, if set, will be used instead of creating local kind cluster -- `version`: Optional, version of devnet chart from starship (default: `0.2.3`) +- `namespace`: Optional, Kubernetes namespace to which helm charts will be deployed. If not found, namespace will be created. (default: `ci-${{ github.repository }}-${{ github.workflow }}-${{ github.ref }}`) - `repo`: Optional, Helm repo to fetch the chart from (default: https://cosmology-tech.github.io/starship) - `name`: Optional, Release name for the helm chart deployment (default: `starship-devnet`) -- `namespace`: Optional, Kubernetes namespace to which helm charts will be deployed. If not found, namespace will be created. (default: `ci-${{ github.repository }}-${{ github.workflow }}-${{ github.ref }}`) - `chart`: Optional, Name of the help chart to use. Recommended: use default (default: `starship/devnet`) ### Outputs diff --git a/action.yaml b/action.yaml index ecbd5f4..6772bb0 100644 --- a/action.yaml +++ b/action.yaml @@ -36,10 +36,6 @@ inputs: 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: diff --git a/install.sh b/install.sh deleted file mode 100755 index 24a3c74..0000000 --- a/install.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/bash - -## Script used to install the helm chart for the devnet from a config file -## Usage: -## ./scripts/install.sh --coinfig -## 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 diff --git a/port-forward.sh b/port-forward.sh deleted file mode 100755 index 8c520b1..0000000 --- a/port-forward.sh +++ /dev/null @@ -1,135 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -function color() { - local color=$1 - shift - local black=30 red=31 green=32 yellow=33 blue=34 magenta=35 cyan=36 white=37 - local color_code=${!color:-$green} - printf "\033[%sm%s\033[0m\n" "$color_code" "$*" -} - -function stop_port_forward() { - color green "Trying to stop all port-forward, if any...." - PIDS=$(ps -ef | grep -i -e 'kubectl port-forward' | grep -v 'grep' | cat | awk '{print $2}') || true - for p in $PIDS; do - kill -15 $p - done - sleep 2 -} - -# Default values -CHAIN_RPC_PORT=26657 -CHAIN_COMETMOCK_PORT=22331 -CHAIN_GRPC_PORT=9090 -CHAIN_LCD_PORT=1317 -CHAIN_EXPOSER_PORT=8081 -CHAIN_FAUCET_PORT=8000 -RELAYER_REST_PORT=3000 -RELAYER_EXPOSER_PORT=8081 -EXPLORER_LCD_PORT=8080 -REGISTRY_LCD_PORT=8080 -REGISTRY_GRPC_PORT=9090 -MONITORING_PROMETHEUS_PORT=8080 -MONITORING_GRAFANA_PORT=8080 - -for i in "$@"; do - case $i in - -c=*|--config=*) - CONFIGFILE="${i#*=}" - shift # past argument=value - ;; - -n=*|--namespace=*) - NAMESPACE="${i#*=}" - shift # past argument=value - ;; - -*|--*) - echo "Unknown option $i" - exit 1 - ;; - *) - ;; - esac -done - -stop_port_forward - -echo "Port forwarding for config ${CONFIGFILE}" -echo "Port forwarding all chains" -num_chains=$(yq -r ".chains | length - 1" ${CONFIGFILE}) -if [[ $num_chains -gt -1 ]]; then - for i in $(seq 0 $num_chains); do - # derive chain pod name from chain id - # https://github.com/cosmology-tech/starship/blob/main/charts/devnet/templates/_helpers.tpl#L56 - chain=$(yq -r ".chains[$i].id" ${CONFIGFILE} ) - chain=${chain/_/"-"} - localrpc=$(yq -r ".chains[$i].ports.rpc" ${CONFIGFILE} ) - localgrpc=$(yq -r ".chains[$i].ports.grpc" ${CONFIGFILE} ) - locallcd=$(yq -r ".chains[$i].ports.rest" ${CONFIGFILE} ) - localexp=$(yq -r ".chains[$i].ports.exposer" ${CONFIGFILE}) - localfaucet=$(yq -r ".chains[$i].ports.faucet" ${CONFIGFILE}) - color yellow "chains: forwarded $chain" - if [[ $(yq -r ".chains[$i].cometmock.enabled" $CONFIGFILE) == "true" ]]; - then - [[ "$localrpc" != "null" ]] && color yellow " cometmock rpc to http://localhost:$localrpc" && kubectl port-forward pods/$chain-cometmock-0 $localrpc:$CHAIN_COMETMOCK_PORT --namespace $NAMESPACE > /dev/null 2>&1 & - else - [[ "$localrpc" != "null" ]] && color yellow " rpc to http://localhost:$localrpc" && kubectl port-forward pods/$chain-genesis-0 $localrpc:$CHAIN_RPC_PORT --namespace $NAMESPACE > /dev/null 2>&1 & - fi - [[ "$localgrpc" != "null" ]] && color yellow " grpc to http://localhost:$localgrpc" && kubectl port-forward pods/$chain-genesis-0 $localgrpc:$CHAIN_GRPC_PORT --namespace $NAMESPACE > /dev/null 2>&1 & - [[ "$locallcd" != "null" ]] && color yellow " lcd to http://localhost:$locallcd" && kubectl port-forward pods/$chain-genesis-0 $locallcd:$CHAIN_LCD_PORT --namespace $NAMESPACE > /dev/null 2>&1 & - [[ "$localexp" != "null" ]] && color yellow " exposer to http://localhost:$localexp" && kubectl port-forward pods/$chain-genesis-0 $localexp:$CHAIN_EXPOSER_PORT --namespace $NAMESPACE > /dev/null 2>&1 & - [[ "$localfaucet" != "null" ]] && color yellow " faucet to http://localhost:$localfaucet" && kubectl port-forward pods/$chain-genesis-0 $localfaucet:$CHAIN_FAUCET_PORT --namespace $NAMESPACE > /dev/null 2>&1 & - sleep 1 - done -else - echo "No chains to port-forward: num: $num_chains" -fi - - -echo "Port forward relayers" -num_relayers=$(yq -r ".relayers | length - 1" ${CONFIGFILE}) -if [[ $num_relayers -gt -1 ]]; then - for i in $(seq 0 $num_relayers); do - # derive chain pod name from chain id - # https://github.com/cosmology-tech/starship/blob/main/charts/devnet/templates/_helpers.tpl#L56 - relayer=$(yq -r ".relayers[$i].name" ${CONFIGFILE} ) - relayer=$(yq -r ".relayers[$i].type" ${CONFIGFILE} )-${relayer/_/"-"} - localrest=$(yq -r ".relayers[$i].ports.rest" ${CONFIGFILE} ) - localexposer=$(yq -r ".relayers[$i].ports.exposer" ${CONFIGFILE} ) - color yellow "relayers: forwarded $relayer" - [[ "$localrest" != "null" ]] && color yellow " rpc to http://localhost:$localrest" && kubectl port-forward pods/$relayer-0 $localrest:$RELAYER_REST_PORT --namespace $NAMESPACE > /dev/null 2>&1 & - [[ "$localexposer" != "null" ]] && color yellow " rpc to http://localhost:$localexposer" && kubectl port-forward pods/$relayer-0 $localexposer:$RELAYER_EXPOSER_PORT --namespace $NAMESPACE > /dev/null 2>&1 & - sleep 1 - done -else - echo "No relayer to port-forward: num: $num_relayers" -fi - - -echo "Port forward services" - -if [[ $(yq -r ".registry.enabled" $CONFIGFILE) == "true" ]]; -then - kubectl port-forward service/registry 8081:$REGISTRY_LCD_PORT --namespace $NAMESPACE > /dev/null 2>&1 & - kubectl port-forward service/registry 9091:$REGISTRY_GRPC_PORT --namespace $NAMESPACE > /dev/null 2>&1 & - sleep 1 - color yellow "registry: forwarded registry lcd to grpc http://localhost:8081, to http://localhost:9091" -fi - -if [[ $(yq -r ".explorer.enabled" $CONFIGFILE) == "true" ]]; -then - kubectl port-forward service/explorer 8080:$EXPLORER_LCD_PORT --namespace $NAMESPACE > /dev/null 2>&1 & - sleep 1 - color green "Open the explorer to get started.... http://localhost:8080" -fi - -if [[ $(yq -r ".monitoring.enabled" $CONFIGFILE) == "true" ]]; -then - color yellow "monitoring port forward:" - localgrafana=$(yq -r ".monitoring.ports.grafana" ${CONFIGFILE}) - localprometheus=$(yq -r ".monitoring.ports.prometheus" ${CONFIGFILE}) - [[ "$localgrafana" != "null" ]] && color yellow " grafana to http://localhost:$localgrafana" && kubectl port-forward service/grafana $localgrafana:$MONITORING_GRAFANA_PORT --namespace $NAMESPACE > /dev/null 2>&1 & - [[ "$localprometheus" != "null" ]] && color yellow " prometheus to http://localhost:$localprometheus" && kubectl port-forward service/prometheus-service $localprometheus:$MONITORING_PROMETHEUS_PORT --namespace $NAMESPACE > /dev/null 2>&1 & - sleep 1 -fi