Add CLI tests and setup CI #53

Merged
ashwin merged 23 commits from deep-stack/laconic-registry-cli:pm-add-tests into main 2024-01-29 04:46:32 +00:00
5 changed files with 67 additions and 29 deletions
Showing only changes of commit 395e8bddee - Show all commits

View File

@ -12,34 +12,45 @@ env:
DOCKER_HOST: unix:///var/run/dind.sock
jobs:
sdk_tests:
cli_tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies and build
run: yarn && yarn build
- name: Install registry-cli
run: yarn global add file:$PWD
- name: Log CLI version
run: laconic --version
- name: Checkout laconicd
uses: actions/checkout@v3
with:
path: "./laconicd/"
path: "/tmp/laconicd/"
repository: cerc-io/laconicd
fetch-depth: 0
ref: main
- name: Environment
run: ls -tlh && env
- name: Start dockerd
run: |
dockerd -H $DOCKER_HOST --userland-proxy=false &
sleep 5
- name: build registry-cli container
run: docker build -t cerc/laconic-registry-cli:local-test --build-arg CERC_NPM_URL=https://git.vdb.to/api/packages/cerc-io/npm/ --build-arg CERC_NPM_AUTH_TOKEN="${{ secrets.CICD_PUBLISH_TOKEN }}" .
- name: build containers scripts
working-directory: laconicd/tests/sdk_tests
- name: Build laconicd container
working-directory: /tmp/laconicd/tests/sdk_tests
run: ./build-laconicd-container.sh
- name: start laconicd container
working-directory: laconicd/tests/sdk_tests
- name: Start laconicd container
env:
TEST_AUCTION_ENABLED: true
run: docker compose up laconicd -d
- name: Run registry-cli demo commands in registry-cli container
run : ls -tla
- name: stop containers
working-directory: laconicd/tests/sdk_tests
- name: Run registry-cli tests
run: ./test/run-tests.sh
- name: Stop containers
run: docker compose down

View File

@ -1,3 +1,4 @@
# TODO: Remove
name: Tests
on:
pull_request:

View File

@ -1,28 +1,25 @@
services:
laconicd:
restart: unless-stopped
image: cerc-io/laconicd:local-test
image: cerc/laconicd:local
command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
environment:
- TEST_AUCTION_ENABLED
- TEST_REGISTRY_EXPIRY
- LOGLEVEL
volumes:
- laconicd/init.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh
- /tmp/laconicd/init.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh
healthcheck:
test: ["CMD", "curl", "-v", "http://127.0.0.1:6060"]
interval: 1s
timeout: 5s
retries: 30
ports:
- "6060"
- "26657"
- "26656"
- "9473"
- "8545"
- "8546"
- "9090"
- "9091"
- "1317"
- "9473:9473"
- "1317:1317"
cli-test-runner:
image: cerc/laconic-registry-cli:local-test
image: cerc/laconic-registry-cli:local
depends_on:
laconicd:
condition: service_healthy

View File

@ -26,7 +26,7 @@
"yargs": "^17.4.1"
},
"scripts": {
"test": "jest --runInBand --verbose --testPathPattern=test",
"test": "jest --runInBand --verbose test/cli.test.ts",
"lint": "eslint .",
"clean": "rm -rf ./dist",
"build": "tsc"

29
test/run-tests.sh Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Get the key from laconicd
laconicd_key=$(yes | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe)
# Set parameters for the test suite
cosmos_chain_id=laconic_9000-1
laconicd_rest_endpoint=http://127.0.0.1:1317
laconicd_gql_endpoint=http://127.0.0.1:9473/api
# Create the required config
config_file="config.yml"
config=$(cat <<EOL
services:
cns:
restEndpoint: $laconicd_rest_endpoint
gqlEndpoint: $laconicd_gql_endpoint
userKey: $laconicd_key
bondId:
chainId: $cosmos_chain_id
EOL
)
echo "$config" > "$config_file"
# Wait for the laconid endpoint to come up
docker compose exec laconicd sh -c "curl --retry 10 --retry-delay 3 --retry-connrefused http://127.0.0.1:9473/api"
# Run tests
yarn test