|
| 1 | +name: Tests for Geth that are used in multiple jobs. |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + |
| 6 | +env: |
| 7 | + stack-orchestrator-ref: ${{ github.event.inputs.stack-orchestrator-ref || 'f2fd766f5400fcb9eb47b50675d2e3b1f2753702'}} |
| 8 | + ipld-eth-db-ref: ${{ github.event.inputs.ipld-ethcl-db-ref || 'be345e0733d2c025e4082c5154e441317ae94cf7' }} |
| 9 | + GOPATH: /tmp/go |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Run docker build |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v2 |
| 17 | + - name: Run docker build |
| 18 | + run: docker build -t cerc-io/go-ethereum . |
| 19 | + |
| 20 | + geth-unit-test: |
| 21 | + name: Run geth unit test |
| 22 | + runs-on: ubuntu-latest |
| 23 | + env: |
| 24 | + GO111MODULE: on |
| 25 | + steps: |
| 26 | + - name: Create GOPATH |
| 27 | + run: mkdir -p /tmp/go |
| 28 | + |
| 29 | + - uses: actions/setup-go@v3 |
| 30 | + with: |
| 31 | + go-version: "1.18" |
| 32 | + check-latest: true |
| 33 | + |
| 34 | + - name: Checkout code |
| 35 | + uses: actions/checkout@v2 |
| 36 | + |
| 37 | + - name: Run unit tests |
| 38 | + run: | |
| 39 | + make test |
| 40 | +
|
| 41 | + statediff-unit-test: |
| 42 | + name: Run state diff unit test |
| 43 | + runs-on: ubuntu-latest |
| 44 | + steps: |
| 45 | + - name: Create GOPATH |
| 46 | + run: mkdir -p /tmp/go |
| 47 | + |
| 48 | + - uses: actions/setup-go@v3 |
| 49 | + with: |
| 50 | + go-version: "1.18" |
| 51 | + check-latest: true |
| 52 | + |
| 53 | + - name: Checkout code |
| 54 | + uses: actions/checkout@v2 |
| 55 | + |
| 56 | + - name: Run docker compose |
| 57 | + run: | |
| 58 | + docker-compose up -d |
| 59 | +
|
| 60 | + - name: Give the migration a few seconds |
| 61 | + run: sleep 30; |
| 62 | + |
| 63 | + - name: Run unit tests |
| 64 | + run: make statedifftest |
| 65 | + |
| 66 | + private-network-test: |
| 67 | + name: Start Geth in a private network. |
| 68 | + runs-on: ubuntu-latest |
| 69 | + steps: |
| 70 | + - name: Create GOPATH |
| 71 | + run: mkdir -p /tmp/go |
| 72 | + |
| 73 | + - uses: actions/setup-go@v3 |
| 74 | + with: |
| 75 | + go-version: "1.18" |
| 76 | + check-latest: true |
| 77 | + |
| 78 | + - name: Checkout code |
| 79 | + uses: actions/checkout@v3 |
| 80 | + with: |
| 81 | + path: "./go-ethereum" |
| 82 | + |
| 83 | + - uses: actions/checkout@v3 |
| 84 | + with: |
| 85 | + ref: ${{ env.stack-orchestrator-ref }} |
| 86 | + path: "./stack-orchestrator/" |
| 87 | + repository: vulcanize/stack-orchestrator |
| 88 | + fetch-depth: 0 |
| 89 | + |
| 90 | + - uses: actions/checkout@v3 |
| 91 | + with: |
| 92 | + ref: ${{ env.ipld-eth-db-ref }} |
| 93 | + repository: cerc-io/ipld-eth-db |
| 94 | + path: "./ipld-eth-db/" |
| 95 | + fetch-depth: 0 |
| 96 | + |
| 97 | + - name: Create config file |
| 98 | + run: | |
| 99 | + echo vulcanize_ipld_eth_db=$GITHUB_WORKSPACE/ipld-eth-db/ > $GITHUB_WORKSPACE/config.sh |
| 100 | + echo vulcanize_go_ethereum=$GITHUB_WORKSPACE/go-ethereum/ >> $GITHUB_WORKSPACE/config.sh |
| 101 | + echo db_write=true >> $GITHUB_WORKSPACE/config.sh |
| 102 | + echo genesis_file_path=start-up-files/go-ethereum/genesis.json >> $GITHUB_WORKSPACE/config.sh |
| 103 | + cat $GITHUB_WORKSPACE/config.sh |
| 104 | +
|
| 105 | + - name: Compile Geth |
| 106 | + run: | |
| 107 | + cd $GITHUB_WORKSPACE/stack-orchestrator/helper-scripts |
| 108 | + ./compile-geth.sh -e docker -p $GITHUB_WORKSPACE/config.sh |
| 109 | + cd - |
| 110 | +
|
| 111 | + - name: Run docker compose |
| 112 | + run: | |
| 113 | + docker-compose \ |
| 114 | + -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-go-ethereum.yml" \ |
| 115 | + -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-db-sharding.yml" \ |
| 116 | + --env-file $GITHUB_WORKSPACE/config.sh \ |
| 117 | + up -d --build |
| 118 | +
|
| 119 | + - name: Make sure the /root/transaction_info/STATEFUL_TEST_DEPLOYED_ADDRESS exists within a certain time frame. |
| 120 | + shell: bash |
| 121 | + run: | |
| 122 | + COUNT=0 |
| 123 | + ATTEMPTS=15 |
| 124 | + docker ps |
| 125 | + until $(docker compose -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-db-sharding.yml" -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-go-ethereum.yml" cp go-ethereum:/root/transaction_info/STATEFUL_TEST_DEPLOYED_ADDRESS ./STATEFUL_TEST_DEPLOYED_ADDRESS) || [[ $COUNT -eq $ATTEMPTS ]]; do echo -e "$(( COUNT++ ))... \c"; sleep 10; done |
| 126 | + [[ $COUNT -eq $ATTEMPTS ]] && echo "Could not find the successful contract deployment" && (exit 1) |
| 127 | + cat ./STATEFUL_TEST_DEPLOYED_ADDRESS |
| 128 | + sleep 15; |
| 129 | +
|
| 130 | + - name: Create a new transaction. |
| 131 | + shell: bash |
| 132 | + run: | |
| 133 | + docker compose -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-db-sharding.yml" -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-go-ethereum.yml" exec go-ethereum /bin/bash /root/transaction_info/NEW_TRANSACTION |
| 134 | + echo $? |
| 135 | +
|
| 136 | + - name: Make sure we see entries in the header table |
| 137 | + shell: bash |
| 138 | + run: | |
| 139 | + rows=$(docker compose -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-db-sharding.yml" -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-go-ethereum.yml" exec ipld-eth-db psql -U vdbm -d vulcanize_testing -AXqtc "SELECT COUNT(*) FROM eth.header_cids") |
| 140 | + [[ "$rows" -lt "1" ]] && echo "We could not find any rows in postgres table." && (exit 1) |
| 141 | + echo $rows |
| 142 | + docker compose -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-db-sharding.yml" -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-go-ethereum.yml" exec ipld-eth-db psql -U vdbm -d vulcanize_testing -AXqtc "SELECT * FROM eth.header_cids" |
0 commit comments