Skip to content

Commit

Permalink
try git workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
winsvega committed Apr 12, 2024
1 parent e1427fc commit e9c5bcf
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 0 deletions.
134 changes: 134 additions & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Evmone Coverage Report

on:
pull_request:
paths:
- 'converted-ethereum-tests.txt' # This triggers the workflow only for changes in file.txt

jobs:
evmone-coverage-diff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache EVMONE
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/evmoneimage
key: ${{ runner.os }}-evmone-${{ hashFiles('evmone-hash.txt') }}
restore-keys: |
${{ runner.os }}-evmone-
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }} # Checks out the PR branch
fetch-depth: 0 # Necessary to fetch all history for diff

- 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 go
curl -L --output go1.21.8.linux-amd64.tar.gz "https://go.dev/dl/go1.21.8.linux-amd64.tar.gz"
tar -xf go1.21.8.linux-amd64.tar.gz
sudo mv go /usr/local
sudo ln -s /usr/local/go/bin/go /usr/local/bin/go
git clone --depth 1 https://github.com/ethereum/go-ethereum.git
cd go-ethereum
go build ./cmd/evm
cp evm /usr/local/bin
cd ..
#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 tests
cd ${{ github.workspace }}
mkdir testpath
cd testpath
git init
git remote add origin https://github.com/ethereum/tests.git
git config core.sparseCheckout true
git sparse-checkout set GeneralStateTests
git pull origin develop
cd ..
#install coverge script
cd ${{ github.workspace }}
git clone https://github.com/winsvega/evmtest_coverage.git
mkdir -p ${{ github.workspace }}/evmoneimage
# 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')
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
mkdir -p ${{ github.workspace }}/evmtest_coverage/testPATCH
find fixtures -type f -name "*.json"
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
ls ${{ github.workspace }}/evmtest_coverage/testBASE
ls ${{ github.workspace }}/evmtest_coverage/testPATCH
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
1 change: 1 addition & 0 deletions evmone-hash.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
af7f7be3b633043835e32faa5ba962b3

0 comments on commit e9c5bcf

Please sign in to comment.