Test Hive #183
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test Hive | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - 'release/**' | |
| schedule: | |
| - cron: "0 05 * * *" # daily at 5 am UTC | |
| workflow_dispatch: | |
| jobs: | |
| test-hive: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Hive | |
| uses: actions/checkout@v5 | |
| with: | |
| repository: ethereum/hive | |
| # ref: master | |
| path: hive | |
| - name: Setup go env and cache | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: '>=1.24' | |
| go-version-file: 'hive/go.mod' | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.ORG_DOCKERHUB_ERIGONTECH_USERNAME }} | |
| password: ${{ secrets.ORG_DOCKERHUB_ERIGONTECH_TOKEN }} | |
| # Targetting the clients/erigon/Dockerfile.git in the Hive director - | |
| # this builds the container from github and uses it for tests | |
| - name: Get dependencies and build hive | |
| run: | | |
| cd hive | |
| go get . >> buildlogs.log | |
| rm clients/erigon/Dockerfile | |
| mv clients/erigon/Dockerfile.git clients/erigon/Dockerfile | |
| branch_name=$(echo ${GITHUB_REF#refs/heads/} | sed 's/[&/\]/\\&/g') | |
| echo Building Hive with Erigon branch - $branch_name | |
| sed -i "s/^ARG tag=main$/ARG tag=${branch_name}/" clients/erigon/Dockerfile | |
| go build . >> buildlogs.log | |
| # Depends on the last line of hive output that prints the number of suites, tests and failed | |
| # Currently, we fail even if suites and tests are too few, indicating the tests did not run | |
| # We also fail if more than half the tests fail | |
| - name: Run hive tests and parse output | |
| run: | | |
| cd hive | |
| run_suite() { | |
| if [ $# -ne 3 ]; then | |
| echo "Error: run_suite requires exactly 3 parameters" | |
| echo "Usage: run_suite <sim> <sim.limit> <max_allowed_failures>" | |
| echo "Provided: $# parameters" | |
| exit 1 | |
| fi | |
| echo -e "\n\n============================================================" | |
| echo "Running test: ${1}-${2}" | |
| echo -e "\n" | |
| ./hive -docker.auth --sim ethereum/"${1}" --sim.limit="${2}" --client erigon 2>&1 | tee output.log || { | |
| if [ $? -gt 0 ]; then | |
| echo "Exitcode gt 0" | |
| fi | |
| } | |
| status_line=$(tail -2 output.log | head -1 | sed -r "s/\x1B\[[0-9;]*[a-zA-Z]//g") | |
| suites=$(echo "$status_line" | sed -n 's/.*suites=\([0-9]*\).*/\1/p') | |
| if [ -z "$suites" ]; then | |
| status_line=$(tail -1 output.log | sed -r "s/\x1B\[[0-9;]*[a-zA-Z]//g") | |
| suites=$(echo "$status_line" | sed -n 's/.*suites=\([0-9]*\).*/\1/p') | |
| fi | |
| tests=$(echo "$status_line" | sed -n 's/.*tests=\([0-9]*\).*/\1/p') | |
| failed=$(echo "$status_line" | sed -n 's/.*failed=\([0-9]*\).*/\1/p') | |
| echo -e "\n" | |
| echo "----------- Results for ${1}-${2} -----------" | |
| echo "Tests: $tests, Failed: $failed" | |
| echo -e "\n\n============================================================" | |
| if (( tests < 4 )); then | |
| echo "Too few tests run for suite ${1}-${2} - ${tests} tests" | |
| echo "failed" > failed.log | |
| exit 1 | |
| fi | |
| max_allowed_failures="${3}" | |
| if (( failed > max_allowed_failures )); then | |
| echo "Too many failures for suite ${1}-${2} - ${failed} failed out of ${tests}" | |
| echo "failed" > failed.log | |
| exit 1 | |
| fi | |
| } | |
| run_suite engine exchange-capabilities 0 | |
| run_suite engine withdrawals 2 | |
| run_suite engine cancun 0 | |
| run_suite engine api 0 | |
| # run_suite engine auth 0 | |
| # run_suite rpc compat 0 | |
| continue-on-error: true | |
| - name: Upload output log | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: hive-workspace-log | |
| path: hive/workspace/logs | |
| continue-on-error: true | |
| - name: Check for failures | |
| run: | | |
| if grep -q "failed" hive/failed.log; then | |
| echo "One or more tests failed." | |
| exit 1 | |
| fi | |
| echo "All tests passed successfully." | |
| # This step is not required UNTIL the github-managed runners are dismissed in favor of self-hosted ones (which is planned) | |
| # So it is good to PROACTIVELY run it (it should not cause any issues within github-managed runners either) | |
| - name: Remove Hive directory | |
| run: | | |
| echo "Removing the Hive directory..." | |
| rm -rf hive | |
| if: always() | |
| # This step is not required UNTIL the github-managed runners are dismissed in favor of self-hosted ones (which is planned) | |
| # So it is good to PROACTIVELY run it (it should not cause any issues within github-managed runners either) | |
| - name: Prune docker | |
| run: | | |
| echo "Pruning docker..." | |
| docker system prune -af --volumes | |
| if: always() |