-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Adding Retester to CI #10071
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
Adding Retester to CI #10071
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
bcb9b34
Initial setup of retester in CI
0xOmarA 338b162
Update the path of the tests
0xOmarA 18d8e02
Allow for the generation of markdown reports
0xOmarA 4a7592f
Update path of report processing script
0xOmarA 3625142
Update python prior running the script
0xOmarA 37eabfa
Change the type aliasing syntax for older python
0xOmarA 734b1a8
Update the installed python
0xOmarA 949b657
Remove sudo from the python update command
0xOmarA 0c7a930
Update the python alias syntax
0xOmarA 647deb8
Merge remote-tracking branch 'origin/master' into 0xOmarA/add-reteste…
0xOmarA 7feb52e
Combine the compilation cache steps into one
0xOmarA e65ae97
Combine the report generation steps into one
0xOmarA 087170b
Remove un-needed step in the ci
0xOmarA 1c0fc20
Only generate report for smart contract PRs
0xOmarA 8e7f4e3
Merge branch 'master' into 0xOmarA/add-retester-to-ci
0xOmarA 71b7c00
Compile Polkadot SDK for release not production
0xOmarA 3db6478
Compile Polkadot SDK for release not production
0xOmarA 9621977
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] db1c6bd
Scope permissions to the dt job
0xOmarA 8e422aa
Merge branch 'master' into 0xOmarA/add-retester-to-ci
0xOmarA 75714d9
Merge branch 'master' into 0xOmarA/add-retester-to-ci
0xOmarA 7e82ce7
Merge remote-tracking branch 'origin' into 0xOmarA/add-retester-to-ci
0xOmarA a96a001
Use commit hash for the action
0xOmarA 10e1c5c
Merge branch 'master' into 0xOmarA/add-retester-to-ci
0xOmarA 4d44995
Update for the latest report format
0xOmarA a9c653c
Merge remote-tracking branch 'origin/master' into 0xOmarA/add-reteste…
0xOmarA 74b1abd
Use manual seal for consensus in differential testing
0xOmarA 5d9222b
Remove accidentally comitted report
0xOmarA 72b3b92
Update retester to supply the failure reason
0xOmarA ac4ccde
Merge branch 'master' into 0xOmarA/add-retester-to-ci
0xOmarA 3d6d1fc
Update the version of dt
0xOmarA 2f308d5
Merge remote-tracking branch 'origin/master' into 0xOmarA/add-reteste…
0xOmarA c149a67
Chane the repo used for caches
0xOmarA 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,241 @@ | ||
| """ | ||
| This script is used to turn the JSON report produced by the revive differential tests tool into an | ||
| easy to consume markdown document for the purpose of reporting this information in the Polkadot SDK | ||
| CI. The full models used in the JSON report can be found in the revive differential tests repo and | ||
| the models used in this script are just a partial reproduction of the full report models. | ||
| """ | ||
|
|
||
| import json, typing, io, sys | ||
|
|
||
|
|
||
| class Report(typing.TypedDict): | ||
| context: "Context" | ||
| execution_information: dict["MetadataFilePathString", "MetadataFileReport"] | ||
|
|
||
|
|
||
| class MetadataFileReport(typing.TypedDict): | ||
| case_reports: dict["CaseIdxString", "CaseReport"] | ||
|
|
||
|
|
||
| class CaseReport(typing.TypedDict): | ||
| mode_execution_reports: dict["ModeString", "ExecutionReport"] | ||
|
|
||
|
|
||
| class ExecutionReport(typing.TypedDict): | ||
| status: "TestCaseStatus" | ||
|
|
||
|
|
||
| class Context(typing.TypedDict): | ||
| Test: "TestContext" | ||
|
|
||
|
|
||
| class TestContext(typing.TypedDict): | ||
| corpus_configuration: "CorpusConfiguration" | ||
|
|
||
|
|
||
| class CorpusConfiguration(typing.TypedDict): | ||
| test_specifiers: list["TestSpecifier"] | ||
|
|
||
|
|
||
| class CaseStatusSuccess(typing.TypedDict): | ||
| status: typing.Literal["Succeeded"] | ||
| steps_executed: int | ||
|
|
||
|
|
||
| class CaseStatusFailure(typing.TypedDict): | ||
| status: typing.Literal["Failed"] | ||
| reason: str | ||
|
|
||
|
|
||
| class CaseStatusIgnored(typing.TypedDict): | ||
| status: typing.Literal["Ignored"] | ||
| reason: str | ||
|
|
||
|
|
||
| TestCaseStatus = typing.Union[CaseStatusSuccess, CaseStatusFailure, CaseStatusIgnored] | ||
| """A union type of all of the possible statuses that could be reported for a case.""" | ||
|
|
||
| TestSpecifier = str | ||
| """A test specifier string. For example resolc-compiler-tests/fixtures/solidity/test.json::0::Y+""" | ||
|
|
||
| ModeString = str | ||
| """The mode string. For example Y+ >=0.8.13""" | ||
|
|
||
| MetadataFilePathString = str | ||
| """The path to a metadata file. For example resolc-compiler-tests/fixtures/solidity/test.json""" | ||
|
|
||
| CaseIdxString = str | ||
| """The index of a case as a string. For example '0'""" | ||
|
|
||
|
|
||
| def path_relative_to_resolc_compiler_test_directory(path: str) -> str: | ||
| """ | ||
| Given a path, this function returns the path relative to the resolc-compiler-test directory. The | ||
| following is an example of an input and an output: | ||
|
|
||
| Input: ~/polkadot-sdk/revive-differential-tests/resolc-compiler-tests/fixtures/solidity/test.json | ||
| Output: test.json | ||
| """ | ||
|
|
||
| return f"{path.split('resolc-compiler-tests/fixtures/solidity')[-1].strip('/')}" | ||
|
|
||
|
|
||
| def main() -> None: | ||
| with open(sys.argv[1], "r") as file: | ||
| report: Report = json.load(file) | ||
|
|
||
| # Starting the markdown document and adding information to it as we go. | ||
| markdown_document: io.TextIOWrapper = open("report.md", "w") | ||
| print("# Differential Tests Results", file=markdown_document) | ||
|
|
||
| # Getting all of the test specifiers from the report and making them relative to the tests dir. | ||
| test_specifiers: list[str] = list( | ||
| map( | ||
| path_relative_to_resolc_compiler_test_directory, | ||
| report["context"]["Test"]["corpus_configuration"]["test_specifiers"], | ||
| ) | ||
| ) | ||
| print("## Specified Tests", file=markdown_document) | ||
| for test_specifier in test_specifiers: | ||
| print(f"* `{test_specifier}`", file=markdown_document) | ||
|
|
||
| # Counting the total number of test cases, successes, failures, and ignored tests | ||
| total_number_of_cases: int = 0 | ||
| total_number_of_successes: int = 0 | ||
| total_number_of_failures: int = 0 | ||
| total_number_of_ignores: int = 0 | ||
| for _, mode_to_case_mapping in report["execution_information"].items(): | ||
| for _, case_idx_to_report_mapping in mode_to_case_mapping[ | ||
| "case_reports" | ||
| ].items(): | ||
| for _, execution_report in case_idx_to_report_mapping[ | ||
| "mode_execution_reports" | ||
| ].items(): | ||
| status: TestCaseStatus = execution_report["status"] | ||
|
|
||
| total_number_of_cases += 1 | ||
| if status["status"] == "Succeeded": | ||
| total_number_of_successes += 1 | ||
| elif status["status"] == "Failed": | ||
| total_number_of_failures += 1 | ||
| elif status["status"] == "Ignored": | ||
| total_number_of_ignores += 1 | ||
| else: | ||
| raise Exception( | ||
| f"Encountered a status that's unknown to the script: {status}" | ||
| ) | ||
|
|
||
| print("## Counts", file=markdown_document) | ||
| print( | ||
| f"* **Total Number of Test Cases:** {total_number_of_cases}", | ||
| file=markdown_document, | ||
| ) | ||
| print( | ||
| f"* **Total Number of Successes:** {total_number_of_successes}", | ||
| file=markdown_document, | ||
| ) | ||
| print( | ||
| f"* **Total Number of Failures:** {total_number_of_failures}", | ||
| file=markdown_document, | ||
| ) | ||
| print( | ||
| f"* **Total Number of Ignores:** {total_number_of_ignores}", | ||
| file=markdown_document, | ||
| ) | ||
|
|
||
| # Grouping the various test cases into dictionaries and groups depending on their status to make | ||
| # them easier to include in the markdown document later on. | ||
| successful_cases: dict[ | ||
| MetadataFilePathString, dict[CaseIdxString, set[ModeString]] | ||
| ] = {} | ||
| for metadata_file_path, mode_to_case_mapping in report[ | ||
| "execution_information" | ||
| ].items(): | ||
| for case_idx_string, case_idx_to_report_mapping in mode_to_case_mapping[ | ||
| "case_reports" | ||
| ].items(): | ||
| for mode_string, execution_report in case_idx_to_report_mapping[ | ||
| "mode_execution_reports" | ||
| ].items(): | ||
| status: TestCaseStatus = execution_report["status"] | ||
| metadata_file_path: str = ( | ||
| path_relative_to_resolc_compiler_test_directory(metadata_file_path) | ||
| ) | ||
| mode_string: str = mode_string.replace(" M3", "+").replace(" M0", "-") | ||
|
|
||
| if status["status"] == "Succeeded": | ||
| successful_cases.setdefault( | ||
| metadata_file_path, | ||
| {}, | ||
| ).setdefault( | ||
| case_idx_string, set() | ||
| ).add(mode_string) | ||
|
|
||
| print("## Failures", file=markdown_document) | ||
| print( | ||
| "The test specifiers seen in this section have the format 'path::case_idx::compilation_mode'\ | ||
| and they're compatible with the revive differential tests framework and can be specified\ | ||
| to it directly in the same way that they're provided through the `--test` argument of the\ | ||
| framework.\n", | ||
| file=markdown_document, | ||
| ) | ||
| print( | ||
| "The failures are provided in an expandable section to ensure that the PR does not get \ | ||
| polluted with information. Please click on the section below for more information", | ||
| file=markdown_document, | ||
| ) | ||
| print( | ||
| "<details><summary>Detailed Differential Tests Failure Information</summary>\n\n", | ||
| file=markdown_document, | ||
| ) | ||
| print("| Test Specifier | Failure Reason | Note |", file=markdown_document) | ||
| print("| -- | -- | -- |", file=markdown_document) | ||
|
|
||
| for metadata_file_path, mode_to_case_mapping in report[ | ||
| "execution_information" | ||
| ].items(): | ||
| for case_idx_string, case_idx_to_report_mapping in mode_to_case_mapping[ | ||
| "case_reports" | ||
| ].items(): | ||
| for mode_string, execution_report in case_idx_to_report_mapping[ | ||
| "mode_execution_reports" | ||
| ].items(): | ||
| status: TestCaseStatus = execution_report["status"] | ||
| metadata_file_path: str = ( | ||
| path_relative_to_resolc_compiler_test_directory(metadata_file_path) | ||
| ) | ||
| mode_string: str = mode_string.replace(" M3", "+").replace(" M0", "-") | ||
|
|
||
| if status["status"] != "Failed": | ||
| continue | ||
|
|
||
| failure_reason: str = status["reason"].replace("\n", " ") | ||
|
|
||
| note: str = "" | ||
| modes_where_this_case_succeeded: set[ModeString] = ( | ||
| successful_cases.setdefault( | ||
| metadata_file_path, | ||
| {}, | ||
| ).setdefault(case_idx_string, set()) | ||
| ) | ||
| if len(modes_where_this_case_succeeded) != 0: | ||
| note: str = ( | ||
| f"This test case succeeded with other compilation modes: {modes_where_this_case_succeeded}" | ||
| ) | ||
|
|
||
| test_specifier: str = ( | ||
| f"{metadata_file_path}::{case_idx_string}::{mode_string}" | ||
| ) | ||
| print( | ||
| f"| `{test_specifier}` | `{failure_reason}` | {note} |", | ||
| file=markdown_document, | ||
| ) | ||
| print("\n\n</details>", file=markdown_document) | ||
|
|
||
| # The primary downside of not using `with`, but I guess it's better since I don't want to over | ||
| # indent the code. | ||
| markdown_document.close() | ||
|
|
||
|
|
||
| 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
|
0xOmarA marked this conversation as resolved.
|
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,8 @@ | ||
| title: Adding Retester to CI | ||
| doc: | ||
| - audience: Runtime Dev | ||
| description: |- | ||
| # Description | ||
|
|
||
| This PR adds differential tests as part of the CI of the polkadot SDK. Currently, a job will be started when pushing to master or when a PR is opened that runs the [differential testing framework](https://github.com/paritytech/revive-differential-tests) with the `revive-dev-node-revm-resolc` target. | ||
| crates: [] |
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.