Skip to content

Commit 4852638

Browse files
authored
feat(github): coverage workflow using evmone script (#503)
1 parent e80addb commit 4852638

File tree

2 files changed

+156
-0
lines changed

2 files changed

+156
-0
lines changed

.github/workflows/coverage.yaml

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
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+
- name: Checkout code
13+
uses: actions/checkout@v3
14+
with:
15+
ref: ${{ github.event.pull_request.head.ref }} # Checks out the PR branch
16+
fetch-depth: 0 # Necessary to fetch all history for diff
17+
18+
- name: Fetch target branch
19+
run: git fetch origin ${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
20+
21+
- name: Install deps
22+
run: |
23+
echo $(pwd)
24+
echo ${{ github.workspace }}
25+
26+
#install pyspec deps from root repo
27+
python3 --version
28+
python3 -m venv ./venv/
29+
source ./venv/bin/activate
30+
pip install -e .
31+
32+
#install solc
33+
curl -L --output solc "https://github.com/ethereum/solidity/releases/download/v0.8.25/solc-static-linux"
34+
sudo mv solc /usr/local/bin
35+
sudo chmod +x /usr/local/bin/solc
36+
solc --version
37+
38+
# Required to fill .py tests
39+
- name: Build GO EVM
40+
uses: ./.github/actions/build-evm
41+
id: evm-builder
42+
with:
43+
type: 'main'
44+
45+
- name: Build EVMONE EVM
46+
uses: ./.github/actions/build-evmone-evm
47+
id: evm-builder2
48+
with:
49+
type: 'main'
50+
51+
- name: Checkout ethereum/tests
52+
uses: actions/checkout@v4
53+
with:
54+
repository: ethereum/tests
55+
path: testpath
56+
sparse-checkout: |
57+
GeneralStateTests
58+
59+
60+
# This command diffs the file and filters in new lines
61+
- name: Parse converted tests from converted-ethereum-tests.txt
62+
run: |
63+
echo "New lines introduced in converted-ethereum-tests.txt:"
64+
lines=$(git diff origin/${{ github.base_ref }} HEAD -- converted-ethereum-tests.txt | grep "^+" | grep -v "^+++")
65+
files=$(echo "$lines" | grep -oP '(?<=\+).+\.json')
66+
67+
if [ -z "$files" ]; then
68+
echo "Error: No new JSON files found in converted-ethereum-tests.txt"
69+
exit 1
70+
fi
71+
72+
for file in $files; do
73+
echo $file
74+
done
75+
76+
mkdir -p ${{ github.workspace }}/evmtest_coverage/coverage/BASE_TESTS
77+
for file in $files; do
78+
cp ${{ github.workspace }}/testpath/$file ${{ github.workspace }}/evmtest_coverage/coverage/BASE_TESTS
79+
done
80+
81+
82+
# This command diffs the .py scripts introduced by a PR
83+
- name: Parse and fill introduced test sources
84+
run: |
85+
python3 -m venv ./venv/
86+
source ./venv/bin/activate
87+
88+
files=$(git diff --name-status origin/${{ github.base_ref }}...HEAD -- tests/ | grep -E '^[AM]' | grep '\.py$')
89+
echo "Modified or new .py files in tests folder:"
90+
echo "$files" | while read line; do
91+
file=$(echo "$line" | cut -c 3-)
92+
echo $file
93+
done
94+
95+
# fill new tests
96+
echo "$files" | while read line; do
97+
file=$(echo "$line" | cut -c 3-)
98+
fill $file --until=Cancun --evm-bin evmone-t8n
99+
done
100+
101+
files=$(find fixtures/state_tests -type f -name "*.json")
102+
if [ -z "$files" ]; then
103+
echo "Error: No filled JSON fixtures found in fixtures/state_tests."
104+
exit 1
105+
fi
106+
107+
mkdir -p ${{ github.workspace }}/evmtest_coverage/coverage/PATCH_TESTS
108+
find fixtures/state_tests -type f -name "*.json" -exec cp {} ${{ github.workspace }}/evmtest_coverage/coverage/PATCH_TESTS \;
109+
110+
- name: Print tests that will be covered
111+
run: |
112+
echo "Original BASE tests:"
113+
ls ${{ github.workspace }}/evmtest_coverage/coverage/BASE_TESTS
114+
echo "--------------------"
115+
echo "Ported PATCH tests:"
116+
ls ${{ github.workspace }}/evmtest_coverage/coverage/PATCH_TESTS
117+
118+
- name: Run coverage of the BASE tests
119+
uses: addnab/docker-run-action@v3
120+
with:
121+
image: winsvega/evmone-coverage-script:latest
122+
options: -v ${{ github.workspace }}/evmtest_coverage/coverage:/tests
123+
run: /entrypoint.sh --mode=cover --testpath=/tests/BASE_TESTS --outputname=BASE
124+
125+
- name: Run coverage of the PATCH tests
126+
uses: addnab/docker-run-action@v3
127+
with:
128+
image: winsvega/evmone-coverage-script:latest
129+
options: -v ${{ github.workspace }}/evmtest_coverage/coverage:/tests
130+
run: /entrypoint.sh --mode=cover --testpath=/tests/PATCH_TESTS --outputname=PATCH
131+
132+
- name: Run coverage DIFF of the PATCH tests compared to BASE tests
133+
uses: addnab/docker-run-action@v3
134+
with:
135+
image: winsvega/evmone-coverage-script:latest
136+
options: -v ${{ github.workspace }}/evmtest_coverage/coverage:/tests
137+
run: /entrypoint.sh --mode=diff --basefile=coverage_BASE.lcov --patchfile=coverage_PATCH.lcov
138+
139+
- name: Chmod coverage results
140+
run: |
141+
user=$(whoami)
142+
sudo chown -R $user:$user ${{ github.workspace }}/evmtest_coverage/coverage
143+
144+
- name: Upload coverage results
145+
uses: actions/upload-artifact@v3
146+
with:
147+
name: coverage-diff
148+
path: ${{ github.workspace }}/evmtest_coverage/coverage
149+
150+
- name: Verify coverage results
151+
uses: addnab/docker-run-action@v3
152+
with:
153+
image: winsvega/evmone-coverage-script:latest
154+
options: -v ${{ github.workspace }}/evmtest_coverage/coverage:/tests
155+
run: /check.sh

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Test fixtures for use by clients are available for each release on the [Github r
3636
- ✨ Add a CLI tool that generates blockchain tests as Python from a transaction hash ([#470](https://github.com/ethereum/execution-spec-tests/pull/470), [#576](https://github.com/ethereum/execution-spec-tests/pull/576)).
3737
- ✨ Add more Transaction and Block exceptions from existing ethereum/tests repo ([#572](https://github.com/ethereum/execution-spec-tests/pull/572)).
3838
- ✨ Add "description" and "url" fields containing test case documentation and a source code permalink to fixtures during `fill` and use them in `consume`-generated Hive test reports ([#579](https://github.com/ethereum/execution-spec-tests/pull/579)).
39+
- ✨ Add git workflow evmone coverage script for any new lines mentioned in converted_ethereum_tests.txt ([#503](https://github.com/ethereum/execution-spec-tests/pull/503)).
3940

4041
### 🔧 EVM Tools
4142

0 commit comments

Comments
 (0)