From 6c82eafef1978ccaf26d78238a9f626cc294557f Mon Sep 17 00:00:00 2001 From: Abdul Rabbani Date: Fri, 27 May 2022 15:27:23 -0400 Subject: [PATCH] Update go version for integration tests. --- .github/workflows/on-pr.yaml | 186 +-------------------------------- .github/workflows/publish.yaml | 3 + .github/workflows/tests.yaml | 181 ++++++++++++++++++++++++++++++++ 3 files changed, 186 insertions(+), 184 deletions(-) create mode 100644 .github/workflows/tests.yaml diff --git a/.github/workflows/on-pr.yaml b/.github/workflows/on-pr.yaml index 4a9bd625..1f195f42 100644 --- a/.github/workflows/on-pr.yaml +++ b/.github/workflows/on-pr.yaml @@ -2,187 +2,5 @@ name: Docker Build on: [pull_request] jobs: - build: - name: Run docker build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Run docker build - run: make docker-build - test: - name: Run unit tests - env: - GOPATH: /tmp/go - # To run the unit tests you need to add secrets to your repository. - BUILD_HOSTNAME: ${{ secrets.BUILD_HOSTNAME }} - BUILD_USERNAME: ${{ secrets.BUILD_USERNAME }} - BUILD_KEY: ${{ secrets.BUILD_KEY }} - #strategy: - # matrix: - # go-version: [1.16.x, 1.17.x] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - # Passed experience with GHA has taught me to store variables in files instead of passing them as variables. - - name: Output variables to files - run: | - echo $GITHUB_REPOSITORY > /tmp/git_repository - echo $GITHUB_HEAD_REF > /tmp/git_head_ref - echo "-----BEGIN OPENSSH PRIVATE KEY-----" >> /tmp/key - echo ${{ env.BUILD_KEY }} >> /tmp/key - echo "-----END OPENSSH PRIVATE KEY-----" >> /tmp/key - chmod 400 /tmp/key - cat /tmp/git_repository - cat /tmp/git_head_ref - - - name: Raw SCP - run: | - scp -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key /tmp/git_repository ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }}:/tmp/git_repository - scp -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key /tmp/git_head_ref ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }}:/tmp/git_head_ref - scp -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key .github/workflows/run_unit_test.sh ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }}:/tmp/run_unit_test.sh - - - name: Trigger Unit Test - run: | - ssh -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }} chmod +x /tmp/run_unit_test.sh /tmp/run_unit_test.sh - ssh -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }} /tmp/run_unit_test.sh - - - name: Get the logs and cat them - run: | - scp -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }}:/tmp/test.log . - cat ./test.log - - - name: Check Error Code - run: | - scp -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }}:/tmp/return_test.txt . - [ $(cat ./return_test.txt) -eq 0 ] - - integrationtest: - name: Run integration tests - env: - STACK_ORCHESTRATOR_REF: fcbc74451c5494664fe21f765e89c9c6565c07cb - GO_ETHEREUM_REF: 498101102c891c4f8c3cab5649158c642ee1fd6b - GOPATH: /tmp/go - DB_WRITE: true - ETH_FORWARD_ETH_CALLS: false - ETH_PROXY_ON_ERROR: false - ETH_HTTP_PATH: "go-ethereum:8545" - strategy: - matrix: - go-version: [1.16.x] - os: [ubuntu-latest] - runs-on: ${{ matrix.os }} - steps: - - name: Create GOPATH - run: mkdir -p /tmp/go - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - uses: actions/checkout@v2 - with: - path: "./ipld-eth-server" - - uses: actions/checkout@v2 - with: - ref: ${{ env.STACK_ORCHESTRATOR_REF }} - path: "./stack-orchestrator/" - repository: vulcanize/stack-orchestrator - - uses: actions/checkout@v2 - with: - ref: ${{ env.GO_ETHEREUM_REF }} - repository: vulcanize/go-ethereum - path: "./go-ethereum/" - - name: Create config file - run: | - echo vulcanize_go_ethereum=$GITHUB_WORKSPACE/go-ethereum/ > ./config.sh - echo vulcanize_ipld_eth_server=$GITHUB_WORKSPACE/ipld-eth-server/ >> ./config.sh - echo db_write=$DB_WRITE >> ./config.sh - echo eth_forward_eth_calls=$ETH_FORWARD_ETH_CALLS >> ./config.sh - echo eth_proxy_on_error=$ETH_PROXY_ON_ERROR >> ./config.sh - echo eth_http_path=$ETH_HTTP_PATH >> ./config.sh - cat ./config.sh - - name: Build geth - run: | - cd $GITHUB_WORKSPACE/stack-orchestrator/helper-scripts - ./compile-geth.sh \ - -p "$GITHUB_WORKSPACE/config.sh" \ - -e docker - - name: Run docker compose - run: | - docker-compose \ - -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/latest/docker-compose-db.yml" \ - -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-go-ethereum.yml" \ - -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-ipld-eth-server.yml" \ - --env-file "$GITHUB_WORKSPACE/config.sh" \ - up -d --build - - name: Test - run: | - cd $GITHUB_WORKSPACE/ipld-eth-server - while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8081)" != "200" ]; do echo "waiting for ipld-eth-server..." && sleep 5; done && \ - while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8545)" != "200" ]; do echo "waiting for geth-statediff..." && sleep 5; done && \ - make integrationtest - - integrationtest_forwardethcalls: - name: Run integration tests for direct proxy fall-through of eth_calls - env: - STACK_ORCHESTRATOR_REF: fcbc74451c5494664fe21f765e89c9c6565c07cb - GO_ETHEREUM_REF: 498101102c891c4f8c3cab5649158c642ee1fd6b - GOPATH: /tmp/go - DB_WRITE: false - ETH_FORWARD_ETH_CALLS: true - ETH_PROXY_ON_ERROR: false - ETH_HTTP_PATH: "go-ethereum:8545" - strategy: - matrix: - go-version: [1.16.x] - os: [ubuntu-latest] - runs-on: ${{ matrix.os }} - steps: - - name: Create GOPATH - run: mkdir -p /tmp/go - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - uses: actions/checkout@v2 - with: - path: "./ipld-eth-server" - - uses: actions/checkout@v2 - with: - ref: ${{ env.STACK_ORCHESTRATOR_REF }} - path: "./stack-orchestrator/" - repository: vulcanize/stack-orchestrator - - uses: actions/checkout@v2 - with: - ref: ${{ env.GO_ETHEREUM_REF }} - repository: vulcanize/go-ethereum - path: "./go-ethereum/" - - name: Create config file - run: | - echo vulcanize_go_ethereum=$GITHUB_WORKSPACE/go-ethereum/ > ./config.sh - echo vulcanize_ipld_eth_server=$GITHUB_WORKSPACE/ipld-eth-server/ >> ./config.sh - echo db_write=$DB_WRITE >> ./config.sh - echo eth_forward_eth_calls=$ETH_FORWARD_ETH_CALLS >> ./config.sh - echo eth_proxy_on_error=$ETH_PROXY_ON_ERROR >> ./config.sh - echo eth_http_path=$ETH_HTTP_PATH >> ./config.sh - cat ./config.sh - - name: Build geth - run: | - cd $GITHUB_WORKSPACE/stack-orchestrator/helper-scripts - ./compile-geth.sh \ - -p "$GITHUB_WORKSPACE/config.sh" \ - -e docker - - name: Run docker compose - run: | - docker-compose \ - -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/latest/docker-compose-db.yml" \ - -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-go-ethereum.yml" \ - -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-ipld-eth-server.yml" \ - --env-file "$GITHUB_WORKSPACE/config.sh" \ - up -d --build - - name: Test - run: | - cd $GITHUB_WORKSPACE/ipld-eth-server - while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8081)" != "200" ]; do echo "waiting for ipld-eth-server..." && sleep 5; done && \ - while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8545)" != "200" ]; do echo "waiting for geth-statediff..." && sleep 5; done && \ - make integrationtest + run-tests: + uses: ./.github/workflows/tests.yml diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 2315bc22..44cb84ec 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -3,9 +3,12 @@ on: release: types: [published] jobs: + run-tests: + uses: ./.github/workflows/tests.yml build: name: Run docker build runs-on: ubuntu-latest + needs: run-tests steps: - uses: actions/checkout@v2 - name: Get the version diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 00000000..1886a1d6 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,181 @@ +name: Test the stack. +on: + workflow_call: + +jobs: + build: + name: Run docker build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run docker build + run: make docker-build + test: + name: Run unit tests + env: + GOPATH: /tmp/go + # To run the unit tests you need to add secrets to your repository. + BUILD_HOSTNAME: ${{ secrets.BUILD_HOSTNAME }} + BUILD_USERNAME: ${{ secrets.BUILD_USERNAME }} + BUILD_KEY: ${{ secrets.BUILD_KEY }} + #strategy: + # matrix: + # go-version: [1.16.x, 1.17.x] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + # Passed experience with GHA has taught me to store variables in files instead of passing them as variables. + - name: Output variables to files + run: | + echo $GITHUB_REPOSITORY > /tmp/git_repository + echo $GITHUB_HEAD_REF > /tmp/git_head_ref + echo "-----BEGIN OPENSSH PRIVATE KEY-----" >> /tmp/key + echo ${{ env.BUILD_KEY }} >> /tmp/key + echo "-----END OPENSSH PRIVATE KEY-----" >> /tmp/key + chmod 400 /tmp/key + cat /tmp/git_repository + cat /tmp/git_head_ref + + - name: Raw SCP + run: | + scp -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key /tmp/git_repository ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }}:/tmp/git_repository + scp -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key /tmp/git_head_ref ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }}:/tmp/git_head_ref + scp -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key .github/workflows/run_unit_test.sh ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }}:/tmp/run_unit_test.sh + + - name: Trigger Unit Test + run: | + ssh -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }} chmod +x /tmp/run_unit_test.sh /tmp/run_unit_test.sh + ssh -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }} /tmp/run_unit_test.sh + + - name: Get the logs and cat them + run: | + scp -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }}:/tmp/test.log . + cat ./test.log + + - name: Check Error Code + run: | + scp -o 'StrictHostKeyChecking no' -o UserKnownHostsFile=/dev/null -q -i /tmp/key ${{ env.BUILD_USERNAME }}@${{ env.BUILD_HOSTNAME }}:/tmp/return_test.txt . + [ $(cat ./return_test.txt) -eq 0 ] + + integrationtest: + name: Run integration tests + env: + STACK_ORCHESTRATOR_REF: fcbc74451c5494664fe21f765e89c9c6565c07cb + GO_ETHEREUM_REF: 498101102c891c4f8c3cab5649158c642ee1fd6b + GOPATH: /tmp/go + DB_WRITE: true + ETH_FORWARD_ETH_CALLS: false + ETH_PROXY_ON_ERROR: false + ETH_HTTP_PATH: "go-ethereum:8545" + runs-on: ubuntu-latest + steps: + - name: Create GOPATH + run: mkdir -p /tmp/go + - uses: actions/setup-go@v3 + with: + go-version: ">=1.18.0" + check-latest: true + - uses: actions/checkout@v2 + with: + path: "./ipld-eth-server" + - uses: actions/checkout@v2 + with: + ref: ${{ env.STACK_ORCHESTRATOR_REF }} + path: "./stack-orchestrator/" + repository: vulcanize/stack-orchestrator + - uses: actions/checkout@v2 + with: + ref: ${{ env.GO_ETHEREUM_REF }} + repository: vulcanize/go-ethereum + path: "./go-ethereum/" + - name: Create config file + run: | + echo vulcanize_go_ethereum=$GITHUB_WORKSPACE/go-ethereum/ > ./config.sh + echo vulcanize_ipld_eth_server=$GITHUB_WORKSPACE/ipld-eth-server/ >> ./config.sh + echo db_write=$DB_WRITE >> ./config.sh + echo eth_forward_eth_calls=$ETH_FORWARD_ETH_CALLS >> ./config.sh + echo eth_proxy_on_error=$ETH_PROXY_ON_ERROR >> ./config.sh + echo eth_http_path=$ETH_HTTP_PATH >> ./config.sh + cat ./config.sh + - name: Build geth + run: | + cd $GITHUB_WORKSPACE/stack-orchestrator/helper-scripts + ./compile-geth.sh \ + -p "$GITHUB_WORKSPACE/config.sh" \ + -e docker + - name: Run docker compose + run: | + docker-compose \ + -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/latest/docker-compose-db.yml" \ + -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-go-ethereum.yml" \ + -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-ipld-eth-server.yml" \ + --env-file "$GITHUB_WORKSPACE/config.sh" \ + up -d --build + - name: Test + run: | + cd $GITHUB_WORKSPACE/ipld-eth-server + while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8081)" != "200" ]; do echo "waiting for ipld-eth-server..." && sleep 5; done && \ + while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8545)" != "200" ]; do echo "waiting for geth-statediff..." && sleep 5; done && \ + make integrationtest + + integrationtest_forwardethcalls: + name: Run integration tests for direct proxy fall-through of eth_calls + env: + STACK_ORCHESTRATOR_REF: fcbc74451c5494664fe21f765e89c9c6565c07cb + GO_ETHEREUM_REF: 498101102c891c4f8c3cab5649158c642ee1fd6b + GOPATH: /tmp/go + DB_WRITE: false + ETH_FORWARD_ETH_CALLS: true + ETH_PROXY_ON_ERROR: false + ETH_HTTP_PATH: "go-ethereum:8545" + runs-on: ubuntu-latest + steps: + - name: Create GOPATH + run: mkdir -p /tmp/go + - uses: actions/setup-go@v3 + with: + go-version: ">=1.18.0" + check-latest: true + - uses: actions/checkout@v2 + with: + path: "./ipld-eth-server" + - uses: actions/checkout@v2 + with: + ref: ${{ env.STACK_ORCHESTRATOR_REF }} + path: "./stack-orchestrator/" + repository: vulcanize/stack-orchestrator + - uses: actions/checkout@v2 + with: + ref: ${{ env.GO_ETHEREUM_REF }} + repository: vulcanize/go-ethereum + path: "./go-ethereum/" + - name: Create config file + run: | + echo vulcanize_go_ethereum=$GITHUB_WORKSPACE/go-ethereum/ > ./config.sh + echo vulcanize_ipld_eth_server=$GITHUB_WORKSPACE/ipld-eth-server/ >> ./config.sh + echo db_write=$DB_WRITE >> ./config.sh + echo eth_forward_eth_calls=$ETH_FORWARD_ETH_CALLS >> ./config.sh + echo eth_proxy_on_error=$ETH_PROXY_ON_ERROR >> ./config.sh + echo eth_http_path=$ETH_HTTP_PATH >> ./config.sh + cat ./config.sh + - name: Build geth + run: | + cd $GITHUB_WORKSPACE/stack-orchestrator/helper-scripts + ./compile-geth.sh \ + -p "$GITHUB_WORKSPACE/config.sh" \ + -e docker + - name: Run docker compose + run: | + docker-compose \ + -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/latest/docker-compose-db.yml" \ + -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-go-ethereum.yml" \ + -f "$GITHUB_WORKSPACE/stack-orchestrator/docker/local/docker-compose-ipld-eth-server.yml" \ + --env-file "$GITHUB_WORKSPACE/config.sh" \ + up -d --build + - name: Test + run: | + cd $GITHUB_WORKSPACE/ipld-eth-server + while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8081)" != "200" ]; do echo "waiting for ipld-eth-server..." && sleep 5; done && \ + while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8545)" != "200" ]; do echo "waiting for geth-statediff..." && sleep 5; done && \ + make integrationtest