diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index 6dc7a5c..021a1b6 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e238e86..dd07de6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,3 +1,4 @@ +# TODO: Remove name: Tests on: pull_request: diff --git a/docker-compose.yml b/docker-compose.yml index 7469649..7886836 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/package.json b/package.json index 0d2fe56..552d6c4 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/test/run-tests.sh b/test/run-tests.sh new file mode 100755 index 0000000..572e250 --- /dev/null +++ b/test/run-tests.sh @@ -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 < "$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