Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
fluiderson committed Nov 9, 2024
1 parent 93933a7 commit 0ccdf58
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.git
.github
.gitignore
.idea

chopsticks
docs
target
tests

Dockerfile
44 changes: 44 additions & 0 deletions .github/workflows/cargo-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Rust test

on:
pull_request:
push:
branches:
- main
- stable

jobs:
check:
name: Cargo test
runs-on: ubuntu-latest
steps:

- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Checkout sources
uses: actions/[email protected]
with:
fetch-depth: 50
submodules: 'recursive'

- name: Install Rust stable toolchain
uses: actions-rs/[email protected]
with:
profile: minimal
toolchain: stable
override: true

- name: Install cargo-nextest
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-nextest
version: 0.9

- name: Rust Cache
uses: Swatinem/[email protected]

- name: cargo nextest
run: cargo nextest run
57 changes: 57 additions & 0 deletions .github/workflows/kalatori-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Kalatori Test

on:
pull_request:
push:
branches:
- main
- stable

jobs:
check:
name: Cargo and TypeScript Tests
runs-on: ubuntu-latest
steps:

- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Checkout sources
uses: actions/[email protected]
with:
fetch-depth: 50
submodules: recursive

- name: Initialize Git Submodules
run: git submodule update --init --recursive

- name: Verify directory structure
run: ls -R

- name: Install Docker using Docker's official script
run: |
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
- name: Install Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/v2.3.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
- name: Build and Start Containers
working-directory: ./tests
run: |
docker-compose up -d --build chopsticks-polkadot chopsticks-statemint kalatori-rust-app
- name: Wait for Dependencies to Initialize
run: sleep 60

- name: Run Tests and Capture Exit Code
working-directory: ./tests
run: |
docker-compose run tests || exit_code=$?
docker-compose down
exit ${exit_code:-0}
25 changes: 25 additions & 0 deletions configs/chopsticks-docker.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
account-lifetime = 86400000 # 1 day.
depth = 3600000 # 1 hour.
debug = true

[[chain]]
name = "polkadot"
native-token = "DOT"
decimals = 10
endpoints = [
"ws://chopsticks-polkadot:8000",
]

[[chain]]
name = "statemint"
endpoints = [
"ws://chopsticks-statemint:9000",
]

[[chain.asset]]
name = "USDC"
id = 1337

[[chain.asset]]
name = "USDt"
id = 1984
55 changes: 55 additions & 0 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: '3.8'

services:
chopsticks-polkadot:
build:
context: ../chopsticks
dockerfile: Dockerfile
container_name: chopsticks-polkadot
ports:
- "8000:8000"
volumes:
- ../chopsticks/pd.yml:/app/config.yml
command: ["chopsticks", "-c", "/app/config.yml", "-p", "8000", "--addr", "0.0.0.0"]

chopsticks-statemint:
build:
context: ../chopsticks
dockerfile: Dockerfile
container_name: chopsticks-statemint
ports:
- "9000:9000"
volumes:
- ../chopsticks/pd-ah.yml:/app/config.yml
command: ["chopsticks", "-c", "/app/config.yml", "-p", "9000", "--addr", "0.0.0.0"]

kalatori-rust-app:
build:
context: ..
dockerfile: Dockerfile
container_name: kalatori-daemon
ports:
- "16726:16726"
volumes:
- ../configs:/app/configs
depends_on:
- chopsticks-polkadot
- chopsticks-statemint
environment:
- KALATORI_HOST=0.0.0.0:16726
- KALATORI_CONFIG=configs/chopsticks-docker.toml
- KALATORI_SEED=bottom drive obey lake curtain smoke basket hold race lonely fit walk
- KALATORI_RECIPIENT=5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
- KALATORI_REMARK=test
command: /bin/sh -c "sleep 10 && /app/kalatori" # 10-second sleep to ensure chopsticks is ready

tests:
image: node:20
working_dir: /app
volumes:
- ../tests/kalatori-api-test-suite:/app
depends_on:
- kalatori-rust-app
environment:
- DAEMON_HOST=http://kalatori-daemon:16726
command: /bin/sh -c "sleep 50 && yarn install && yarn test"

0 comments on commit 0ccdf58

Please sign in to comment.