Skip to content

Commit c55a0ec

Browse files
committed
git workflow evmone coverage script
1 parent a6a720f commit c55a0ec

File tree

2 files changed

+161
-0
lines changed

2 files changed

+161
-0
lines changed

.github/workflows/coverage.yaml

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
name: Evmone Coverage Report
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'converted-ethereum-tests.txt' # This triggers the workflow only for changes in file.txt
7+
8+
jobs:
9+
evmone-coverage-diff:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Cache EVMONE
14+
uses: actions/cache@v2
15+
with:
16+
path: ${{ github.workspace }}/evmoneimage
17+
key: ${{ runner.os }}-evmone-${{ hashFiles('evmone-hash.txt') }}
18+
restore-keys: |
19+
${{ runner.os }}-evmone-
20+
21+
- name: Checkout code
22+
uses: actions/checkout@v3
23+
with:
24+
ref: ${{ github.event.pull_request.head.ref }} # Checks out the PR branch
25+
fetch-depth: 0 # Necessary to fetch all history for diff
26+
27+
- name: Fetch target branch
28+
run: git fetch origin ${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
29+
30+
- name: Install deps
31+
run: |
32+
echo $(pwd)
33+
echo ${{ github.workspace }}
34+
35+
sudo apt-get install docker-ce
36+
37+
#install pyspec deps from root repo
38+
python3 --version
39+
python3 -m venv ./venv/
40+
source ./venv/bin/activate
41+
pip install -e .
42+
43+
44+
#install go
45+
curl -L --output go1.21.8.linux-amd64.tar.gz "https://go.dev/dl/go1.21.8.linux-amd64.tar.gz"
46+
tar -xf go1.21.8.linux-amd64.tar.gz
47+
sudo mv go /usr/local
48+
sudo ln -s /usr/local/go/bin/go /usr/local/bin/go
49+
git clone --depth 1 https://github.com/ethereum/go-ethereum.git
50+
cd go-ethereum
51+
go build ./cmd/evm
52+
cp evm /usr/local/bin
53+
cd ..
54+
55+
#install solc
56+
curl -L --output solc "https://github.com/ethereum/solidity/releases/download/v0.8.25/solc-static-linux"
57+
sudo mv solc /usr/local/bin
58+
sudo chmod +x /usr/local/bin/solc
59+
solc --version
60+
61+
#install tests
62+
cd ${{ github.workspace }}
63+
mkdir testpath
64+
cd testpath
65+
git init
66+
git remote add origin https://github.com/ethereum/tests.git
67+
git config core.sparseCheckout true
68+
git sparse-checkout set GeneralStateTests
69+
git pull origin develop
70+
cd ..
71+
72+
#install coverge script
73+
cd ${{ github.workspace }}
74+
git clone https://github.com/winsvega/evmtest_coverage.git
75+
mkdir -p ${{ github.workspace }}/evmoneimage
76+
77+
78+
# This command diffs the file and filters in new lines
79+
- name: Parse converted tests from converted-ethereum-tests.txt
80+
run: |
81+
echo "New lines introduced in converted-ethereum-tests.txt:"
82+
lines=$(git diff origin/${{ github.base_ref }} HEAD -- converted-ethereum-tests.txt | grep "^+" | grep -v "^+++")
83+
files=$(echo "$lines" | grep -oP '(?<=\+).+\.json')
84+
85+
if [ -z "$files" ]; then
86+
echo "Error: No new JSON files found in converted-ethereum-tests.txt"
87+
exit 1
88+
fi
89+
90+
for file in $files; do
91+
echo $file
92+
done
93+
94+
mkdir -p ${{ github.workspace }}/evmtest_coverage/testBASE
95+
for file in $files; do
96+
cp ${{ github.workspace }}/testpath/$file ${{ github.workspace }}/evmtest_coverage/testBASE
97+
done
98+
99+
100+
# This command diffs the .py scripts introduced by a PR
101+
- name: Parse and fill introduced test sources
102+
run: |
103+
python3 -m venv ./venv/
104+
source ./venv/bin/activate
105+
106+
files=$(git diff --name-status origin/${{ github.base_ref }}...HEAD -- tests/ | grep -E '^[AM]' | grep '\.py$')
107+
echo "Modified or new .py files in tests folder:"
108+
echo "$files" | while read line; do
109+
file=$(echo "$line" | cut -c 3-)
110+
echo $file
111+
done
112+
113+
# fill new tests
114+
echo "$files" | while read line; do
115+
file=$(echo "$line" | cut -c 3-)
116+
fill $file --until=Cancun
117+
done
118+
119+
files=$(find fixtures/state_tests -type f -name "*.json")
120+
if [ -z "$files" ]; then
121+
echo "Error: No filled JSON fixtures found in fixtures/state_tests."
122+
exit 1
123+
fi
124+
125+
mkdir -p ${{ github.workspace }}/evmtest_coverage/testPATCH
126+
find fixtures/state_tests -type f -name "*.json" -exec cp {} ${{ github.workspace }}/evmtest_coverage/testPATCH \;
127+
128+
- name: Download evmone image if not cached
129+
run: |
130+
cd ${{ github.workspace }}/evmoneimage
131+
if [ ! -f "evmone.tar" ]; then
132+
wget -O ${{ github.workspace }}/evmoneimage/evmone.tar http://retesteth.ethdevops.io/release/evmone.tar
133+
fi
134+
135+
- name: Run coverage script
136+
run: |
137+
docker --version
138+
echo "Original BASE tests:"
139+
ls ${{ github.workspace }}/evmtest_coverage/testBASE
140+
echo "Ported PATCH tests:"
141+
ls ${{ github.workspace }}/evmtest_coverage/testPATCH
142+
143+
echo "Loading docker image:"
144+
sudo docker image load --input ${{ github.workspace }}/evmoneimage/evmone.tar
145+
146+
cd ${{ github.workspace }}/evmtest_coverage
147+
sudo chmod +x ./dcoverage.sh
148+
sudo ./dcoverage.sh --base=testBASE --patch=testPATCH
149+
150+
- name: Upload coverage results
151+
uses: actions/upload-artifact@v3
152+
with:
153+
name: coverage-diff
154+
path: ${{ github.workspace }}/evmtest_coverage/coverage
155+
156+
- name: Verify coverage results
157+
run: |
158+
cd ${{ github.workspace }}/evmtest_coverage
159+
sudo chmod +x ./check.sh
160+
sudo ./check.sh

evmone-hash.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
af7f7be3b633043835e32faa5ba962b3

0 commit comments

Comments
 (0)