Skip to content

Commit 986df6e

Browse files
committed
chore(cli): add markdown table of outdated eip versions
1 parent 885afa6 commit 986df6e

2 files changed

Lines changed: 148 additions & 22 deletions

File tree

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
"""Generate a markdown report of outdated EIP references from the EIP version checker output."""
2+
3+
import os
4+
import re
5+
import sys
6+
import textwrap
7+
from string import Template
8+
9+
# Report template using textwrap.dedent for clean multiline strings
10+
REPORT_TEMPLATE = Template(
11+
textwrap.dedent("""\
12+
# EIP Version Check Report
13+
14+
This automated check has detected that some EIP references in test files are outdated. This means that the EIPs have been updated in the [ethereum/EIPs](https://github.com/ethereum/EIPs) repository since our tests were last updated.
15+
16+
## Outdated EIP References
17+
18+
### Summary Table
19+
20+
| File | EIP | Referenced Version | Latest Version | EIP Link |
21+
| ---- | --- | ----------------- | ------------- | -------- |
22+
$summary_table
23+
24+
### Verbatim Failures
25+
26+
```
27+
$fail_messages
28+
```
29+
30+
### Verbatim Errors
31+
32+
```
33+
$error_messages
34+
```
35+
36+
## Action Required
37+
38+
1. Please verify whether the affected tests need updating based on changes in the EIP spec.
39+
2. Update the `REFERENCE_SPEC_VERSION` in each file with the latest version shown above.
40+
3. For detailed instructions, see the [reference specification documentation](https://eest.ethereum.org/main/writing_tests/reference_specification/).
41+
42+
## Workflow Information
43+
44+
For more details, see the [workflow run](https://github.com/ethereum/execution-spec-tests/actions/runs/$run_id).
45+
""") # noqa: E501
46+
)
47+
48+
49+
def extract_failures(output):
50+
"""Extract failure information from the output using regex."""
51+
failures = []
52+
53+
for line in output.split("\n"):
54+
if not line.startswith("FAILED"):
55+
continue
56+
57+
# Extract test file path
58+
file_match = re.search(r"FAILED (tests/[^:]+\.py)", line)
59+
if not file_match:
60+
continue
61+
file_path = file_match.group(1)
62+
63+
# Extract EIP number
64+
eip_match = re.search(r"eip(\d+)", file_path, re.IGNORECASE)
65+
eip_num = f"EIP-{eip_match.group(1)}" if eip_match else "Unknown"
66+
67+
# Extract full path
68+
full_path_match = re.search(r"from '([^']+)'", line)
69+
full_path = full_path_match.group(1) if full_path_match else "Unknown"
70+
71+
# Extract EIP link
72+
eip_link_match = re.search(r"Spec: (https://[^ ]+)\.", line)
73+
eip_link = eip_link_match.group(1) if eip_link_match else ""
74+
eip_link = eip_link.replace("blob/", "commits/") if eip_link else ""
75+
76+
# Extract versions
77+
ref_version_match = re.search(r"Referenced version: ([a-f0-9]+)", line)
78+
ref_version = ref_version_match.group(1) if ref_version_match else "Unknown"
79+
80+
latest_version_match = re.search(r"Latest version: ([a-f0-9]+)", line)
81+
latest_version = latest_version_match.group(1) if latest_version_match else "Unknown"
82+
83+
failures.append((file_path, eip_num, full_path, eip_link, ref_version, latest_version))
84+
85+
return failures
86+
87+
88+
def generate_summary_table(failures):
89+
"""Generate a markdown summary table from the failures."""
90+
rows = []
91+
for file_path, eip_num, _, eip_link, ref_version, latest_version in failures:
92+
rows.append(
93+
f"| `{file_path}` | `{ref_version}` | `{latest_version}` | [{eip_num}]({eip_link}) |" # noqa: E501
94+
)
95+
return "\n".join(rows)
96+
97+
98+
def main():
99+
"""Generate the report."""
100+
if len(sys.argv) < 2:
101+
print("Usage: uv run python generate_eip_report.py <input_file> [output_file]")
102+
sys.exit(1)
103+
104+
input_file = sys.argv[1]
105+
output_file = sys.argv[2] if len(sys.argv) > 2 else "./reports/outdated_eips.md"
106+
107+
try:
108+
with open(input_file, "r") as f:
109+
output = f.read()
110+
except Exception as e:
111+
print(f"Error reading input file: {e}")
112+
sys.exit(1)
113+
114+
failures = extract_failures(output)
115+
116+
fail_messages = "\n".join(line for line in output.split("\n") if line.startswith("FAILED"))
117+
if not fail_messages:
118+
fail_messages = (
119+
"No test failures were found in the pytest output: No lines start with 'FAILED'."
120+
)
121+
122+
error_messages = "\n".join(line for line in output.split("\n") if line.startswith("ERROR"))
123+
if not error_messages:
124+
error_messages = (
125+
"No test errors were found in the pytest output: No lines start with 'ERROR'."
126+
)
127+
128+
report_content = REPORT_TEMPLATE.substitute(
129+
summary_table=generate_summary_table(failures),
130+
fail_messages=fail_messages,
131+
error_messages=error_messages,
132+
run_id=os.environ.get("GITHUB_RUN_ID", ""),
133+
)
134+
135+
try:
136+
with open(output_file, "w") as report:
137+
report.write(report_content)
138+
except Exception as e:
139+
print(f"Error writing output file: {e}")
140+
sys.exit(1)
141+
142+
print(f"Report generated successfully: {output_file}")
143+
print(f"Found {len(failures)} outdated EIP references")
144+
145+
146+
if __name__ == "__main__":
147+
main()

.github/workflows/check_eip_versions.yaml

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,7 @@ jobs:
4343
- name: Generate report file
4444
if: steps.check-eip.outputs.exit_code != 0
4545
run: |
46-
cat > ./reports/outdated_eips.md << EOL
47-
# EIP Version Check Report
48-
49-
This automated check has detected that some EIP references in test files are outdated. This means that the EIPs have been updated in the [ethereum/EIPs](https://github.com/ethereum/EIPs) repository since our tests were last updated.
50-
51-
## Outdated EIP References
52-
53-
The EIP spec version checker reports the following failures:
54-
55-
\`\`\`
56-
$(grep "FAILED.* does not match that from ethereum/EIPs" ./reports/eip_check_output.txt || echo "No specific outdated EIPs found in the output.")
57-
\`\`\`
58-
59-
## Action Required
60-
61-
1. Please verify whether the affected tests need updating based on the updated EIP spec.
62-
2. Update the EIP reference versions in the affected test files, for details see [the online documentation](https://eest.ethereum.org/main/writing_tests/reference_specification/).
63-
64-
## Workflow Information
65-
66-
For more details, see the [workflow run](https://github.com/ethereum/execution-spec-tests/actions/runs/${{ github.run_id }}).
67-
EOL
46+
uv run python .github/scripts/generate_eip_report.py ./reports/eip_check_output.txt ./reports/outdated_eips.md
6847
6948
- name: Create Issue From File
7049
if: steps.check-eip.outputs.exit_code != 0

0 commit comments

Comments
 (0)