|
| 1 | +id: execution-spec-tests-execute |
| 2 | +name: "Run 'execute' on execution spec tests" |
| 3 | +timeout: 1h |
| 4 | +config: |
| 5 | + gitRepo: https://github.com/ethereum/execution-spec-tests.git |
| 6 | + gitBranch: main |
| 7 | + testPath: "" |
| 8 | + chainID: "0" |
| 9 | + rpcEndpoint: http://127.0.0.1:8545 |
| 10 | + seedPrivateKey: "" |
| 11 | + seedAmount: "1" # (In Wei). Amount used to seed child accounts for test execution. Can also use "1 ether" or "10000 gwei" as input |
| 12 | + extraFlags: "" |
| 13 | + solcVersion: "0.8.24" |
| 14 | +tasks: |
| 15 | + - name: run_shell |
| 16 | + title: "Execute tests: ${gitRepo}@${gitBranch} [${testPath}]" |
| 17 | + id: execute |
| 18 | + config: |
| 19 | + shell: bash |
| 20 | + shellArgs: [--login] |
| 21 | + envVars: |
| 22 | + GIT_REPO: gitRepo |
| 23 | + GIT_BRANCH: gitBranch |
| 24 | + TEST_PATH: testPath |
| 25 | + CHAIN_ID: chainID |
| 26 | + RPC_ENDPOINT: rpcEndpoint |
| 27 | + PRIVATE_KEY: seedPrivateKey |
| 28 | + SEED_AMOUNT: seedAmount |
| 29 | + EXTRA_FLAGS: extraFlags |
| 30 | + SOLC_VERSION: "solcVersion" |
| 31 | + command: | |
| 32 | + set -e |
| 33 | +
|
| 34 | + # Convert env vars. They are passed as RAW JSON values |
| 35 | +
|
| 36 | + GIT_REPO=$(echo $GIT_REPO | jq -r) |
| 37 | + GIT_BRANCH=$(echo $GIT_BRANCH | jq -r) |
| 38 | + TEST_PATH=$(echo $TEST_PATH | jq -r) |
| 39 | + CHAIN_ID=$(echo $CHAIN_ID | jq -r) |
| 40 | + RPC_ENDPOINT=$(echo $RPC_ENDPOINT | jq -r) |
| 41 | + PRIVATE_KEY=$(echo $PRIVATE_KEY | jq -r) |
| 42 | + SEED_AMOUNT=$(echo $SEED_AMOUNT | jq -r) |
| 43 | + EXTRA_FLAGS=$(echo $EXTRA_FLAGS | jq -r) |
| 44 | + SOLC_VERSION=$(echo $SOLC_VERSION | jq -r) |
| 45 | +
|
| 46 | + echo "RPC_ENDPOINT: ${RPC_ENDPOINT}" |
| 47 | + echo "CHAIN_ID: ${CHAIN_ID}" |
| 48 | +
|
| 49 | + # Validate some inputs |
| 50 | + if [ -z "$TEST_PATH" ]; then |
| 51 | + echo |
| 52 | + exit "You need to provide a test path" |
| 53 | + fi |
| 54 | + if [ -z "$PRIVATE_KEY" ]; then |
| 55 | + echo |
| 56 | + exit "You need to provide a private key to fund the tests" |
| 57 | + fi |
| 58 | +
|
| 59 | + # Check if pip (python package manager) is installed |
| 60 | + if ! command -v pip &> /dev/null |
| 61 | + then |
| 62 | + echo "pip could not be found. Please install python3-pip" |
| 63 | + exit 1 |
| 64 | + fi |
| 65 | +
|
| 66 | + # Create dir for temp files |
| 67 | + tmp_dir=$(mktemp -d -t execution-spec-tests-XXXXXXXXXX) |
| 68 | + cd $tmp_dir |
| 69 | + export HOME=$tmp_dir |
| 70 | + echo "============================" |
| 71 | + echo "Temp dir created: ${tmp_dir}" |
| 72 | + echo "============================" |
| 73 | +
|
| 74 | + function cleanup { |
| 75 | + rv=$? |
| 76 | + rm -rf "$tmp_dir" |
| 77 | + echo "tmpdir removed" |
| 78 | + exit $rv |
| 79 | + } |
| 80 | +
|
| 81 | + trap cleanup EXIT # always remove tempdir on exit |
| 82 | +
|
| 83 | + echo "============================" |
| 84 | + echo "Clone git repo ${GIT_REPO} @ ${GIT_BRANCH}" |
| 85 | + echo "============================" |
| 86 | + git clone ${GIT_REPO} --branch ${GIT_BRANCH} --single-branch |
| 87 | + cd execution-spec-tests |
| 88 | +
|
| 89 | + echo "============================" |
| 90 | + echo "Installing dependencies" |
| 91 | + echo "============================" |
| 92 | + pip install uv |
| 93 | + uv sync --all-extras |
| 94 | + uv run solc-select use "${SOLC_VERSION}" --always-install |
| 95 | + source .venv/bin/activate |
| 96 | +
|
| 97 | + echo "============================" |
| 98 | + echo "Running test: ${TEST_PATH}" |
| 99 | + echo "============================" |
| 100 | + uv run execute remote "${TEST_PATH}" \ |
| 101 | + --rpc-chain-id=${CHAIN_ID} \ |
| 102 | + --rpc-endpoint=${RPC_ENDPOINT} \ |
| 103 | + --rpc-seed-key=${PRIVATE_KEY} \ |
| 104 | + --seed-account-sweep-amount=${SEED_AMOUNT} \ |
| 105 | + --json-report \ |
| 106 | + --json-report-file=report.json \ |
| 107 | + --html=report.html \ |
| 108 | + ${EXTRA_FLAGS[@]} |
| 109 | +
|
| 110 | + echo "============================" |
| 111 | + echo "Exporting reports" |
| 112 | + echo "============================" |
| 113 | + REPORT_JSON=$(cat report.json) |
| 114 | + REPORT_HTML=$(jq -Rs '.' report.html) |
| 115 | + echo "::set-output reportHTML ${REPORT_HTML}" |
| 116 | + echo "::set-output-json reportJSON ${REPORT_JSON}" |
| 117 | +
|
| 118 | + - name: run_task_matrix |
| 119 | + title: "Show test results" |
| 120 | + configVars: |
| 121 | + matrixValues: "tasks.execute.outputs.reportJSON.tests" |
| 122 | + config: |
| 123 | + runConcurrent: true |
| 124 | + matrixVar: "testResult" |
| 125 | + task: |
| 126 | + name: run_shell |
| 127 | + title: "${{testResult.nodeid}}" |
| 128 | + config: |
| 129 | + shell: bash |
| 130 | + envVars: |
| 131 | + TEST_RESULT: testResult |
| 132 | + command: | |
| 133 | + DURATION_SECONDS=$(echo $TEST_RESULT | jq -r '.setup.duration + .call.duration + .teardown.duration') |
| 134 | + echo "::set-output-json customRunTimeSeconds ${DURATION_SECONDS}" |
| 135 | + echo "::set-output-json execTestResult ${TEST_RESULT}" |
| 136 | + if $(echo $TEST_RESULT | jq -e '.outcome == "passed"') ; then |
| 137 | + echo "Test passed" |
| 138 | + else |
| 139 | + echo "Test failed" |
| 140 | + exit 1 |
| 141 | + fi |
0 commit comments