From 22204f05ac22919f0e4efd86f9982fca02993706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= <43241881+kamilchodola@users.noreply.github.com> Date: Mon, 12 Aug 2024 16:56:18 +0200 Subject: [PATCH 01/18] Create retriveAllTests.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kamil Chodoła <43241881+kamilchodola@users.noreply.github.com> --- scripts/retriveAllTests.py | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 scripts/retriveAllTests.py diff --git a/scripts/retriveAllTests.py b/scripts/retriveAllTests.py new file mode 100644 index 0000000..9f6c347 --- /dev/null +++ b/scripts/retriveAllTests.py @@ -0,0 +1,53 @@ +import os +from pathlib import Path +import argparse +import math + +repo_dir = Path(__file__).resolve().parents[1] +tests_dir = repo_dir / "assertoor-tests" + +def get_yaml_files(tests_dir, include=None, exclude=None): + yaml_files = [] + for root, _, files in os.walk(tests_dir): + for file in files: + if file.endswith(".yaml"): + if file == "all.yaml": + continue + if include and not any(inc in file for inc in include): + continue + if exclude and any(exc in file for exc in exclude): + continue + full_path = Path(root) / file + raw_url = f"https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/{full_path.relative_to(repo_dir)}" + yaml_files.append(raw_url) + return yaml_files + +def construct_yaml_structure(yaml_files): + yaml_structure = "tests:\n" + for url in yaml_files: + yaml_structure += f" - {url}\n" + return yaml_structure + +def slice_tests(yaml_files, groups): + sliced_groups = [] + group_size = math.ceil(len(yaml_files) / groups) + for i in range(0, len(yaml_files), group_size): + sliced_groups.append(yaml_files[i:i + group_size]) + return sliced_groups + +def main(): + parser = argparse.ArgumentParser(description="Generate test YAML structure with optional filtering and slicing.") + parser.add_argument("--include", type=str, nargs='*', help="List of texts to include in file names (only include matching files).") + parser.add_argument("--exclude", type=str, nargs='*', help="List of texts to exclude from file names (exclude matching files).") + parser.add_argument("--groups", type=int, help="Number of groups to slice the tests into.", default=1) + + args = parser.parse_args() + + yaml_files = get_yaml_files(tests_dir, include=args.include, exclude=args.exclude) + sliced_yaml_files = slice_tests(yaml_files, args.groups) + + for idx, group in enumerate(sliced_yaml_files, start=1): + print(f"Group {idx}:\n{construct_yaml_structure(group)}\n") + +if __name__ == "__main__": + main() From 0567f1434b36dd002f0fbadbf28745c02566fe3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= <43241881+kamilchodola@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:16:06 +0200 Subject: [PATCH 02/18] Create Readme.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kamil Chodoła <43241881+kamilchodola@users.noreply.github.com> --- scripts/Readme.md | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 scripts/Readme.md diff --git a/scripts/Readme.md b/scripts/Readme.md new file mode 100644 index 0000000..6fd0f7c --- /dev/null +++ b/scripts/Readme.md @@ -0,0 +1,68 @@ +# Generate Tests YAML Script + +This Python script is designed to generate a YAML structure for running tests in a CI/CD pipeline. It reads .yaml files from a specified directory (assertoor-tests), applies optional filtering, and can slice the tests into groups for parallel execution. + +## Features + +- Recursive Directory Traversal: Automatically searches for .yaml test files within the assertoor-tests directory and its subdirectories. +- Inclusion and Exclusion Filters: Allows you to specify patterns to include or exclude specific test files. +- Grouping: Splits the tests into specified groups for parallel processing. + +## Usage +To use the script, navigate to the root directory of your project and run the script using Python: + +### Basic Usage + +`python Scripts/generate_tests_yaml.py` + +This will generate a YAML structure with all .yaml files found in the assertoor-tests directory and its subdirectories, excluding all.yaml. + +### Filtering Tests +#### Include Specific Tests + +To include only certain tests based on their filenames, use the --include option: + +`python Scripts/generate_tests_yaml.py --include "validator" "proposal"` + +This will include all files with validator or proposal in their filenames. + +#### Exclude Specific Tests + +To exclude certain tests based on their filenames, use the --exclude option: + +`python Scripts/generate_tests_yaml.py --exclude "verkle" "blob"` + +This will exclude all files with verkle or blob in their filenames. + +### Slicing Tests for Parallel Execution + +To divide the list of tests into groups for parallel execution, use the --groups option: + +`python Scripts/generate_tests_yaml.py --groups 3` + +This will split the tests into 3 groups. + +### Raw Output Usage +To output the raw URLs without YAML formatting, use the --raw option: + +`python Scripts/generate_tests_yaml.py --raw` + +This will output the URLs as plain text, one per line: + +``` +https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/assertoor-tests/pectra-dev/test1.yaml +https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/assertoor-tests/verkle-dev/testA.yaml +... +``` + +## Example Output +The script will output the YAML structure in the format required for your CI/CD configuration: + +``` +tests: + - https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/assertoor-tests/pectra-dev/test1.yaml + - https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/assertoor-tests/verkle-dev/testA.yaml + ... +``` + +If you use the --groups option, it will output separate YAML structures for each group. From 969d6e0ac93522ec05e4b6a23ac7b0d5978fc2af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= <43241881+kamilchodola@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:16:43 +0200 Subject: [PATCH 03/18] Add --raw flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kamil Chodoła <43241881+kamilchodola@users.noreply.github.com> --- scripts/retriveAllTests.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/retriveAllTests.py b/scripts/retriveAllTests.py index 9f6c347..9537184 100644 --- a/scripts/retriveAllTests.py +++ b/scripts/retriveAllTests.py @@ -36,18 +36,22 @@ def slice_tests(yaml_files, groups): return sliced_groups def main(): - parser = argparse.ArgumentParser(description="Generate test YAML structure with optional filtering and slicing.") + parser = argparse.ArgumentParser(description="Generate test URLs with optional filtering, slicing, and formatting.") parser.add_argument("--include", type=str, nargs='*', help="List of texts to include in file names (only include matching files).") parser.add_argument("--exclude", type=str, nargs='*', help="List of texts to exclude from file names (exclude matching files).") parser.add_argument("--groups", type=int, help="Number of groups to slice the tests into.", default=1) + parser.add_argument("--raw", action="store_true", help="Output raw URLs without YAML formatting.") args = parser.parse_args() yaml_files = get_yaml_files(tests_dir, include=args.include, exclude=args.exclude) sliced_yaml_files = slice_tests(yaml_files, args.groups) - + for idx, group in enumerate(sliced_yaml_files, start=1): - print(f"Group {idx}:\n{construct_yaml_structure(group)}\n") + if args.raw: + print(f"Group {idx}:\n" + "\n".join(group) + "\n") + else: + print(f"Group {idx}:\n{construct_yaml_structure(group)}\n") if __name__ == "__main__": main() From 5c1b4b0eefbf44b6c60ce96b33c07f26c5e179e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= <43241881+kamilchodola@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:19:11 +0200 Subject: [PATCH 04/18] Remove prefix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kamil Chodoła <43241881+kamilchodola@users.noreply.github.com> --- scripts/retriveAllTests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/retriveAllTests.py b/scripts/retriveAllTests.py index 9537184..cc2b2c6 100644 --- a/scripts/retriveAllTests.py +++ b/scripts/retriveAllTests.py @@ -49,9 +49,9 @@ def main(): for idx, group in enumerate(sliced_yaml_files, start=1): if args.raw: - print(f"Group {idx}:\n" + "\n".join(group) + "\n") + print(f"\n".join(group) + "\n") else: - print(f"Group {idx}:\n{construct_yaml_structure(group)}\n") + print(f"{construct_yaml_structure(group)}\n") if __name__ == "__main__": main() From 56e3e7f49014179f2660307354171cc307623372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= <43241881+kamilchodola@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:19:53 +0200 Subject: [PATCH 05/18] Remove not needed nnew line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kamil Chodoła <43241881+kamilchodola@users.noreply.github.com> --- scripts/retriveAllTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/retriveAllTests.py b/scripts/retriveAllTests.py index cc2b2c6..ce93239 100644 --- a/scripts/retriveAllTests.py +++ b/scripts/retriveAllTests.py @@ -51,7 +51,7 @@ def main(): if args.raw: print(f"\n".join(group) + "\n") else: - print(f"{construct_yaml_structure(group)}\n") + print(f"{construct_yaml_structure(group)}") if __name__ == "__main__": main() From 4f046d3b8075527085fd5730f4ca427b0f0a3957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= <43241881+kamilchodola@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:21:24 +0200 Subject: [PATCH 06/18] Add json formatting output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kamil Chodoła <43241881+kamilchodola@users.noreply.github.com> --- scripts/retriveAllTests.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/retriveAllTests.py b/scripts/retriveAllTests.py index ce93239..b6d5d8f 100644 --- a/scripts/retriveAllTests.py +++ b/scripts/retriveAllTests.py @@ -41,6 +41,7 @@ def main(): parser.add_argument("--exclude", type=str, nargs='*', help="List of texts to exclude from file names (exclude matching files).") parser.add_argument("--groups", type=int, help="Number of groups to slice the tests into.", default=1) parser.add_argument("--raw", action="store_true", help="Output raw URLs without YAML formatting.") + parser.add_argument("--json", action="store_true", help="Output URLs in JSON format.") args = parser.parse_args() @@ -48,10 +49,12 @@ def main(): sliced_yaml_files = slice_tests(yaml_files, args.groups) for idx, group in enumerate(sliced_yaml_files, start=1): - if args.raw: - print(f"\n".join(group) + "\n") + if args.json: + print(json.dumps({f"Group {idx}": group}, indent=2)) + elif args.raw: + print("\n".join(group) + "\n") else: - print(f"{construct_yaml_structure(group)}") + print(construct_yaml_structure(group)) if __name__ == "__main__": main() From 14627c593c52c6c246f22b53b507a3e2beeccf72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= <43241881+kamilchodola@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:22:44 +0200 Subject: [PATCH 07/18] Add missing import MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kamil Chodoła <43241881+kamilchodola@users.noreply.github.com> --- scripts/retriveAllTests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/retriveAllTests.py b/scripts/retriveAllTests.py index b6d5d8f..6a8948c 100644 --- a/scripts/retriveAllTests.py +++ b/scripts/retriveAllTests.py @@ -2,6 +2,7 @@ from pathlib import Path import argparse import math +import json repo_dir = Path(__file__).resolve().parents[1] tests_dir = repo_dir / "assertoor-tests" From 799b748a563966ef426ff37d5202442ad73682d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= <43241881+kamilchodola@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:26:43 +0200 Subject: [PATCH 08/18] Improve json format output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kamil Chodoła <43241881+kamilchodola@users.noreply.github.com> --- scripts/retriveAllTests.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/retriveAllTests.py b/scripts/retriveAllTests.py index 6a8948c..6d2cd55 100644 --- a/scripts/retriveAllTests.py +++ b/scripts/retriveAllTests.py @@ -49,13 +49,15 @@ def main(): yaml_files = get_yaml_files(tests_dir, include=args.include, exclude=args.exclude) sliced_yaml_files = slice_tests(yaml_files, args.groups) - for idx, group in enumerate(sliced_yaml_files, start=1): - if args.json: - print(json.dumps({f"Group {idx}": group}, indent=2)) - elif args.raw: - print("\n".join(group) + "\n") - else: - print(construct_yaml_structure(group)) + if args.json: + json_output = {str(idx + 1): group for idx, group in enumerate(sliced_yaml_files)} + print(json.dumps(json_output, indent=2)) + else: + for idx, group in enumerate(sliced_yaml_files, start=1): + if args.raw: + print("\n".join(group) + "\n") + else: + print(construct_yaml_structure(group)) if __name__ == "__main__": main() From 0db866af688258be350e14c1fd1e3ebd9e77f2c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= <43241881+kamilchodola@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:28:17 +0200 Subject: [PATCH 09/18] Update Readme.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kamil Chodoła <43241881+kamilchodola@users.noreply.github.com> --- scripts/Readme.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scripts/Readme.md b/scripts/Readme.md index 6fd0f7c..8058c8c 100644 --- a/scripts/Readme.md +++ b/scripts/Readme.md @@ -43,6 +43,7 @@ To divide the list of tests into groups for parallel execution, use the --groups This will split the tests into 3 groups. ### Raw Output Usage + To output the raw URLs without YAML formatting, use the --raw option: `python Scripts/generate_tests_yaml.py --raw` @@ -55,6 +56,24 @@ https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/assertoor-te ... ``` +### Json Output Usage + +To output the test URLs in JSON format, use the --json option: + +`python Scripts/generate_tests_yaml.py --json` + +This will output the URLs in a JSON format, like so: + +``` +{ + "1": [ + "https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/assertoor-tests/pectra-dev/test1.yaml", + "https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/assertoor-tests/verkle-dev/testA.yaml", + ... + ] +} +``` + ## Example Output The script will output the YAML structure in the format required for your CI/CD configuration: From 6b95a6a42448d40e8471f914c8978e6d0c2f664b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= <43241881+kamilchodola@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:33:00 +0200 Subject: [PATCH 10/18] Fix include/exclude flags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kamil Chodoła <43241881+kamilchodola@users.noreply.github.com> --- scripts/retriveAllTests.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/retriveAllTests.py b/scripts/retriveAllTests.py index 6d2cd55..9d3f4bb 100644 --- a/scripts/retriveAllTests.py +++ b/scripts/retriveAllTests.py @@ -14,10 +14,13 @@ def get_yaml_files(tests_dir, include=None, exclude=None): if file.endswith(".yaml"): if file == "all.yaml": continue - if include and not any(inc in file for inc in include): + + if include and not any(inc in str(full_path) for inc in include): continue - if exclude and any(exc in file for exc in exclude): + + if exclude and any(exc in str(full_path) for exc in exclude): continue + full_path = Path(root) / file raw_url = f"https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/{full_path.relative_to(repo_dir)}" yaml_files.append(raw_url) From cb29b28469c6ed0e5eb77fdd80cd42507426b49d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= <43241881+kamilchodola@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:37:14 +0200 Subject: [PATCH 11/18] One more fix for getYaml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kamil Chodoła <43241881+kamilchodola@users.noreply.github.com> --- scripts/retriveAllTests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/retriveAllTests.py b/scripts/retriveAllTests.py index 9d3f4bb..ceb8716 100644 --- a/scripts/retriveAllTests.py +++ b/scripts/retriveAllTests.py @@ -12,6 +12,8 @@ def get_yaml_files(tests_dir, include=None, exclude=None): for root, _, files in os.walk(tests_dir): for file in files: if file.endswith(".yaml"): + full_path = Path(root) / file + if file == "all.yaml": continue @@ -20,11 +22,9 @@ def get_yaml_files(tests_dir, include=None, exclude=None): if exclude and any(exc in str(full_path) for exc in exclude): continue - - full_path = Path(root) / file + raw_url = f"https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/{full_path.relative_to(repo_dir)}" - yaml_files.append(raw_url) - return yaml_files + yaml_fil def construct_yaml_structure(yaml_files): yaml_structure = "tests:\n" From f160ffb20e9b05cb7df49ff3fff26d23591aec0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= <43241881+kamilchodola@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:37:39 +0200 Subject: [PATCH 12/18] Fix typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kamil Chodoła <43241881+kamilchodola@users.noreply.github.com> --- scripts/retriveAllTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/retriveAllTests.py b/scripts/retriveAllTests.py index ceb8716..63dc065 100644 --- a/scripts/retriveAllTests.py +++ b/scripts/retriveAllTests.py @@ -24,7 +24,7 @@ def get_yaml_files(tests_dir, include=None, exclude=None): continue raw_url = f"https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/{full_path.relative_to(repo_dir)}" - yaml_fil + yaml_file def construct_yaml_structure(yaml_files): yaml_structure = "tests:\n" From 3fec6d77e7784f7b06aa347f65e6b948bbe4991b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= <43241881+kamilchodola@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:38:02 +0200 Subject: [PATCH 13/18] One more... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kamil Chodoła <43241881+kamilchodola@users.noreply.github.com> --- scripts/retriveAllTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/retriveAllTests.py b/scripts/retriveAllTests.py index 63dc065..ab6247d 100644 --- a/scripts/retriveAllTests.py +++ b/scripts/retriveAllTests.py @@ -24,7 +24,7 @@ def get_yaml_files(tests_dir, include=None, exclude=None): continue raw_url = f"https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/{full_path.relative_to(repo_dir)}" - yaml_file + yaml_files def construct_yaml_structure(yaml_files): yaml_structure = "tests:\n" From 761fff68cf8303ec4cebfd41ee7f257f510a8e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= <43241881+kamilchodola@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:50:30 +0200 Subject: [PATCH 14/18] Proper return (missed) --- scripts/retriveAllTests.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/retriveAllTests.py b/scripts/retriveAllTests.py index ab6247d..608388a 100644 --- a/scripts/retriveAllTests.py +++ b/scripts/retriveAllTests.py @@ -24,7 +24,9 @@ def get_yaml_files(tests_dir, include=None, exclude=None): continue raw_url = f"https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/{full_path.relative_to(repo_dir)}" - yaml_files + yaml_files.append(raw_url) + + return yaml_files def construct_yaml_structure(yaml_files): yaml_structure = "tests:\n" From d6fa718fc7dcd21db3d2b7cb6ba8eb4bd8680888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= Date: Mon, 12 Aug 2024 17:52:44 +0200 Subject: [PATCH 15/18] move to subdir --- scripts/{ => retriveAllTests}/Readme.md | 0 scripts/{ => retriveAllTests}/retriveAllTests.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename scripts/{ => retriveAllTests}/Readme.md (100%) rename scripts/{ => retriveAllTests}/retriveAllTests.py (100%) diff --git a/scripts/Readme.md b/scripts/retriveAllTests/Readme.md similarity index 100% rename from scripts/Readme.md rename to scripts/retriveAllTests/Readme.md diff --git a/scripts/retriveAllTests.py b/scripts/retriveAllTests/retriveAllTests.py similarity index 100% rename from scripts/retriveAllTests.py rename to scripts/retriveAllTests/retriveAllTests.py From 33fda13297c5af5ad8931687beef927e8122d11c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= Date: Mon, 12 Aug 2024 18:04:18 +0200 Subject: [PATCH 16/18] Add branch selector --- scripts/retriveAllTests/Readme.md | 22 ++++++++++++++++------ scripts/retriveAllTests/retriveAllTests.py | 10 ++++++---- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/scripts/retriveAllTests/Readme.md b/scripts/retriveAllTests/Readme.md index 8058c8c..fc9aa8f 100644 --- a/scripts/retriveAllTests/Readme.md +++ b/scripts/retriveAllTests/Readme.md @@ -13,16 +13,26 @@ To use the script, navigate to the root directory of your project and run the sc ### Basic Usage -`python Scripts/generate_tests_yaml.py` +`python retriveAllTests.py` This will generate a YAML structure with all .yaml files found in the assertoor-tests directory and its subdirectories, excluding all.yaml. +### Branch Selection +To specify a branch other than the default (master), use the --branch option: + +`python SretriveAllTests.py --branch "pectra"` + +This command will use the pectra branch instead of master to retrieve the test files. + +*WARNING* +This is only a branch replacement feature in path - make sure to checkout repository on proper branch before applying this parameter. + ### Filtering Tests #### Include Specific Tests To include only certain tests based on their filenames, use the --include option: -`python Scripts/generate_tests_yaml.py --include "validator" "proposal"` +`python retriveAllTests.py --include "validator" "proposal"` This will include all files with validator or proposal in their filenames. @@ -30,7 +40,7 @@ This will include all files with validator or proposal in their filenames. To exclude certain tests based on their filenames, use the --exclude option: -`python Scripts/generate_tests_yaml.py --exclude "verkle" "blob"` +`python retriveAllTests.py --exclude "verkle" "blob"` This will exclude all files with verkle or blob in their filenames. @@ -38,7 +48,7 @@ This will exclude all files with verkle or blob in their filenames. To divide the list of tests into groups for parallel execution, use the --groups option: -`python Scripts/generate_tests_yaml.py --groups 3` +`python retriveAllTests.py --groups 3` This will split the tests into 3 groups. @@ -46,7 +56,7 @@ This will split the tests into 3 groups. To output the raw URLs without YAML formatting, use the --raw option: -`python Scripts/generate_tests_yaml.py --raw` +`python retriveAllTests.py --raw` This will output the URLs as plain text, one per line: @@ -60,7 +70,7 @@ https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/assertoor-te To output the test URLs in JSON format, use the --json option: -`python Scripts/generate_tests_yaml.py --json` +`python retriveAllTests.py --json` This will output the URLs in a JSON format, like so: diff --git a/scripts/retriveAllTests/retriveAllTests.py b/scripts/retriveAllTests/retriveAllTests.py index 608388a..ff8c2bf 100644 --- a/scripts/retriveAllTests/retriveAllTests.py +++ b/scripts/retriveAllTests/retriveAllTests.py @@ -4,10 +4,11 @@ import math import json -repo_dir = Path(__file__).resolve().parents[1] +script_dir = Path(__file__).resolve().parent +repo_dir = script_dir.parents[1] tests_dir = repo_dir / "assertoor-tests" -def get_yaml_files(tests_dir, include=None, exclude=None): +def get_yaml_files(tests_dir, branch="master", include=None, exclude=None): yaml_files = [] for root, _, files in os.walk(tests_dir): for file in files: @@ -23,7 +24,7 @@ def get_yaml_files(tests_dir, include=None, exclude=None): if exclude and any(exc in str(full_path) for exc in exclude): continue - raw_url = f"https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/{full_path.relative_to(repo_dir)}" + raw_url = f"https://raw.githubusercontent.com/ethpandaops/assertoor-test/{branch}/{full_path.relative_to(repo_dir)}" yaml_files.append(raw_url) return yaml_files @@ -43,6 +44,7 @@ def slice_tests(yaml_files, groups): def main(): parser = argparse.ArgumentParser(description="Generate test URLs with optional filtering, slicing, and formatting.") + parser.add_argument("--branch", type=str, default="master", help="The branch name to use for constructing the raw URLs.") parser.add_argument("--include", type=str, nargs='*', help="List of texts to include in file names (only include matching files).") parser.add_argument("--exclude", type=str, nargs='*', help="List of texts to exclude from file names (exclude matching files).") parser.add_argument("--groups", type=int, help="Number of groups to slice the tests into.", default=1) @@ -51,7 +53,7 @@ def main(): args = parser.parse_args() - yaml_files = get_yaml_files(tests_dir, include=args.include, exclude=args.exclude) + yaml_files = get_yaml_files(tests_dir, branch=args.branch, include=args.include, exclude=args.exclude) sliced_yaml_files = slice_tests(yaml_files, args.groups) if args.json: From 40b948d428ed124104753008d000bc54323a4aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= <43241881+kamilchodola@users.noreply.github.com> Date: Mon, 12 Aug 2024 18:05:29 +0200 Subject: [PATCH 17/18] Update Readme.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kamil Chodoła <43241881+kamilchodola@users.noreply.github.com> --- scripts/retriveAllTests/Readme.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/retriveAllTests/Readme.md b/scripts/retriveAllTests/Readme.md index fc9aa8f..a437319 100644 --- a/scripts/retriveAllTests/Readme.md +++ b/scripts/retriveAllTests/Readme.md @@ -20,12 +20,13 @@ This will generate a YAML structure with all .yaml files found in the assertoor- ### Branch Selection To specify a branch other than the default (master), use the --branch option: -`python SretriveAllTests.py --branch "pectra"` +`python retriveAllTests.py --branch "pectra"` This command will use the pectra branch instead of master to retrieve the test files. -*WARNING* -This is only a branch replacement feature in path - make sure to checkout repository on proper branch before applying this parameter. +>**IMPORTANT** +> +>This is only a branch replacement feature in path - make sure to checkout repository on proper branch before applying this parameter. ### Filtering Tests #### Include Specific Tests From 11cbd4e24dd375c77d711dc256bf4fcc8d84b68c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= Date: Tue, 13 Aug 2024 10:48:12 +0200 Subject: [PATCH 18/18] Improve YAML output --- scripts/retriveAllTests/Readme.md | 11 +++++++---- scripts/retriveAllTests/retriveAllTests.py | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/retriveAllTests/Readme.md b/scripts/retriveAllTests/Readme.md index a437319..268ce2e 100644 --- a/scripts/retriveAllTests/Readme.md +++ b/scripts/retriveAllTests/Readme.md @@ -86,12 +86,15 @@ This will output the URLs in a JSON format, like so: ``` ## Example Output -The script will output the YAML structure in the format required for your CI/CD configuration: +The script will output the assertoor_params section needed for Kurtosis network_params YAML structure in the format required for your CI/CD configuration: ``` -tests: - - https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/assertoor-tests/pectra-dev/test1.yaml - - https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/assertoor-tests/verkle-dev/testA.yaml +assertoor_params: + tests: + - { file: "https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/assertoor-tests/all-opcodes-test.yaml" } + - { file: "https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/assertoor-tests/big-calldata-tx-test.yaml" } + - { file: "https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/assertoor-tests/blob-transactions-test.yaml" } + - { file: "https://raw.githubusercontent.com/ethpandaops/assertoor-test/master/assertoor-tests/block-proposal-check.yaml" } ... ``` diff --git a/scripts/retriveAllTests/retriveAllTests.py b/scripts/retriveAllTests/retriveAllTests.py index ff8c2bf..5e94f52 100644 --- a/scripts/retriveAllTests/retriveAllTests.py +++ b/scripts/retriveAllTests/retriveAllTests.py @@ -30,9 +30,10 @@ def get_yaml_files(tests_dir, branch="master", include=None, exclude=None): return yaml_files def construct_yaml_structure(yaml_files): - yaml_structure = "tests:\n" + yaml_structure = "assertoor_params:\n" + yaml_structure += " tests:\n" for url in yaml_files: - yaml_structure += f" - {url}\n" + yaml_structure += f" - {{ file: \"{url}\" }}\n" return yaml_structure def slice_tests(yaml_files, groups):