Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Commit

Permalink
simpler names
Browse files Browse the repository at this point in the history
  • Loading branch information
pyramation committed Apr 20, 2024
1 parent 8b96e1a commit 463d6ee
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 17 deletions.
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Utilities for [Starship](https://github.com/cosmology-tech/starship) 🚀

## install

Install the test utilities `starshipjs` and the CI client `@starship-ci/client`:

```sh
npm install starshipjs @starship-ci/client

Expand All @@ -27,10 +29,65 @@ npm install starshipjs @starship-ci/client
- [starshipjs](#starshipjs)
- [Install](#install)
- [Table of contents](#table-of-contents)
- [Usage](#usage)
- [Initializing the Client](#initializing-the-client)
- [Starting Port Forwarding](#setting-up-and-installing-the-chart)
- [Stopping And Cleaning up](#stopping-and-cleaning-up)
- [Developing](#developing)
- [Credits](#credits)

## Using the StarshipClient

The `StarshipClient` simplifies managing Kubernetes resources, specifically tailored for developers working in interchain environments. Below is an example showing how to instantiate the client and use it to manage a Helm deployment:

### Initializing the Client

First, you need to import and initialize the `StarshipClient` with your Helm configuration:

```js
import { StarshipClient } from '@starship-ci/client';

const client = new StarshipClient({
helmName: 'osmojs',
helmFile: 'path/to/config.yaml',
helmRepo: 'starship',
helmRepoUrl: 'https://cosmology-tech.github.io/starship/',
helmChart: 'devnet',
helmVersion: 'v0.1.38'
});
```

### Setting Up and Installing the Chart

After initializing, set up the environment and install the starship helm chart:

```js
// adds helm chart to registry
client.setup();
// installs helm chart
client.deploy();
```

## Starting Port Forwarding

For local development, you might need to forward ports from your Kubernetes pods:

```js
client.startPortForward();
```

## Stopping and Cleaning Up

Once done with development or testing, you can stop the port forwarding and remove the Helm chart:

```js
// stop port forwarding AND
// remove the deployed release from your Kubernetes cluster
client.undeploy();

// remove the helm chart
client.teardown();
```

## Developing

Expand Down
83 changes: 77 additions & 6 deletions ci/client/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,98 @@
# utils
# starshipjs

<p align="center">
<img src="https://user-images.githubusercontent.com/545047/188804067-28e67e5e-0214-4449-ab04-2e0c564a6885.svg" width="80"><br />
Starship CI Utils
<img src="https://user-images.githubusercontent.com/10805402/242348990-c141d6cd-e1c9-413f-af68-283de029c3a4.png" width="80"><br />
Starship TypeScript Utilties
</p>

<p align="center" width="100%">
<a href="https://github.com/cosmology-tech/starshipjs/actions/workflows/run-tests.yml">
<img height="20" src="https://github.com/cosmology-tech/starshipjs/actions/workflows/run-tests.yml/badge.svg" />
</a>
<a href="https://github.com/cosmology-tech/starshipjs/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-BSD%203--Clause%20Clear-blue.svg"></a>
</p>

Universal interchain development environment in k8s. The vision of this project is to have a single easy to use developer environment with full testing support for multichain use cases

Utilities for [Starship](https://github.com/cosmology-tech/starship) 🚀

## install

Install the test utilities `starshipjs` and the CI client `@starship-ci/client`:

```sh
npm install utils
npm install starshipjs @starship-ci/client

```
## Table of contents

- [utils](#utils)
- [starshipjs](#starshipjs)
- [Install](#install)
- [Table of contents](#table-of-contents)
- [Usage](#usage)
- [Initializing the Client](#initializing-the-client)
- [Starting Port Forwarding](#setting-up-and-installing-the-chart)
- [Stopping And Cleaning up](#stopping-and-cleaning-up)
- [Developing](#developing)
- [Credits](#credits)

## Using the StarshipClient

The `StarshipClient` simplifies managing Kubernetes resources, specifically tailored for developers working in interchain environments. Below is an example showing how to instantiate the client and use it to manage a Helm deployment:

### Initializing the Client

First, you need to import and initialize the `StarshipClient` with your Helm configuration:

```js
import { StarshipClient } from '@starship-ci/client';

const client = new StarshipClient({
helmName: 'osmojs',
helmFile: 'path/to/config.yaml',
helmRepo: 'starship',
helmRepoUrl: 'https://cosmology-tech.github.io/starship/',
helmChart: 'devnet',
helmVersion: 'v0.1.38'
});
```

### Setting Up and Installing the Chart

After initializing, set up the environment and install the starship helm chart:

```js
// adds helm chart to registry
client.setup();
// installs helm chart
client.deploy();
```

## Starting Port Forwarding

For local development, you might need to forward ports from your Kubernetes pods:

```js
client.startPortForward();
```

## Stopping and Cleaning Up

Once done with development or testing, you can stop the port forwarding and remove the Helm chart:

```js
// stop port forwarding AND
// remove the deployed release from your Kubernetes cluster
client.undeploy();

// remove the helm chart
client.teardown();
```

## Developing

When first cloning the repo:

When first cloning the repo:
```
yarn
yarn build
Expand Down
4 changes: 2 additions & 2 deletions ci/client/__tests__/__snapshots__/client.ports.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Call: setup()
helm repo add starship https://cosmology-tech.github.io/starship/
helm repo update
helm search repo starship/devnet --version v0.1.38
Call: install()
Call: deploy()
Log: Installing the helm chart. This is going to take a while.....
helm install -f ../../__fixtures__/config.yaml osmojs starship/devnet --version v0.1.38
Log: Run "kubectl get pods" to check the status of the cluster
Expand All @@ -31,7 +31,7 @@ kubectl port-forward service/registry 8081:8080 > /dev/null 2>&1 &
Log: Forwarded registry on port 8081 to target port 8080
kubectl port-forward service/registry 9091:9090 > /dev/null 2>&1 &
Log: Forwarded registry on port 9091 to target port 9090
Call: stop()
Call: undeploy()
Log: Trying to stop all port-forward, if any....
ps -ef | grep -i 'kubectl port-forward' | grep -v 'grep' | awk '{print $2}'
sleep 2
Expand Down
4 changes: 2 additions & 2 deletions ci/client/__tests__/__snapshots__/client.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Call: setup()
helm repo add starship https://cosmology-tech.github.io/starship/
helm repo update
helm search repo starship/devnet --version v0.1.38
Call: install()
Call: deploy()
Log: Installing the helm chart. This is going to take a while.....
helm install -f ../../__fixtures__/config.yaml osmojs starship/devnet --version v0.1.38
Log: Run "kubectl get pods" to check the status of the cluster
Expand All @@ -32,7 +32,7 @@ kubectl port-forward service/registry 8081:8080 > /dev/null 2>&1 &
Log: Forwarded registry on port 8081 to target port 8080
kubectl port-forward service/registry 9091:9090 > /dev/null 2>&1 &
Log: Forwarded registry on port 9091 to target port 9090
Call: stop()
Call: undeploy()
Log: Trying to stop all port-forward, if any....
ps -ef | grep -i 'kubectl port-forward' | grep -v 'grep' | awk '{print $2}'
sleep 2
Expand Down
4 changes: 2 additions & 2 deletions ci/client/__tests__/client.ports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ describe('StarshipClient', () => {

// helm
client.setup();
client.install();
client.deploy();

client.startPortForward();

client.stop();
client.undeploy();

// remove helm chart
client.teardown();
Expand Down
4 changes: 2 additions & 2 deletions ci/client/__tests__/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ describe('StarshipClient', () => {

// helm
client.setup();
client.install();
client.deploy();

client.startPortForward();

client.stop();
client.undeploy();

// remove helm chart
client.teardown();
Expand Down
6 changes: 3 additions & 3 deletions ci/client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ export class StarshipClient implements StarshipClientI{
]);
}

public stop(): void {
public undeploy(): void {
this.stopPortForward();
this.deleteHelm();
}

public clean(): void {
this.stop();
this.undeploy();
this.cleanKind();
}

Expand Down Expand Up @@ -207,7 +207,7 @@ export class StarshipClient implements StarshipClientI{
]);
}

public install(): void {
public deploy(): void {
this.log("Installing the helm chart. This is going to take a while.....");
this.exec([
'helm',
Expand Down

0 comments on commit 463d6ee

Please sign in to comment.