From 500c429266e47fcff515fdb4fbcd0956904e7ab3 Mon Sep 17 00:00:00 2001 From: evgeniy-scherbina Date: Thu, 1 Aug 2024 09:30:57 -0400 Subject: [PATCH] Added process_kava_dispatch workflow --- .github/scripts/wait-for-node-init.sh | 15 ++++++ .github/workflows/process_kava_dispatch.yml | 60 +++++++++++++++++++++ testing/retry_test.go | 2 + 3 files changed, 77 insertions(+) create mode 100755 .github/scripts/wait-for-node-init.sh create mode 100644 .github/workflows/process_kava_dispatch.yml diff --git a/.github/scripts/wait-for-node-init.sh b/.github/scripts/wait-for-node-init.sh new file mode 100755 index 0000000..36c9241 --- /dev/null +++ b/.github/scripts/wait-for-node-init.sh @@ -0,0 +1,15 @@ +get_block_number() { + local BLOCK_NUMBER=$(curl -sS -X POST \ + --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \ + -H "Content-Type: application/json" \ + http://localhost:8545 | jq .result) + echo $BLOCK_NUMBER +} + +BLOCK_NUMBER=$(get_block_number) + +while [ "$BLOCK_NUMBER" == "" ] +do + BLOCK_NUMBER=$(get_block_number) + sleep 0.5 +done diff --git a/.github/workflows/process_kava_dispatch.yml b/.github/workflows/process_kava_dispatch.yml new file mode 100644 index 0000000..96a9c4c --- /dev/null +++ b/.github/workflows/process_kava_dispatch.yml @@ -0,0 +1,60 @@ +name: Process Kava Repository Dispatch Event + +on: + push: + branches: [ process_kava_dispatch ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout rosetta-kava + uses: actions/checkout@v4 + with: + path: rosetta-kava + + # TODO(yevhenii): consider reusing already built kava docker image instead of rebuilding it + - name: Checkout kava + uses: actions/checkout@v4 + with: + repository: Kava-Labs/kava + path: kava + + - name: Checkout kvtool + uses: actions/checkout@v4 + with: + repository: Kava-Labs/kvtool + path: kvtool + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: rosetta-kava/go.mod + + - name: Cache Go Modules + uses: actions/cache@v4 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('./rosetta-kava/**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Build kava docker image + run: make docker-build + working-directory: ./kava + + - name: Install kvtool + run: make install + working-directory: ./kvtool + + - name: Run kava docker container + run: KAVA_TAG=local kvtool t bootstrap + + - name: Wait until kava node is ready to serve traffic + run: bash ${GITHUB_WORKSPACE}/rosetta-kava/.github/scripts/wait-for-node-init.sh + + - name: Run integration tests + run: KAVA_RPC_URL=http://localhost:26657 NETWORK=kava-local PORT=4000 make test-integration + working-directory: ./rosetta-kava + + diff --git a/testing/retry_test.go b/testing/retry_test.go index 4229a6c..bf6ecf5 100644 --- a/testing/retry_test.go +++ b/testing/retry_test.go @@ -49,6 +49,8 @@ func TestBlockRetry(t *testing.T) { time.Sleep(time.Duration(rand.Intn(1000)) * time.Millisecond) for { + time.Sleep(time.Millisecond * 100) + select { case <-jobCtx.Done(): return