|
| 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 || 'feature/geth-testing'}} |
| 8 | + ipld-eth-db-ref: ${{ github.event.inputs.ipld-ethcl-db-ref || 'feature/startup-script' }} |
| 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 vulcanize/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.0" |
| 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.0" |
| 51 | + check-latest: true |
| 52 | + |
| 53 | + - name: Checkout code |
| 54 | + uses: actions/checkout@v2 |
| 55 | + |
| 56 | + - uses: actions/checkout@v3 |
| 57 | + with: |
| 58 | + ref: ${{ env.stack-orchestrator-ref }} |
| 59 | + path: "./stack-orchestrator/" |
| 60 | + repository: vulcanize/stack-orchestrator |
| 61 | + fetch-depth: 0 |
| 62 | + |
| 63 | + - uses: actions/checkout@v3 |
| 64 | + with: |
| 65 | + ref: ${{ env.ipld-eth-db-ref }} |
| 66 | + repository: vulcanize/ipld-eth-db |
| 67 | + path: "./ipld-eth-db/" |
| 68 | + fetch-depth: 0 |
| 69 | + |
| 70 | + - name: Create config file |
| 71 | + run: | |
| 72 | + echo vulcanize_ipld_eth_db=$GITHUB_WORKSPACE/ipld-eth-db/ > $GITHUB_WORKSPACE/config.sh |
| 73 | + echo vulcanize_go_ethereum=$GITHUB_WORKSPACE/go-ethereum/ >> $GITHUB_WORKSPACE/config.sh |
| 74 | + echo db_write=true >> $GITHUB_WORKSPACE/config.sh |
| 75 | + cat $GITHUB_WORKSPACE/config.sh |
| 76 | +
|
| 77 | + - name: Run docker compose |
| 78 | + run: | |
| 79 | + docker-compose \ |
| 80 | + -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-db-migration.yml" \ |
| 81 | + -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/latest/docker-compose-timescale-db.yml" \ |
| 82 | + --env-file $GITHUB_WORKSPACE/config.sh \ |
| 83 | + up -d --build |
| 84 | +
|
| 85 | + - name: Give the migration a few seconds |
| 86 | + run: sleep 30; |
| 87 | + |
| 88 | + - name: Run unit tests |
| 89 | + run: make statedifftest |
| 90 | + |
| 91 | + private-network-test: |
| 92 | + name: Start Geth in a private network. |
| 93 | + runs-on: ubuntu-latest |
| 94 | + steps: |
| 95 | + - name: Create GOPATH |
| 96 | + run: mkdir -p /tmp/go |
| 97 | + |
| 98 | + - uses: actions/setup-go@v3 |
| 99 | + with: |
| 100 | + go-version: ">=1.18.0" |
| 101 | + check-latest: true |
| 102 | + |
| 103 | + - name: Checkout code |
| 104 | + uses: actions/checkout@v3 |
| 105 | + with: |
| 106 | + path: "./go-ethereum" |
| 107 | + |
| 108 | + - uses: actions/checkout@v3 |
| 109 | + with: |
| 110 | + ref: ${{ env.stack-orchestrator-ref }} |
| 111 | + path: "./stack-orchestrator/" |
| 112 | + repository: vulcanize/stack-orchestrator |
| 113 | + fetch-depth: 0 |
| 114 | + |
| 115 | + - uses: actions/checkout@v3 |
| 116 | + with: |
| 117 | + ref: ${{ env.ipld-eth-db-ref }} |
| 118 | + repository: vulcanize/ipld-eth-db |
| 119 | + path: "./ipld-eth-db/" |
| 120 | + fetch-depth: 0 |
| 121 | + |
| 122 | + - name: Create config file |
| 123 | + run: | |
| 124 | + echo vulcanize_ipld_eth_db=$GITHUB_WORKSPACE/ipld-eth-db/ > $GITHUB_WORKSPACE/config.sh |
| 125 | + echo vulcanize_go_ethereum=$GITHUB_WORKSPACE/go-ethereum/ >> $GITHUB_WORKSPACE/config.sh |
| 126 | + echo db_write=true >> $GITHUB_WORKSPACE/config.sh |
| 127 | + cat $GITHUB_WORKSPACE/config.sh |
| 128 | +
|
| 129 | + - name: Compile Geth |
| 130 | + run: | |
| 131 | + cd $GITHUB_WORKSPACE/stack-orchestrator/helper-scripts |
| 132 | + ./compile-geth.sh -e docker -p $GITHUB_WORKSPACE/config.sh |
| 133 | + cd - |
| 134 | +
|
| 135 | + - name: Run docker compose |
| 136 | + run: | |
| 137 | + docker-compose \ |
| 138 | + -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-db-migration.yml" \ |
| 139 | + -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-go-ethereum4.yml" \ |
| 140 | + -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/latest/docker-compose-timescale-db.yml" \ |
| 141 | + --env-file $GITHUB_WORKSPACE/config.sh \ |
| 142 | + up -d --build |
| 143 | +
|
| 144 | + - name: Make sure the /root/transaction_info/STATEFUL_TEST_DEPLOYED_ADDRESS exists within a certain time frame. |
| 145 | + shell: bash |
| 146 | + run: | |
| 147 | + COUNT=0 |
| 148 | + ATTEMPTS=15 |
| 149 | + until $(docker compose -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 |
| 150 | + [[ $COUNT -eq $ATTEMPTS ]] && echo "Could not find the successful contract deployment" && (exit 1) |
| 151 | + cat ./STATEFUL_TEST_DEPLOYED_ADDRESS |
| 152 | + sleep 15; |
| 153 | +
|
| 154 | + - name: Create a new transaction. |
| 155 | + shell: bash |
| 156 | + run: | |
| 157 | + docker compose -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-go-ethereum.yml" exec go-ethereum /bin/bash /root/transaction_info/NEW_TRANSACTION |
| 158 | + echo $? |
| 159 | +
|
| 160 | + - name: Make sure we see entries in the header table |
| 161 | + shell: bash |
| 162 | + run: | |
| 163 | + rows=$(docker compose -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-go-ethereum.yml" exec access-node psql -U vdbm -d vulcanize_testing_v4 -AXqtc "SELECT COUNT(*) FROM eth.header_cids") |
| 164 | + [[ "$rows" -lt "1" ]] && echo "We could not find any rows in postgres table." && (exit 1) |
| 165 | + echo $rows |
| 166 | + docker compose -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-go-ethereum.yml" exec access-node psql -U vdbm -d vulcanize_testing_v4 -AXqtc "SELECT * FROM eth.header_cids" |
0 commit comments