Skip to content

Commit

Permalink
github workflow split tests
Browse files Browse the repository at this point in the history
  • Loading branch information
udpatil committed Mar 30, 2024
1 parent 2c37349 commit d941672
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 40 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/eth_blocktests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@ defaults:
run:
shell: bash

env:
TOTAL_RUNNERS: 5

jobs:
split-blocktests:
name: "Split ETH Blocktests"
runner-indexes:
runs-on: ubuntu-latest
name: Generate runner indexes
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
json: ${{ steps.generate-index-list.outputs.json }}
steps:
- uses: actions/checkout@v2
- name: Clone ETH Blocktests
run: git clone https://github.com/ethereum/tests.git ethtests
- name: List ETH Blocktests
run: ./run_blocktests.sh list ./ethtests/BlockchainTests/ValidBlocks/
- name: Set the matrix output
id: set-matrix
run: echo "matrix=[$(cat blocktests_list.txt)]" >> $GITHUB_OUTPUT
- name: Echo matrix
run: echo ${{ steps.set-matrix.outputs.matrix }}
- id: generate-index-list
run: |
MAX_INDEX=$((${{ env.TOTAL_RUNNERS }}-1))
INDEX_LIST=$(seq 0 ${MAX_INDEX})
INDEX_JSON=$(jq --null-input --compact-output '. |= [inputs]' <<< ${INDEX_LIST})
echo "json=${INDEX_JSON}" >> $GITHUB_OUTPUT
eth-blocktests:
name: "Run ETH Blocktests"
needs: split-blocktests
name: "Run ETH Blocktests ${{ matrix.runner-index }}"
runs-on: ubuntu-latest
needs: runner-indexes
strategy:
fail-fast: false
matrix:
test-file: ${{fromJson(needs.split-blocktests.outputs.matrix)}}
# generate runner index array from 0 to total-runners
runner-index: ${{fromJson(needs.runner-indexes.outputs.json)}}
steps:
- uses: actions/checkout@v2

Expand All @@ -49,5 +49,5 @@ jobs:
- name: Clone ETH Blocktests
run: git clone https://github.com/ethereum/tests.git ethtests

- name: "Run ETH Blocktest ${{ matrix.test-file }}"
run: ./run_blocktests.sh run ${{ matrix.test-file }}
- name: "Run ETH Blocktest"
run: ./run_blocktests.sh ./ethtests/BlockchainTests/ValidBlocks/ ${{ matrix.runner-index }} ${{ env.TOTAL_RUNNERS }}
43 changes: 21 additions & 22 deletions run_blocktests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
set -e

# mode options are list, run, or all
mode=$1
block_tests_path=$2
block_tests_path=$1
runner_index=$2
runner_total=$3

if [ -z "$runner_index" ]; then
runner_index=0
runner_total=1
fi

echo $mode
echo $block_tests_path
Expand Down Expand Up @@ -43,6 +49,8 @@ block_tests=$(find "$block_tests_path" -name "*.json")

test_files=""

i=0

# for each json file, run the block test
for test_file in $block_tests; do
test_name=$(basename "$test_file" .json)
Expand All @@ -59,26 +67,17 @@ for test_file in $block_tests; do
continue
fi

if [ $mode == "list" ]; then
# append to test_files if non-empty, otherwise set to test_files
if [ -z "$test_files" ]; then
test_files="\"$test_file\""
else
test_files="$test_files,\"$test_file\""
fi
if [ $((i % runner_total)) -ne $runner_index ]; then
continue
elif [ $mode == "all" ]; then
echo -e "\n*********************************************************\n"
echo "Running block test: $test_file"
echo "test name: ${test_name}_Cancun"
echo -e "\n*********************************************************\n"
rm -r ~/.sei || true
NO_RUN=1 ./scripts/initialize_local_chain.sh
seid blocktest --block-test $test_file --test-name "${test_name}_Cancun"
fi
done

if [ $mode == "list" ]; then
echo "Writing blocktests list to blocktests_list.txt"
echo "$test_files" > blocktests_list.txt
fi
i=$i + 1

echo -e "\n*********************************************************\n"
echo "Running block test: $test_file"
echo "test name: ${test_name}_Cancun"
echo -e "\n*********************************************************\n"
rm -r ~/.sei || true
NO_RUN=1 ./scripts/initialize_local_chain.sh
seid blocktest --block-test $test_file --test-name "${test_name}_Cancun"
done

0 comments on commit d941672

Please sign in to comment.