chore: segregate files and fix ci flakiness #28
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: IBC Testing with Emerynet and Local Chain | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
workflow_dispatch: | |
jobs: | |
ibc-testing: | |
runs-on: ubuntu-latest | |
env: | |
EMERYNET_BALANCE_FILE: emerynet_balance.txt | |
LOCAL_BALANCE_FILE: local_balance.txt | |
EMERYNET_CHAIN_ID: agoric-emerynet-8 | |
LOCAL_CHAIN_ID: agoric-local | |
WALLET_ADDRESS_EMERYNET: agoric10emrzln03exuc9uv98mjwmp95735mjm6k2n9xm | |
WALLET_ADDRESS_LOCAL: agoric1myfpdaxyj34lqexe9cypu6vrf34xemtfq2a0nt | |
RELAYER_CONFIG: /workspace/relayer/config-emerynet-local.toml | |
TRANSFER_AMOUNT_FROM_EMERYNET: 100 | |
TRANSFER_AMOUNT_FROM_LOCAL: 50 | |
EMERYNET_API_URL: https://emerynet.api.agoric.net/cosmos/bank/v1beta1/balances | |
LOCAL_API_URL: http://localhost:1317/cosmos/bank/v1beta1/balances | |
BLD_DENOM: ubld | |
IBC_DENOM: ibc/49C630713B2AB60653F76C0C58D43C2A64956803B4D422CACB6DD4AD016ED846 | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Start Agoric Local Chain | |
run: docker-compose -f docker-compose-emerynet-local.yaml up -d agoric-local | |
- name: Wait for Local container to be ready | |
run: | | |
wait_for_bootstrap() { | |
endpoint="localhost" | |
while true; do | |
if json=$(curl -s --fail -m 15 "$endpoint:26657/status"); then | |
if [[ "$(echo "$json" | jq -r .jsonrpc)" == "2.0" ]]; then | |
if last_height=$(echo "$json" | jq -r .result.sync_info.latest_block_height); then | |
if [[ "$last_height" != "1" ]]; then | |
echo "$last_height" | |
return | |
else | |
echo "$last_height" | |
fi | |
fi | |
fi | |
fi | |
echo "waiting for next block..." | |
sleep 5 | |
done | |
echo "done" | |
} | |
waitForBlock() { | |
echo "waiting for block..." | |
times=${1:-1} | |
echo "$times" | |
for ((i = 1; i <= times; i++)); do | |
b1=$(wait_for_bootstrap) | |
while true; do | |
b2=$(wait_for_bootstrap) | |
if [[ "$b1" != "$b2" ]]; then | |
echo "block produced" | |
break | |
fi | |
sleep 5 | |
done | |
done | |
echo "done" | |
} | |
waitForBlock 8 | |
- name: Start Relayer Service | |
run: docker-compose -f docker-compose-emerynet-local.yaml up -d relayer | |
- name: Check if Hermes relayer has started | |
run: | | |
echo "Waiting for the Relayer to start..." | |
timeout 480 bash -c "\ | |
until docker logs relayer 2>&1 | grep -q 'Hermes has started'; do | |
sleep 1 | |
done" | |
continue-on-error: true | |
- name: Output Docker logs | |
run: | | |
echo 'Current logs from the relayer:' | |
docker logs relayer | |
- name: Fail workflow if Hermes relayer didn't start | |
if: failure() | |
run: | | |
echo "The Hermes relayer failed to start." | |
exit 1 # Explicitly failing the workflow to prevent subsequent steps from running. | |
- name: Store Local Wallet Balance in a file | |
uses: ./.github/actions/store-balances | |
with: | |
url: ${{ env.LOCAL_API_URL }} | |
address: ${{ env.WALLET_ADDRESS_LOCAL }} | |
denom: ${{ env.IBC_DENOM }} | |
file: ${{ env.LOCAL_BALANCE_FILE }} | |
- name: Store Emerynet Wallet Balance in a file | |
uses: ./.github/actions/store-balances | |
with: | |
url: ${{ env.EMERYNET_API_URL }} | |
address: ${{ env.WALLET_ADDRESS_EMERYNET }} | |
denom: ${{ env.BLD_DENOM }} | |
file: ${{ env.EMERYNET_BALANCE_FILE }} | |
- name: Monitor Channel Initialization | |
run: | | |
timeout 360 bash -c "\ | |
echo 'Waiting for channel initialization...' | |
until line=\$(docker logs relayer 2>&1 | grep 'OpenInitChannel'); do | |
sleep 1 | |
done | |
if [[ -n \$line ]]; then | |
channel_id=\$(echo \$line | awk -F'channel_id: ' '{print \$2}' | awk -F', ' '{print \$1}') | |
echo \"Channel ID extracted: \$channel_id\" | |
echo \$channel_id > channel_id.txt | |
else | |
echo 'Channel initialization timed out.' | |
docker logs relayer | |
exit 1 | |
fi" | |
- name: Confirm Channel Status | |
run: | | |
channel_id=$(cat channel_id.txt) | |
timeout 600 bash -c "\ | |
until line=\$(docker logs relayer 2>&1 | grep 'OpenConfirmChannel.*$channel_id'); do | |
sleep 1 | |
done | |
if [[ -n \$line ]]; then | |
echo 'Channel ID $channel_id confirmed.' | |
else | |
echo 'Channel confirmation timed out.' | |
docker logs relayer | |
exit 1 | |
fi" | |
- name: Execute IBC Token Transfer from Emerynet to Local Chain | |
run: | | |
docker exec relayer hermes --config $RELAYER_CONFIG tx ft-transfer --src-chain $EMERYNET_CHAIN_ID --src-channel $(cat channel_id.txt) \ | |
--dst-chain $LOCAL_CHAIN_ID --src-port transfer --amount $TRANSFER_AMOUNT_FROM_EMERYNET --denom 'ubld' --timeout-seconds 1000 && \ | |
sleep 5 | |
- name: Check Token Balance on Emerynet after transfer | |
uses: ./.github/actions/check-balance-with-polling | |
with: | |
url: ${{ env.EMERYNET_API_URL }} | |
address: ${{ env.WALLET_ADDRESS_EMERYNET }} | |
denom: ${{ env.BLD_DENOM }} | |
file: ${{ env.EMERYNET_BALANCE_FILE }} | |
comparison_type: lesser | |
polling_seconds: 120 | |
- name: Check Token Balance on Local Chain after transfer | |
uses: ./.github/actions/check-balance-with-polling | |
with: | |
url: ${{ env.LOCAL_API_URL }} | |
address: ${{ env.WALLET_ADDRESS_LOCAL }} | |
denom: ${{ env.IBC_DENOM }} | |
file: ${{ env.LOCAL_BALANCE_FILE }} | |
comparison_type: greater | |
polling_seconds: 120 | |
- name: Store Local Wallet Balance in a file | |
uses: ./.github/actions/store-balances | |
with: | |
url: ${{ env.LOCAL_API_URL }} | |
address: ${{ env.WALLET_ADDRESS_LOCAL }} | |
denom: ${{ env.IBC_DENOM }} | |
file: ${{ env.LOCAL_BALANCE_FILE }} | |
- name: Store Emerynet Wallet Balance in a file | |
uses: ./.github/actions/store-balances | |
with: | |
url: ${{ env.EMERYNET_API_URL }} | |
address: ${{ env.WALLET_ADDRESS_EMERYNET }} | |
denom: ${{ env.BLD_DENOM }} | |
file: ${{ env.EMERYNET_BALANCE_FILE }} | |
- name: Execute IBC Token Transfer from Local Chain to Emerynet | |
run: | | |
docker exec relayer hermes --config $RELAYER_CONFIG tx ft-transfer --src-chain $LOCAL_CHAIN_ID --src-channel channel-0 \ | |
--dst-chain $EMERYNET_CHAIN_ID --src-port transfer --amount $TRANSFER_AMOUNT_FROM_LOCAL --denom 'ibc/49C630713B2AB60653F76C0C58D43C2A64956803B4D422CACB6DD4AD016ED846' --timeout-seconds 1000 && \ | |
sleep 5 | |
- name: Check Token Balance on Local Chain after transfer | |
uses: ./.github/actions/check-balance-with-polling | |
with: | |
url: ${{ env.LOCAL_API_URL }} | |
address: ${{ env.WALLET_ADDRESS_LOCAL }} | |
denom: ${{ env.IBC_DENOM }} | |
file: ${{ env.LOCAL_BALANCE_FILE }} | |
comparison_type: lesser | |
polling_seconds: 120 | |
- name: Check Token Balance on Emerynet after transfer | |
uses: ./.github/actions/check-balance-with-polling | |
with: | |
url: ${{ env.EMERYNET_API_URL }} | |
address: ${{ env.WALLET_ADDRESS_EMERYNET }} | |
denom: ${{ env.BLD_DENOM }} | |
file: ${{ env.EMERYNET_BALANCE_FILE }} | |
comparison_type: greater | |
polling_seconds: 120 |