@@ -3,60 +3,99 @@ name: Evmone Coverage Report
3
3
on :
4
4
pull_request :
5
5
paths :
6
- - " converted-ethereum-tests.txt" # This triggers the workflow only for changes in file.txt
6
+ - ' tests/**' # This triggers the workflow for any changes in the tests folder
7
+ - ' !tests/prague/**' # exclude changes in 'tests/prague'
8
+ - ' !tests/osaka/**' # exclude changes in 'tests/osaka'
7
9
8
10
jobs :
9
11
evmone-coverage-diff :
10
12
runs-on : ubuntu-latest
11
- strategy :
12
- matrix :
13
- driver : [retesteth, native]
14
13
15
14
steps :
16
15
- name : Checkout code
17
- uses : actions/checkout@v3
16
+ uses : actions/checkout@v4
17
+
18
+ - name : Debug GitHub context
19
+ run : |
20
+ echo "Git reference: ${{ github.ref }}"
21
+ echo "Git head ref: ${{ github.head_ref }}"
22
+ echo "Git base ref: ${{ github.base_ref }}"
23
+ echo "Node Version: $(node -v)"
24
+ echo "NPM Version: $(npm -v)"
25
+
26
+
27
+ - name : Get all changed python files in tests/ and changes to coverted-ethereum-tests.txt
28
+ id : changed-tests
29
+ uses : tj-actions/changed-files@v45
30
+ with :
31
+ # TODO: non-test modules such as __init__.py or spec.py could effect coverage - in this case we should
32
+ # fill all applicable tests (i.e., all the test_*.py files in or under the changed module's directory)
33
+ include_all_old_new_renamed_files : true
34
+ output_renamed_files_as_deleted_and_added : true
35
+ files_yaml : |
36
+ tests:
37
+ - tests/**/test_*.py
38
+ - '!tests/prague/**'
39
+ - '!tests/osaka/**'
40
+ converted_tests:
41
+ - converted-ethereum-tests.txt
42
+
43
+ - name : Exit workflow if there are no changed python files
44
+ if : steps.changed-tests.outputs.tests_any_changed != 'true'
45
+ run : |
46
+ echo "No python files were changed in ./tests/ - no action necessary"
47
+ exit 0
18
48
19
- - name : Fetch target branch
20
- run : git fetch origin ${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
49
+ - name : Report changed python test moudules
50
+ if : steps.changed-tests.outputs.tests_any_changed == 'true'
51
+ run : |
52
+ echo "${{ toJson(steps.changed-tests.outputs) }}"
53
+ echo "Changed python test modules: ${{ steps.changed-tests.outputs.tests_all_modified_files }}"
54
+
55
+ - name : Debug GitHub context
56
+ run : |
57
+ echo "Git reference: ${{ github.ref }}"
58
+ echo "Git head ref: ${{ github.head_ref }}"
59
+ echo "Git base ref: ${{ github.base_ref }}"
21
60
22
61
- name : Log in to Docker Hub
62
+ if : ${{ steps.changed-tests.outputs.tests_any_changed == 'true' && github.event.pull_request.head.repo.full_name == github.repository }}
23
63
uses : docker/login-action@v3
24
- if : ${{ github.event.pull_request.head.repo.full_name == github.repository }}
25
64
with :
26
65
username : winsvega
27
66
password : ${{ secrets.DOCKERHUB_PASSWORD }}
28
67
29
68
- name : Install deps
69
+ if : steps.changed-tests.outputs.tests_any_changed == 'true'
30
70
run : |
31
71
echo $(pwd)
32
72
echo ${{ github.workspace }}
33
73
34
74
- name : Set up uv
75
+ if : steps.changed-tests.outputs.tests_any_changed == 'true'
35
76
uses : ./.github/actions/setup-uv
36
77
37
78
- name : Set up Python
79
+ if : steps.changed-tests.outputs.tests_any_changed == 'true'
38
80
run : uv python install 3.10
39
81
40
82
- name : Install EEST
83
+ if : steps.changed-tests.outputs.tests_any_changed == 'true'
41
84
run : |
42
85
uv sync --no-progress
43
86
uv run python --version
44
87
45
88
# Required to fill .py tests
46
- - name : Build GO EVM
47
- uses : ./.github/actions/build-evm-client/geth
48
- id : evm-builder
49
- with :
50
- type : " main"
51
-
52
89
- name : Build EVMONE EVM
53
90
uses : ./.github/actions/build-evm-client/evmone
91
+ if : steps.changed-tests.outputs.tests_any_changed == 'true'
54
92
id : evm-builder2
55
93
with :
56
- type : " main "
94
+ targets : " evmone-t8n "
57
95
58
96
- name : Checkout ethereum/tests
59
97
uses : actions/checkout@v4
98
+ if : steps.changed-tests.outputs.tests_any_changed == 'true'
60
99
with :
61
100
repository : ethereum/tests
62
101
path : testpath
66
105
67
106
- name : Checkout ethereum/legacytests
68
107
uses : actions/checkout@v4
108
+ if : steps.changed-tests.outputs.tests_any_changed == 'true'
69
109
with :
70
110
repository : ethereum/legacytests
71
111
path : legacytestpath
@@ -74,16 +114,19 @@ jobs:
74
114
75
115
# This command diffs the file and filters in new lines
76
116
- name : Parse converted tests from converted-ethereum-tests.txt
117
+ if : steps.changed-tests.outputs.tests_any_changed == 'true'
77
118
run : |
78
119
echo "New lines introduced in converted-ethereum-tests.txt:"
79
- lines=$(git diff origin/${{ github.base_ref }} HEAD -- converted-ethereum-tests.txt | grep "^+" | grep -v "^+++")
80
- files=$(echo "$lines" | grep -oP '(?<=\+).+\.json')
81
-
82
- if [ -z "$files" ]; then
83
- echo "Error: No new JSON files found in converted-ethereum-tests.txt"
84
- exit 1
120
+ lines=$(git diff origin/${{ github.base_ref }} HEAD -- converted-ethereum-tests.txt | grep "^+" | grep -v "^+++" || true)
121
+ if [ -z "$lines" ]; then
122
+ echo "No new lines in converted-ethereum-tests.txt, check updates instead:"
123
+ echo "converted_skip=true" >> $GITHUB_ENV
124
+ exit 0
125
+ else
126
+ echo "converted_skip=false" >> $GITHUB_ENV
85
127
fi
86
128
129
+ files=$(echo "$lines" | grep -oP '(?<=\+).+\.json')
87
130
for file in $files; do
88
131
echo $file
89
132
done
@@ -123,53 +166,26 @@ jobs:
123
166
124
167
# This command diffs the .py scripts introduced by a PR
125
168
- name : Parse and fill introduced test sources
169
+ if : steps.changed-tests.outputs.tests_any_changed == 'true'
170
+ env :
171
+ CHANGED_TEST_FILES : ${{ steps.changed-tests.outputs.tests_all_changed_files }}
126
172
run : |
127
- python3 -m venv ./venv/
128
- source ./venv/bin/activate
129
-
130
- if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
131
- # Fetch changes when PR comes from remote repo
132
- git fetch origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
133
- git fetch origin +refs/pull/${{ github.event.pull_request.number }}/head:refs/remotes/origin/PR-${{ github.event.pull_request.number }}
134
- files=$(git diff --name-status origin/${{ github.base_ref }}...origin/PR-${{ github.event.pull_request.number }} -- tests/ | grep -E '^[AM]' | grep '\.py$')
135
- else
136
- # Fetch the base branch and the head branch
137
- git fetch origin ${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
138
- git fetch origin ${{ github.head_ref }}:refs/remotes/origin/${{ github.head_ref }}
139
-
140
- # Perform the diff
141
- files=$(git diff --name-status origin/${{ github.base_ref }}...origin/${{ github.head_ref }} -- tests/ | grep -E '^[AM]' | grep '\.py$')
142
- fi
143
-
144
-
145
- echo "Modified or new .py files in tests folder:"
146
- echo "$files" | while read line; do
147
- file=$(echo "$line" | cut -c 3-)
148
- echo $file
149
- done
173
+ source $GITHUB_ENV
174
+ files=$(echo "$CHANGED_TEST_FILES" | tr ',' '\n')
150
175
151
176
# fill new tests
152
177
# using `|| true` here because if no tests found, pyspec fill returns error code
153
178
mkdir -p fixtures/state_tests
154
179
mkdir -p fixtures/eof_tests
155
- echo "$files" | while read line; do
156
- file=$(echo "$line" | cut -c 3-)
157
- uv run fill $file --until=Cancun --evm-bin evmone-t8n --solc-version=0.8.25 || true >> filloutput.log 2>&1
158
- (uv run fill $file --fork=CancunEIP7692 --evm-bin evmone-t8n --solc-version=0.8.25 -k eof_test || true) > >(tee -a filloutput.log filloutputEOF.log) 2>&1
159
- done
180
+
181
+ echo "uv run fill $files --until=Cancun --evm-bin evmone-t8n >> filloutput.log 2>&1"
182
+ uv run fill $files --until=Cancun --evm-bin evmone-t8n >> filloutput.log 2>&1
183
+ cat filloutput.log
160
184
161
185
if grep -q "FAILURES" filloutput.log; then
162
186
echo "Error: failed to generate .py tests."
163
187
exit 1
164
188
fi
165
- if [ "${{ matrix.driver }}" = "retesteth" ] && grep -q "passed" filloutputEOF.log; then
166
- echo "Disabling retesteth coverage check as EOF tests detected!"
167
- echo "retesteth_skip=true" >> $GITHUB_ENV
168
- exit 0
169
- else
170
- echo "retesteth_skip=false" >> $GITHUB_ENV
171
- fi
172
-
173
189
174
190
filesState=$(find fixtures/state_tests -type f -name "*.json")
175
191
filesEOF=$(find fixtures/eof_tests -type f -name "*.json")
@@ -178,13 +194,78 @@ jobs:
178
194
exit 1
179
195
fi
180
196
197
+ # Include basic evm operations into coverage by default
198
+ # As when we translate from yul/solidity some dup/push opcodes could become untouched
199
+ uv run fill tests/homestead/coverage/test_coverage.py --until=Cancun --evm-bin evmone-t8n
200
+
181
201
PATCH_TEST_PATH=${{ github.workspace }}/evmtest_coverage/coverage/PATCH_TESTS
182
202
mkdir -p $PATCH_TEST_PATH
183
203
find fixtures/state_tests -type f -name "*.json" -exec cp {} $PATCH_TEST_PATH \;
184
204
find fixtures/eof_tests -type f -name "*.json" -exec cp {} $PATCH_TEST_PATH \;
185
205
206
+ - name : Parse and fill introduced test sources from before the PR
207
+ if : ${{ steps.changed-tests.outputs.tests_any_changed == 'true' && env.converted_skip == 'true' }}
208
+ env :
209
+ CHANGED_TEST_FILES : ${{ steps.changed-tests.outputs.tests_all_modified_files }}
210
+ run : |
211
+ echo "--------------------"
212
+ echo "converted-ethereum-tests.txt seem untouched, try to fill pre-patched version of .py files:"
213
+
214
+ source $GITHUB_ENV
215
+ files=$(echo "$CHANGED_TEST_FILES" | tr ',' '\n')
216
+
217
+ git checkout main
218
+ PREV_COMMIT=$(git rev-parse HEAD)
219
+ echo "Checkout head $PREV_COMMIT"
220
+
221
+ # Take only those files that exist in the filesystem (ignore newly created files)
222
+ files_fixed=$(echo "$files" | tr ' ' '\n' | while read file; do
223
+ if [ -f "$file" ]; then
224
+ echo "$file"
225
+ fi
226
+ done | tr '\n' ' ')
227
+
228
+ echo "Select files that were changed and exist on the main branch:"
229
+ echo $files_fixed
230
+
231
+ rm -r fixtures
232
+ rm filloutput.log
233
+ mkdir -p fixtures/state_tests
234
+ mkdir -p fixtures/eof_tests
235
+
236
+ if [ -n "$files_fixed" ]; then
237
+ echo "uv run fill $files_fixed --until=Cancun --evm-bin evmone-t8n >> filloutput.log 2>&1"
238
+ uv run fill $files_fixed --until=Cancun --evm-bin evmone-t8n >> filloutput.log 2>&1
239
+ cat filloutput.log
240
+
241
+ if grep -q "FAILURES" filloutput.log; then
242
+ echo "Error: failed to generate .py tests from before the PR."
243
+ exit 1
244
+ fi
245
+
246
+ if grep -q "ERROR collecting test session" filloutput.log; then
247
+ echo "Error: failed to generate .py tests from before the PR."
248
+ exit 1
249
+ fi
250
+ else
251
+ echo "No tests affected from before patch!"
252
+ fi
253
+
254
+ filesState=$(find fixtures/state_tests -type f -name "*.json")
255
+ filesEOF=$(find fixtures/eof_tests -type f -name "*.json")
256
+
257
+ BASE_TEST_PATH=${{ github.workspace }}/evmtest_coverage/coverage/BASE_TESTS
258
+ mkdir -p $BASE_TEST_PATH
259
+ find fixtures/state_tests -type f -name "*.json" -exec cp {} $BASE_TEST_PATH \;
260
+ find fixtures/eof_tests -type f -name "*.json" -exec cp {} $BASE_TEST_PATH \;
261
+ for file in $BASE_TEST_PATH/*.json; do
262
+ if [ -e "$file" ]; then
263
+ mv "$file" "${file%.json}_$PREV_COMMIT.json"
264
+ fi
265
+ done
266
+
186
267
- name : Print tests that will be covered
187
- if : ${{ env.retesteth_skip == 'false' || matrix.driver == 'native ' }}
268
+ if : ${{ steps.changed-tests.outputs.tests_any_changed == 'true ' }}
188
269
run : |
189
270
echo "Original BASE tests:"
190
271
ls ${{ github.workspace }}/evmtest_coverage/coverage/BASE_TESTS
@@ -194,44 +275,44 @@ jobs:
194
275
195
276
- name : Run coverage of the BASE tests
196
277
uses : addnab/docker-run-action@v3
197
- if : ${{ env.retesteth_skip == 'false' || matrix.driver == 'native ' }}
278
+ if : ${{ steps.changed-tests.outputs.tests_any_changed == 'true ' }}
198
279
with :
199
280
image : winsvega/evmone-coverage-script:latest
200
281
options : -v ${{ github.workspace }}/evmtest_coverage/coverage:/tests
201
- run : /entrypoint.sh --mode=cover --driver=${{ matrix.driver }} --testpath=/tests/BASE_TESTS --outputname=BASE
282
+ run : /entrypoint.sh --mode=cover --driver=native --testpath=/tests/BASE_TESTS --outputname=BASE
202
283
203
284
- name : Run coverage of the PATCH tests
204
285
uses : addnab/docker-run-action@v3
205
- if : ${{ env.retesteth_skip == 'false' || matrix.driver == 'native ' }}
286
+ if : ${{ steps.changed-tests.outputs.tests_any_changed == 'true ' }}
206
287
with :
207
288
image : winsvega/evmone-coverage-script:latest
208
289
options : -v ${{ github.workspace }}/evmtest_coverage/coverage:/tests
209
- run : /entrypoint.sh --mode=cover --driver=${{ matrix.driver }} --testpath=/tests/PATCH_TESTS --outputname=PATCH
290
+ run : /entrypoint.sh --mode=cover --driver=native --testpath=/tests/PATCH_TESTS --outputname=PATCH
210
291
211
292
- name : Run coverage DIFF of the PATCH tests compared to BASE tests
212
293
uses : addnab/docker-run-action@v3
213
- if : ${{ env.retesteth_skip == 'false' || matrix.driver == 'native ' }}
294
+ if : ${{ steps.changed-tests.outputs.tests_any_changed == 'true ' }}
214
295
with :
215
296
image : winsvega/evmone-coverage-script:latest
216
297
options : -v ${{ github.workspace }}/evmtest_coverage/coverage:/tests
217
298
run : /entrypoint.sh --mode=diff --basefile=coverage_BASE.lcov --patchfile=coverage_PATCH.lcov
218
299
219
300
- name : Chmod coverage results
220
- if : ${{ env.retesteth_skip == 'false' || matrix.driver == 'native ' }}
301
+ if : ${{ steps.changed-tests.outputs.tests_any_changed == 'true ' }}
221
302
run : |
222
303
user=$(whoami)
223
304
sudo chown -R $user:$user ${{ github.workspace }}/evmtest_coverage/coverage
224
305
225
306
- name : Upload coverage results
226
307
uses : actions/upload-artifact@v3
227
- if : ${{ env.retesteth_skip == 'false' || matrix.driver == 'native ' }}
308
+ if : ${{ steps.changed-tests.outputs.tests_any_changed == 'true ' }}
228
309
with :
229
- name : coverage-diff
310
+ name : coverage-diff-native
230
311
path : ${{ github.workspace }}/evmtest_coverage/coverage
231
312
232
313
- name : Verify coverage results
233
314
uses : addnab/docker-run-action@v3
234
- if : ${{ env.retesteth_skip == 'false' || matrix.driver == 'native ' }}
315
+ if : ${{ steps.changed-tests.outputs.tests_any_changed == 'true ' }}
235
316
with :
236
317
image : winsvega/evmone-coverage-script:latest
237
318
options : -v ${{ github.workspace }}/evmtest_coverage/coverage:/tests
0 commit comments