From 47afcef6b959bf5c94bd12cd533d10ea7d0cae36 Mon Sep 17 00:00:00 2001 From: Carlos Santiago Yanzon <27785807+bizk@users.noreply.github.com> Date: Thu, 18 Jan 2024 11:48:32 -0300 Subject: [PATCH] feat: improve rosetta-ci test (#71) * added makefile step for test-rosetta-ci * downsized github workflow * Update Makefile Co-authored-by: Ezequiel Raynaudo * fixed makefile message * debugging workflow * debug * debug * debug * merge with main * removed merge typo * added checkout to cosmos-sdk versioning * fix makefile typo --------- Co-authored-by: Ezequiel Raynaudo --- .github/issue_labeler.yml | 2 -- .github/pr_labeler.yml | 2 -- .github/workflows/build.yml | 5 +--- .github/workflows/pr_labeler.yml | 18 ------------ .github/workflows/rosetta-cli-test.yaml | 39 ++----------------------- .github/workflows/test.yml | 3 +- Makefile | 24 +++++++-------- README.md | 2 +- scripts/simapp-start-node.sh | 12 ++++++++ tests/rosetta-cli/data.sh | 29 ------------------ 10 files changed, 30 insertions(+), 106 deletions(-) delete mode 100644 .github/issue_labeler.yml delete mode 100644 .github/pr_labeler.yml delete mode 100644 .github/workflows/pr_labeler.yml create mode 100644 scripts/simapp-start-node.sh delete mode 100644 tests/rosetta-cli/data.sh diff --git a/.github/issue_labeler.yml b/.github/issue_labeler.yml deleted file mode 100644 index cd0e254..0000000 --- a/.github/issue_labeler.yml +++ /dev/null @@ -1,2 +0,0 @@ -needs-triage: # if no label is set then set triage - - '' diff --git a/.github/pr_labeler.yml b/.github/pr_labeler.yml deleted file mode 100644 index b646f19..0000000 --- a/.github/pr_labeler.yml +++ /dev/null @@ -1,2 +0,0 @@ -"C:Rosetta": - - /**/* \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9b7409f..4ce9078 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,9 +37,6 @@ jobs: **/go.sum **/Makefile Makefile - ################### - #### Build App #### - ################### - name: Build if: env.GIT_DIFF run: GOARCH=${{ matrix.go-arch }} make build @@ -48,4 +45,4 @@ jobs: ################### - name: Build Rosetta if: env.GIT_DIFF - run: GOARCH=${{ matrix.go-arch }} make rosetta \ No newline at end of file + run: GOARCH=${{ matrix.go-arch }} make build \ No newline at end of file diff --git a/.github/workflows/pr_labeler.yml b/.github/workflows/pr_labeler.yml deleted file mode 100644 index 885d8b4..0000000 --- a/.github/workflows/pr_labeler.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: "Pull Request Labeler" -on: - - pull_request_target - -permissions: - contents: read - -jobs: - labeler: - permissions: - contents: read # for actions/labeler to determine modified files - pull-requests: write # for actions/labeler to add labels to PRs - runs-on: ubuntu-latest - steps: - - uses: actions/labeler@main - with: - configuration-path: .github/pr_labeler.yml - repo-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/rosetta-cli-test.yaml b/.github/workflows/rosetta-cli-test.yaml index f98986b..8453983 100644 --- a/.github/workflows/rosetta-cli-test.yaml +++ b/.github/workflows/rosetta-cli-test.yaml @@ -19,41 +19,8 @@ jobs: - uses: actions/setup-go@v5 with: go-version: '^1.21.1' - - name: Get cosmos-sdk repo - uses: actions/checkout@v4 - with: - repository: cosmos/cosmos-sdk - ref: main - path: './cosmos-sdk' - - name: set up simapp - run: - cd cosmos-sdk && - make build && - export SIMD_BIN=./build/simd && - make init-simapp - - name: Run simapp - run: ./cosmos-sdk/build/simd start & - - name: Wait for simd to boot up for 2 mins and produce blocks - run: sleep 120s - shell: bash - - name: Check blockchain status - run: curl localhost:26657/status - - name: Build Rosetta - run: go mod tidy && make rosetta && make plugin - - name: Run Rosetta service - run: ./rosetta --blockchain "cosmos" --network "cosmos" --tendermint "tcp://localhost:26657" --addr "localhost:8080" --grpc "localhost:9090" & - - name: Wait for rosetta boot up for 30 secs - run: sleep 30s - shell: bash - - name: Check rosetta status - run: curl localhost:8080/block - - name: Generate wallets and transactions - run: - export SIMD_BIN=./cosmos-sdk/build/simd && - chmod +x ./tests/rosetta-cli/data.sh && - ./tests/rosetta-cli/data.sh - shell: bash - - name: Test rosetta through Rosetta-cli + - name: Run make test-rosetta-ci run: - make rosetta-cli + COSMOS_SDK_VERSION=v0.50.3 + make test-rosetta-ci shell: bash \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c068d55..77b092d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,5 +37,4 @@ jobs: - name: tests if: env.GIT_DIFF run: | - make plugin && make test - go test -mod=readonly -timeout 30m -coverprofile=coverage.out -covermode=atomic ./... + make plugin && make test \ No newline at end of file diff --git a/Makefile b/Makefile index f432ff4..7789f61 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,25 @@ #!/usr/bin/make -f -all: build +all: build plugin build: - cd plugins/cosmos-hub && make plugin - go build -mod=readonly ./cmd/rosetta - -rosetta: go build -mod=readonly ./cmd/rosetta plugin: cd plugins/cosmos-hub && make plugin +docker: + docker build . --tag rosetta + test: - go test -mod=readonly ./... + go test -mod=readonly -timeout 30m -coverprofile=coverage.out -covermode=atomic ./... + +test-rosetta-ci: + sh ./scripts/simapp-start-node.sh + make build && make plugin + ./rosetta --blockchain "cosmos" --network "cosmos" --tendermint "tcp://localhost:26657" --addr "localhost:8080" --grpc "localhost:9090" & + sleep 30 + export SIMD_BIN=./cosmos-sdk/build/simd && sh ./tests/rosetta-cli/rosetta-cli-test.sh ############################################################################### ### Linting ### @@ -31,9 +37,3 @@ lint-fix: @./scripts/go-lint-all.bash --fix .PHONY: all build rosetta test lint lint-fix - -docker: - docker build . --tag rosetta - -rosetta-cli: - ./tests/rosetta-cli/rosetta-cli-test.sh \ No newline at end of file diff --git a/README.md b/README.md index 936666f..de74d98 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Install Rosetta standalone server with the following command: go install github.com/cosmos/rosetta ``` -Alternatively, for building from source, simply run `make rosetta`. The binary will be located in the root folder. +Alternatively, for building from source, simply run `make build`. The binary will be located in the root folder. ### Native - As a node command diff --git a/scripts/simapp-start-node.sh b/scripts/simapp-start-node.sh new file mode 100644 index 0000000..c327c46 --- /dev/null +++ b/scripts/simapp-start-node.sh @@ -0,0 +1,12 @@ +git clone https://github.com/cosmos/cosmos-sdk.git +# shellcheck disable=SC2164 +cd cosmos-sdk +git checkout "$COSMOS_SDK_VERSION" +make build +export SIMD_BIN=./build/simd +chmod 777 ./scripts/init-simapp.sh +sh ./scripts/init-simapp.sh --just-print +$SIMD_BIN start & +until curl --output /dev/null --silent --head --fail http://localhost:26657/health; do + sleep 1 +done \ No newline at end of file diff --git a/tests/rosetta-cli/data.sh b/tests/rosetta-cli/data.sh deleted file mode 100644 index 8328f6b..0000000 --- a/tests/rosetta-cli/data.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -SIMD_BIN=${SIMD_BIN:=$(which simd 2>/dev/null)} - -if [ -z "$SIMD_BIN" ]; then echo "SIMD_BIN is not set. Make sure to run make install before"; exit 1; fi - -# Global variables -KEY_RING_BACKEND="test" -CHAIN_ID="demo" -amount_of_wallets=100 - -validator_address=$($SIMD_BIN keys show alice -a --keyring-backend "$KEY_RING_BACKEND") - -echo "[INFO] Generating wallets: $amount_of_wallets" -for ((index=0; index<"$amount_of_wallets"; index++)) -do - random_number=$((1 + RANDOM % 10000)) - - wallet_name="wallet-$random_number" - $SIMD_BIN keys add $wallet_name --keyring-backend "$KEY_RING_BACKEND" - wallet_address=$($SIMD_BIN keys show $wallet_name -a --keyring-backend "$KEY_RING_BACKEND") - echo "[DEBUG] Generated wallet: $wallet_name - $wallet_address" - - amount="$((RANDOM*10))stake" - echo "[DEBUG] Generating tx from validator: $validator_address sending $amount to $wallet_address" - $SIMD_BIN tx bank send "$validator_address" "$wallet_address" "$amount" --chain-id "$CHAIN_ID" --keyring-backend "$KEY_RING_BACKEND" -y - - sleep 1s # Wait so the TXs can happen in different blocks -done