Skip to content

Commit 26dd2ff

Browse files
authoredOct 16, 2024
Merge pull request #23 from hyperweb-io/anmol/docker-all-in-one
feature: docker all in one
2 parents ca83f1f + d3026b2 commit 26dd2ff

File tree

5 files changed

+97
-22
lines changed

5 files changed

+97
-22
lines changed
 
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Run E2E Docker Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
jobs:
13+
e2e-tests:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout Repository 📝
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: "20.x"
24+
cache: "yarn"
25+
26+
- name: Install Dependencies
27+
run: yarn install --frozen-lockfile
28+
29+
- name: Build contracts
30+
run: yarn build
31+
32+
- name: Run docker infra
33+
run: |
34+
yarn run docker
35+
sleep 5
36+
37+
- name: Run E2E Tests
38+
run: yarn test

‎.github/workflows/e2e-tests.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ on:
99
- main
1010
workflow_dispatch:
1111

12-
permissions:
13-
contents: read
14-
packages: write
15-
1612
jobs:
1713
e2e-tests:
1814
runs-on: ubuntu-latest

‎.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
**/node_modules/
22
**/.DS_Store
33
**/yarn-error.log
4-
lerna-debug.log
4+
lerna-debug.log
5+
6+
**/.idea

‎README.md

+52-17
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,24 @@ Welcome to **Hyperweb**, the blockchain for JavaScript smart contracts. Hyperweb
2020
## Table of Contents
2121

2222
- [Quickstart](#quickstart)
23-
- [Contract Layout](#contract-layout)
24-
- [Building and Bundling](#building-and-bundling)
25-
- [Creating JSD Client](#creating-jsd-client)
26-
- [Deploying and Interacting with the Contract](#deploying-and-interacting-with-the-contract)
23+
- [Bundle Contracts](#bundle-contracts)
24+
- [Infrastructure Setup](#infrastructure-setup)
25+
- [Option 1: Using Starship](#option-1-using-starship)
26+
- [Enable Kubernetes in Docker Desktop](#enable-kubernetes-in-docker-desktop)
27+
- [Install `kubectl` and `helm`](#install-kubectl-and-helm)
28+
- [Start Starship](#start-starship)
29+
- [Interact with the Chain](#interact-with-the-chain)
30+
- [Option 2: Using Docker](#option-2-using-docker)
31+
- [Run Hyperweb with Docker](#run-hyperweb-with-docker)
32+
- [Interact with Chain](#interact-with-chain)
33+
- [Run Tests](#run-tests)
2734
- [Usage](#usage)
28-
- [Instantiating a Contract](#instantiating-a-contract)
29-
- [Interacting with the Contract](#interacting-with-the-contract)
30-
- [Evaluating Functions on the Contract](#evaluating-functions-on-the-contract)
31-
- [Reading Contract State](#reading-contract-state)
35+
- [Creating JSD Client](#creating-jsd-client)
36+
- [Deploying and Interacting with the Contract](#deploying-and-interacting-with-the-contract)
37+
- [Instantiating a Contract](#instantiating-a-contract)
38+
- [Interacting with the Contract](#interacting-with-the-contract)
39+
- [Evaluating Functions on the Contract](#evaluating-functions-on-the-contract)
40+
- [Reading Contract State](#reading-contract-state)
3241
- [Development](#development)
3342

3443
## Installation
@@ -56,7 +65,11 @@ yarn build
5665

5766
This bundles the contracts from src/** into dist/contracts/.
5867

59-
### Spin Up Starship
68+
## Infrastructure Setup
69+
70+
### Option 1: Using Starship
71+
[Starship](https://github.com/cosmology-tech/starship) is a Kubernetes-based blockchain orchestrator. It sets up a local blockchain environment with full cross-chain compatibility.
72+
6073
#### Enable Kubernetes in Docker Desktop
6174
Docker Desktop includes a standalone Kubernetes server and client, as well as Docker CLI integration that runs on your machine.
6275
To enable Kubernetes in Docker Desktop:
@@ -80,18 +93,40 @@ Wait for Starship to initialize.
8093

8194
For more details, refer to the [Starship Docs](https://docs.cosmology.zone/starship/).
8295

83-
#### Interact with Chain
84-
Once the starship nodes are running, then you can interact with the chain using following endpoints:
85-
- REST: http://localhost:1317
86-
- RPC: http://localhost:26657
87-
- Faucet: http://localhost:8000
96+
### Option 2: Using Docker
97+
Alternatively, Hyperweb can be run using Docker, which simplifies setup and enables you to interact with the blockchain without requiring Kubernetes.
98+
99+
#### Run Hyperweb with Docker
100+
To spin up the chain using Docker, the following scripts are available in the package.json:
101+
102+
* Run Docker container:
103+
```bash
104+
yarn docker
105+
```
106+
107+
* Stop and remove the container:
108+
```bash
109+
yarn docker:stop
110+
```
111+
112+
### Interact with chain
113+
114+
This will set up the same chain environment that Starship provides, allowing you to interact with the chain using the same endpoints:
115+
* REST: http://localhost:1317
116+
* RPC: http://localhost:26657
117+
* Faucet: http://localhost:8000
118+
* Exposer: http://localhost:8081
119+
* Registry: http://localhost:8001
120+
121+
Once the chain is running, you can follow the same steps to interact with the chain and run tests as detailed below.
88122

89-
### Run Tests
123+
## Run Tests
124+
Once the setup it complete, you can run tests to validate the contract functionality.
90125
Run tests:
91126
```bash
92127
yarn test
93128
```
94-
The test suite deploys the contracts, interacts with them, and validates state transitions. The tests are located in tests/.
129+
The test suite deploys the contracts, interacts with them, and validates state transitions. The tests are located in `__tests__/`.
95130

96131
---
97132

@@ -212,4 +247,4 @@ console.log('Contract state:', state);
212247

213248
## Development
214249

215-
For local development, you can run the tests provided in the `tests/` folder to validate contract functionality using `starshipjs` to simulate chain interactions.
250+
For local development, you can run the tests provided in the `__tests__/` folder to validate contract functionality using `starshipjs` to simulate chain interactions.

‎package.json

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
"build": "ts-node scripts/build.ts",
1818
"test": "jest --verbose --bail",
1919
"test:debug": "jest --runInBand --verbose --bail",
20+
"docker": "npm run docker:stop && npm run docker:run",
21+
"docker:run": "docker run -d --name jsd-plus -p 26657:26657 -p 1317:1317 -p 8000:8000 -p 8001:8001 -p 8081:8081 ghcr.io/cosmology-tech/jsd-plus:0.1.1",
22+
"docker:exec": "docker exec -it jsd-plus /bin/bash",
23+
"docker:stop": "docker stop jsd-plus || true && docker rm jsd-plus || true",
2024
"starship": "starship --config configs/local.yaml",
2125
"starship:ci": "starship --config configs/ci.yaml"
2226
},

0 commit comments

Comments
 (0)