Skip to content

Commit

Permalink
ci: get active vaults
Browse files Browse the repository at this point in the history
  • Loading branch information
rabi-siddique committed Dec 17, 2024
1 parent 4040adf commit 505ff0d
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 3 deletions.
45 changes: 45 additions & 0 deletions .github/actions/getActiveVaults/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: 'Get Active Vaults'
description: 'Fetches the number of active vaults from a GraphQL API.'

inputs:
apiUrl:
description: 'The URL of the GraphQL API.'
required: true
expectedVaults:
description: 'The exact number of active vaults expected.'
required: true
outputs:
activeVaults:
description: 'The number of active vaults.'
assertionResult:
description: 'Result of the vault count assertion, whether it matches the expected number.'

runs:
using: 'composite'
steps:
- name: Fetch Active Vaults
shell: bash
run: |
sleep 360
result=$(curl -s -X POST http://localhost:3000/ \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
--data-raw '{"query":"query { vaults(filter: {state: {equalTo: \"active\"}}) { totalCount } }"}')
activeVaults=$(echo $result | jq -r '.data.vaults.totalCount')
echo "Active vaults: $activeVaults"
echo "::set-output name=activeVaults::$activeVaults"
id: fetch

- name: Assert Expected Number of Active Vaults
shell: bash
run: |
if [[ "${{ steps.fetch.outputs.activeVaults }}" -eq "${{ inputs.expectedVaults }}" ]]; then
echo "Assertion passed: The number of active vaults (${{ steps.fetch.outputs.activeVaults }}) matches the expected value (${{ inputs.expectedVaults }})."
echo "::set-output name=assertionResult::passed"
else
echo "Assertion failed: The number of active vaults (${{ steps.fetch.outputs.activeVaults }}) does not match the expected value (${{ inputs.expectedVaults }})."
echo "::set-output name=assertionResult::failed"
exit 1
fi
32 changes: 31 additions & 1 deletion .github/workflows/liquidation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,42 @@ jobs:
run: yarn install

- name: Start subql indexer
run: yarn dev:ci
env:
AGORIC_NET: local
run: yarn dev

- name: Print initial logs of all containers
if: failure()
run: |
echo "Fetching initial logs for all containers..."
containers=$(docker ps --format '{{.ID}}')
for container in $containers; do
echo "Fetching initial logs for container $container..."
docker logs $container
done
- name: Wait for 2 minutes
run: sleep 120

- name: Print logs after 2 minutes for all containers
run: |
echo "Fetching logs after 2 minutes for all containers..."
containers=$(docker ps --format '{{.ID}}')
for container in $containers; do
echo "Fetching logs after 2 minutes for container $container..."
docker logs $container
done
- name: Set ATOM Price to 12.34
run: |
docker exec a3p /usr/src/agoric-sdk/packages/agoric-cli/bin/agops oracle setPrice --keys gov1,gov2 --pair ATOM.USD --price 12.34 --keyring-backend=test
- name: Get active vaults
uses: ./.github/actions/getActiveVaults
with:
apiUrl: 'http://localhost:3000/'
expectedVaults: 7

- name: Create Vault with 100 Minted and 15 Collateral
uses: ./.github/actions/createVault
with:
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"build": "subql build",
"codegen": "subql codegen",
"start:docker": "docker-compose pull && docker-compose up --remove-orphans",
"dev": "subql codegen && subql build && docker-compose pull && docker-compose up --remove-orphans",
"dev:ci": "AGORIC_NET=docker subql codegen && subql build && docker compose pull && docker compose up --remove-orphans --detach",
"dev": "subql codegen && subql build && docker compose pull && docker compose up --remove-orphans --detach",
"prepack": "rm -rf dist && npm run build",
"test": "subql build && subql-node-cosmos test",
"prettier:check": "prettier --list-different . --print-width 120",
Expand Down

0 comments on commit 505ff0d

Please sign in to comment.