-
Notifications
You must be signed in to change notification settings - Fork 200
feat(cli,fill): make the eip version checker a separate pytest cli tool #1537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
50eac45
chore(fill): remove eip version checking from fill & execute
danceratopz d24e920
fix(fill): reference_spec fixture is required by fill, not by ver che…
danceratopz 4146487
feat(cli,fill): make the eip version checker a separate pytest cli
danceratopz 1c30246
feat(ci): add a workflow to check eip spec versions
danceratopz e5afd3f
docs: update changelog
danceratopz 04377f7
test(fw): add headers to mock in `test_git_reference_spec`
danceratopz 7fda669
fix(pytest): fix args and add typehints
danceratopz 7a38487
fix(execute): update `execute hive`'s pytest ini file
danceratopz 930ef61
chore(pytest): remove superflous 'not eip_version_check' flags
danceratopz 92d6552
chore(ci): temporarily enable workflow on push for testing
danceratopz d8dca1c
chore(pytest): more typehints to fix docs
danceratopz 7a6aff0
fix(pytest): fix spec_version_checker args again
danceratopz 4af177d
fix(ci): fix report used in generated issue
danceratopz 4d2c28f
chore(ci): add link to originating workflow, improve title/labels
danceratopz 22892db
chore(ci): only run flow once for testing
danceratopz cf183a9
chore(cli): align `check_eip_versions` with other pytest clis
danceratopz 885afa6
chore(config): add a config class for `check_eip_versions`
danceratopz 986df6e
chore(cli): add markdown table of outdated eip versions
danceratopz 4fe9b6e
chore(cli): fix up table headers in report
danceratopz a0b6a79
chore(tests): bump eip spec version for eip198_modexp_precompile
danceratopz b793fce
chore(tests): bump eip spec version for tests from deployed forks
danceratopz ed7f7d7
chore(tests): bump eip spec version for prague tests
danceratopz 54d030b
chore(ci): run eip version checker weekly
danceratopz d5b45e3
chore(ci): remove 'on push'; previously added for testing
danceratopz 2a5fc88
docs(cli): add help to specify the token via github cli
danceratopz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| """Generate a markdown report of outdated EIP references from the EIP version checker output.""" | ||
|
|
||
| import os | ||
| import re | ||
| import sys | ||
| import textwrap | ||
| from string import Template | ||
|
|
||
| # Report template using textwrap.dedent for clean multiline strings | ||
| REPORT_TEMPLATE = Template( | ||
| textwrap.dedent("""\ | ||
| # EIP Version Check Report | ||
|
|
||
| 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. | ||
|
|
||
| ## Outdated EIP References | ||
|
|
||
| ### Summary Table | ||
|
|
||
| | File | EIP Link | Referenced Version | Latest Version | | ||
| | ---- | -------- | ------------------ | -------------- | | ||
| $summary_table | ||
|
|
||
| ### Verbatim Failures | ||
|
|
||
| ``` | ||
| $fail_messages | ||
| ``` | ||
|
|
||
| ### Verbatim Errors | ||
|
|
||
| ``` | ||
| $error_messages | ||
| ``` | ||
|
|
||
| ## Action Required | ||
|
|
||
| 1. Please verify whether the affected tests need updating based on changes in the EIP spec. | ||
| 2. Update the `REFERENCE_SPEC_VERSION` in each file with the latest version shown above. | ||
| 3. For detailed instructions, see the [reference specification documentation](https://eest.ethereum.org/main/writing_tests/reference_specification/). | ||
|
|
||
| ## Workflow Information | ||
|
|
||
| For more details, see the [workflow run](https://github.com/ethereum/execution-spec-tests/actions/runs/$run_id). | ||
| """) # noqa: E501 | ||
| ) | ||
|
|
||
|
|
||
| def extract_failures(output): | ||
| """Extract failure information from the output using regex.""" | ||
| failures = [] | ||
|
|
||
| for line in output.split("\n"): | ||
| if not line.startswith("FAILED"): | ||
| continue | ||
|
|
||
| # Extract test file path | ||
| file_match = re.search(r"FAILED (tests/[^:]+\.py)", line) | ||
| if not file_match: | ||
| continue | ||
| file_path = file_match.group(1) | ||
|
|
||
| # Extract EIP number | ||
| eip_match = re.search(r"eip(\d+)", file_path, re.IGNORECASE) | ||
| eip_num = f"EIP-{eip_match.group(1)}" if eip_match else "Unknown" | ||
|
|
||
| # Extract full path | ||
| full_path_match = re.search(r"from '([^']+)'", line) | ||
| full_path = full_path_match.group(1) if full_path_match else "Unknown" | ||
|
|
||
| # Extract EIP link | ||
| eip_link_match = re.search(r"Spec: (https://[^ ]+)\.", line) | ||
| eip_link = eip_link_match.group(1) if eip_link_match else "" | ||
| eip_link = eip_link.replace("blob/", "commits/") if eip_link else "" | ||
|
|
||
| # Extract versions | ||
| ref_version_match = re.search(r"Referenced version: ([a-f0-9]+)", line) | ||
| ref_version = ref_version_match.group(1) if ref_version_match else "Unknown" | ||
|
|
||
| latest_version_match = re.search(r"Latest version: ([a-f0-9]+)", line) | ||
| latest_version = latest_version_match.group(1) if latest_version_match else "Unknown" | ||
|
|
||
| failures.append((file_path, eip_num, full_path, eip_link, ref_version, latest_version)) | ||
|
|
||
| return failures | ||
|
|
||
|
|
||
| def generate_summary_table(failures): | ||
| """Generate a markdown summary table from the failures.""" | ||
| rows = [] | ||
| for file_path, eip_num, _, eip_link, ref_version, latest_version in failures: | ||
| rows.append( | ||
| f"| `{file_path}` | [{eip_num}]({eip_link}) | `{ref_version}` | `{latest_version}` |" | ||
| ) | ||
| return "\n".join(rows) | ||
|
|
||
|
|
||
| def main(): | ||
| """Generate the report.""" | ||
| if len(sys.argv) < 2: | ||
| print("Usage: uv run python generate_eip_report.py <input_file> [output_file]") | ||
| sys.exit(1) | ||
|
|
||
| input_file = sys.argv[1] | ||
| output_file = sys.argv[2] if len(sys.argv) > 2 else "./reports/outdated_eips.md" | ||
|
|
||
| try: | ||
| with open(input_file, "r") as f: | ||
| output = f.read() | ||
| except Exception as e: | ||
| print(f"Error reading input file: {e}") | ||
| sys.exit(1) | ||
|
|
||
| failures = extract_failures(output) | ||
|
|
||
| fail_messages = "\n".join(line for line in output.split("\n") if line.startswith("FAILED")) | ||
| if not fail_messages: | ||
| fail_messages = ( | ||
| "No test failures were found in the pytest output: No lines start with 'FAILED'." | ||
| ) | ||
|
|
||
| error_messages = "\n".join(line for line in output.split("\n") if line.startswith("ERROR")) | ||
| if not error_messages: | ||
| error_messages = ( | ||
| "No test errors were found in the pytest output: No lines start with 'ERROR'." | ||
| ) | ||
|
|
||
| report_content = REPORT_TEMPLATE.substitute( | ||
| summary_table=generate_summary_table(failures), | ||
| fail_messages=fail_messages, | ||
| error_messages=error_messages, | ||
| run_id=os.environ.get("GITHUB_RUN_ID", ""), | ||
| ) | ||
|
|
||
| try: | ||
| with open(output_file, "w") as report: | ||
| report.write(report_content) | ||
| except Exception as e: | ||
| print(f"Error writing output file: {e}") | ||
| sys.exit(1) | ||
|
|
||
| print(f"Report generated successfully: {output_file}") | ||
| print(f"Found {len(failures)} outdated EIP references") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| name: Check EIP Versions | ||
|
|
||
| on: | ||
| repository_dispatch: | ||
| workflow_dispatch: | ||
| schedule: | ||
| - cron: "00 12 * * 1" # Run weekly on Mondays at 12:00 UTC | ||
|
|
||
| jobs: | ||
| check_eip_versions: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| issues: write # required for peter-evans/create-issue-from-file | ||
| contents: read # needed for API access to GitHub | ||
| steps: | ||
| - name: Checkout ethereum/execution-spec-tests | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | ||
|
|
||
| - name: Install uv ${{ vars.UV_VERSION }} and python ${{ matrix.python }} | ||
| uses: astral-sh/setup-uv@0c5e2b8115b80b4c7c5ddf6ffdd634974642d182 | ||
| with: | ||
| enable-cache: true | ||
| cache-dependency-glob: "uv.lock" | ||
| version: ${{ vars.UV_VERSION }} | ||
| python-version: ${{ matrix.python }} | ||
|
|
||
| - name: Run EIP Version Checker | ||
| id: check-eip | ||
| continue-on-error: true | ||
| env: | ||
| # GitHub token provides API access for EIP version checking | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| mkdir -p ./reports | ||
| uv run check_eip_versions 2>&1 | tee ./reports/eip_check_output.txt | ||
| # Save the exit code but don't fail the workflow | ||
| exit_code=${PIPESTATUS[0]} | ||
| echo "exit_code=$exit_code" >> $GITHUB_OUTPUT | ||
| # Always return success to GitHub Actions | ||
| exit 0 | ||
|
|
||
| - name: Generate report file | ||
| if: steps.check-eip.outputs.exit_code != 0 | ||
| run: | | ||
| uv run python .github/scripts/generate_eip_report.py ./reports/eip_check_output.txt ./reports/outdated_eips.md | ||
|
|
||
| - name: Create Issue From File | ||
| if: steps.check-eip.outputs.exit_code != 0 | ||
| uses: peter-evans/create-issue-from-file@e8ef132d6df98ed982188e460ebb3b5d4ef3a9cd | ||
| with: | ||
| title: "chore(tests): eip spec references outdated" | ||
| content-filepath: ./reports/outdated_eips.md | ||
| labels: report, automated issue, scope:tests, type:chore | ||
|
danceratopz marked this conversation as resolved.
|
||
|
|
||
| - name: Upload test report as artifact | ||
| if: always() | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 | ||
| with: | ||
| name: eip-check-report | ||
| path: ./reports/ | ||
| retention-days: 30 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| # EEST CLI Tools | ||
|
|
||
| - [`check_eip_versions`](../../writing_tests/reference_specification.md) - A CLI tool to check the SHA values specified in EIP tests match the latest version from ethereum/EIPs. | ||
| - [`eest`](eest.md) - A CLI tool that helps with routine tasks in ethereum/execution-spec-tests. | ||
| - [`evm_bytes`](evm_bytes.md) - Convert the given EVM bytes from a binary file or a hex string to EEST's python opcodes. |
Binary file modified
BIN
+20.8 KB
(130%)
docs/writing_tests/img/eip_reference_spec_console_output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-12.6 KB
(76%)
docs/writing_tests/img/eip_reference_spec_console_output_fail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| [pytest] | ||
| console_output_style = count | ||
| minversion = 7.0 | ||
| python_files = *.py | ||
| testpaths = tests/ | ||
| markers = | ||
| slow | ||
| pre_alloc_modify | ||
| eip_version_check | ||
| addopts = | ||
| -p pytest_plugins.spec_version_checker.spec_version_checker | ||
| -p pytest_plugins.concurrency | ||
| -p pytest_plugins.filler.pre_alloc | ||
| -p pytest_plugins.solc.solc | ||
| -p pytest_plugins.filler.filler | ||
| -p pytest_plugins.shared.execute_fill | ||
| -p pytest_plugins.forks.forks | ||
| -p pytest_plugins.help.help | ||
| -m eip_version_check | ||
| --tb short |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| """CLI entry point for the EIP version checker pytest-based command.""" | ||
|
|
||
| import sys | ||
| from typing import List | ||
|
|
||
| import click | ||
| import pytest | ||
|
|
||
| from config.check_eip_versions import CheckEipVersionsConfig | ||
|
|
||
| from .common import common_click_options, handle_help_flags | ||
|
|
||
|
|
||
| @click.command(context_settings={"ignore_unknown_options": True}) | ||
| @common_click_options | ||
| def check_eip_versions(pytest_args: List[str], **kwargs) -> None: | ||
| """Run pytest with the `spec_version_checker` plugin.""" | ||
| args = ["-c", "pytest-check-eip-versions.ini"] | ||
| args += ["--until", CheckEipVersionsConfig().UNTIL_FORK] | ||
| args += handle_help_flags(list(pytest_args), pytest_type="check-eip-versions") | ||
| result = pytest.main(args) | ||
| sys.exit(result) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.