diff --git a/.github/actions/build-evmone-coverage/Dockerfile b/.github/actions/build-evmone-coverage/Dockerfile new file mode 100644 index 0000000000..747241f379 --- /dev/null +++ b/.github/actions/build-evmone-coverage/Dockerfile @@ -0,0 +1,9 @@ +# Container image that runs your code +FROM alpine:3.10 + +# Copies your code file from your action repository to the filesystem path `/` of the container +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +# Code file to execute when the docker container starts up (`entrypoint.sh`) +ENTRYPOINT ["/entrypoint.sh"] diff --git a/.github/actions/build-evmone-coverage/action.yaml b/.github/actions/build-evmone-coverage/action.yaml new file mode 100644 index 0000000000..782c83020b --- /dev/null +++ b/.github/actions/build-evmone-coverage/action.yaml @@ -0,0 +1,16 @@ +# action.yml +name: 'Hello World' +description: 'Greet someone and record the time' +inputs: + who-to-greet: # id of input + description: 'Who to greet' + required: true + default: 'World' +outputs: + time: # id of output + description: 'The time we greeted you' +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.who-to-greet }} diff --git a/.github/actions/build-evmone-coverage/entrypoint.sh b/.github/actions/build-evmone-coverage/entrypoint.sh new file mode 100755 index 0000000000..3fee027dff --- /dev/null +++ b/.github/actions/build-evmone-coverage/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/sh -l + +echo "Hello $1" +time=$(date) +echo "time=$time" >> $GITHUB_OUTPUT diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index ac10d6d408..9ef003a59e 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -15,137 +15,10 @@ jobs: ref: ${{ github.event.pull_request.head.ref }} # Checks out the PR branch fetch-depth: 0 # Necessary to fetch all history for diff - - name: Cache EVMONE - uses: actions/cache@v2 + - name: Docker Action + uses: ./github/actions/build-evmone-coverage@v2 with: - path: ${{ github.workspace }}/evmoneimage - key: ${{ runner.os }}-evmone-${{ hashFiles('evmone-hash.txt') }} - restore-keys: | - ${{ runner.os }}-evmone- + who-to-greet: 'Mona the Octocat' - - name: Fetch target branch - run: git fetch origin ${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }} - - name: Install deps - run: | - echo $(pwd) - echo ${{ github.workspace }} - sudo apt-get install docker-ce - - #install pyspec deps from root repo - python3 --version - python3 -m venv ./venv/ - source ./venv/bin/activate - pip install -e . - - #install solc - curl -L --output solc "https://github.com/ethereum/solidity/releases/download/v0.8.25/solc-static-linux" - sudo mv solc /usr/local/bin - sudo chmod +x /usr/local/bin/solc - solc --version - - #install coverge script - cd ${{ github.workspace }} - git clone https://github.com/winsvega/evmtest_coverage.git - mkdir -p ${{ github.workspace }}/evmoneimage - - # Required to fill .py tests - - name: Build GO EVM - uses: ./.github/actions/build-evm - id: evm-builder - with: - type: 'main' - - - name: Checkout ethereum/tests - uses: actions/checkout@v4 - with: - repository: ethereum/tests - path: testpath - sparse-checkout: | - GeneralStateTests - - - # This command diffs the file and filters in new lines - - name: Parse converted tests from converted-ethereum-tests.txt - run: | - echo "New lines introduced in converted-ethereum-tests.txt:" - lines=$(git diff origin/${{ github.base_ref }} HEAD -- converted-ethereum-tests.txt | grep "^+" | grep -v "^+++") - files=$(echo "$lines" | grep -oP '(?<=\+).+\.json') - - if [ -z "$files" ]; then - echo "Error: No new JSON files found in converted-ethereum-tests.txt" - exit 1 - fi - - for file in $files; do - echo $file - done - - mkdir -p ${{ github.workspace }}/evmtest_coverage/testBASE - for file in $files; do - cp ${{ github.workspace }}/testpath/$file ${{ github.workspace }}/evmtest_coverage/testBASE - done - - - # This command diffs the .py scripts introduced by a PR - - name: Parse and fill introduced test sources - run: | - python3 -m venv ./venv/ - source ./venv/bin/activate - - files=$(git diff --name-status origin/${{ github.base_ref }}...HEAD -- tests/ | grep -E '^[AM]' | grep '\.py$') - echo "Modified or new .py files in tests folder:" - echo "$files" | while read line; do - file=$(echo "$line" | cut -c 3-) - echo $file - done - - # fill new tests - echo "$files" | while read line; do - file=$(echo "$line" | cut -c 3-) - fill $file --until=Cancun - done - - files=$(find fixtures/state_tests -type f -name "*.json") - if [ -z "$files" ]; then - echo "Error: No filled JSON fixtures found in fixtures/state_tests." - exit 1 - fi - - mkdir -p ${{ github.workspace }}/evmtest_coverage/testPATCH - find fixtures/state_tests -type f -name "*.json" -exec cp {} ${{ github.workspace }}/evmtest_coverage/testPATCH \; - - - name: Download evmone image if not cached - run: | - cd ${{ github.workspace }}/evmoneimage - if [ ! -f "evmone.tar" ]; then - wget -O ${{ github.workspace }}/evmoneimage/evmone.tar http://retesteth.ethdevops.io/release/evmone.tar - fi - - - name: Run coverage script - run: | - docker --version - echo "Original BASE tests:" - ls ${{ github.workspace }}/evmtest_coverage/testBASE - echo "Ported PATCH tests:" - ls ${{ github.workspace }}/evmtest_coverage/testPATCH - - echo "Loading docker image:" - sudo docker image load --input ${{ github.workspace }}/evmoneimage/evmone.tar - - cd ${{ github.workspace }}/evmtest_coverage - sudo chmod +x ./dcoverage.sh - sudo ./dcoverage.sh --base=testBASE --patch=testPATCH - - - name: Upload coverage results - uses: actions/upload-artifact@v3 - with: - name: coverage-diff - path: ${{ github.workspace }}/evmtest_coverage/coverage - - - name: Verify coverage results - run: | - cd ${{ github.workspace }}/evmtest_coverage - sudo chmod +x ./check.sh - sudo ./check.sh