From 84b3bea77aea5939895b6789bb37d3485b04b390 Mon Sep 17 00:00:00 2001 From: Andreas Zwinkau Date: Fri, 29 May 2026 15:06:57 +0200 Subject: [PATCH 1/3] chore: split up tests for better caching --- src/extensions/score_metamodel/BUILD | 46 +++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/src/extensions/score_metamodel/BUILD b/src/extensions/score_metamodel/BUILD index 3ddd80e15..2c0a3426e 100644 --- a/src/extensions/score_metamodel/BUILD +++ b/src/extensions/score_metamodel/BUILD @@ -74,16 +74,46 @@ score_pytest( ) score_pytest( - name = "file_based_tests", + name = "file_based_tests_architecture", size = "medium", srcs = ["tests/test_rules_file_based.py"], - # All requirements already in the library so no need to have it double - data = glob( - [ - "tests/**/*.rst", - "tests/**/*.yaml", - ], - ) + ["tests/rst/conf.py"], + data = glob(["tests/rst/architecture/*.rst"]) + ["tests/rst/conf.py"], + pytest_config = "//:pyproject.toml", + deps = [":score_metamodel"], +) + +score_pytest( + name = "file_based_tests_attributes", + size = "medium", + srcs = ["tests/test_rules_file_based.py"], + data = glob(["tests/rst/attributes/*.rst"]) + ["tests/rst/conf.py"], + pytest_config = "//:pyproject.toml", + deps = [":score_metamodel"], +) + +score_pytest( + name = "file_based_tests_graph", + size = "medium", + srcs = ["tests/test_rules_file_based.py"], + data = glob(["tests/rst/graph/*.rst"]) + ["tests/rst/conf.py"], + pytest_config = "//:pyproject.toml", + deps = [":score_metamodel"], +) + +score_pytest( + name = "file_based_tests_id_contains_feature", + size = "medium", + srcs = ["tests/test_rules_file_based.py"], + data = glob(["tests/rst/id_contains_feature/*.rst"]) + ["tests/rst/conf.py"], + pytest_config = "//:pyproject.toml", + deps = [":score_metamodel"], +) + +score_pytest( + name = "file_based_tests_options", + size = "medium", + srcs = ["tests/test_rules_file_based.py"], + data = glob(["tests/rst/options/*.rst"]) + ["tests/rst/conf.py"], pytest_config = "//:pyproject.toml", deps = [":score_metamodel"], ) From 312283f8de1789ab0a47dc2da9dfdc3614fa7056 Mon Sep 17 00:00:00 2001 From: Andreas Zwinkau Date: Fri, 29 May 2026 15:48:29 +0200 Subject: [PATCH 2/3] perf: Avoid downloading needs.json This costs ~700ms x 15+ tests. Also, network access is not a good thing for tests. --- src/extensions/score_metamodel/BUILD | 2 +- .../tests/rst/attributes/needs.json | 29 +++++++++++++++++++ .../score_metamodel/tests/rst/conf.py | 6 ---- .../tests/test_rules_file_based.py | 14 +++++++++ 4 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 src/extensions/score_metamodel/tests/rst/attributes/needs.json diff --git a/src/extensions/score_metamodel/BUILD b/src/extensions/score_metamodel/BUILD index 2c0a3426e..0e30e9bad 100644 --- a/src/extensions/score_metamodel/BUILD +++ b/src/extensions/score_metamodel/BUILD @@ -86,7 +86,7 @@ score_pytest( name = "file_based_tests_attributes", size = "medium", srcs = ["tests/test_rules_file_based.py"], - data = glob(["tests/rst/attributes/*.rst"]) + ["tests/rst/conf.py"], + data = glob(["tests/rst/attributes/*.rst"]) + ["tests/rst/conf.py", "tests/rst/attributes/needs.json"], pytest_config = "//:pyproject.toml", deps = [":score_metamodel"], ) diff --git a/src/extensions/score_metamodel/tests/rst/attributes/needs.json b/src/extensions/score_metamodel/tests/rst/attributes/needs.json new file mode 100644 index 000000000..b3f9a83ec --- /dev/null +++ b/src/extensions/score_metamodel/tests/rst/attributes/needs.json @@ -0,0 +1,29 @@ +{ + "current_version": "1.0", + "project": "test", + "project_url": "https://eclipse-score.github.io/process_description/main/", + "versions": { + "1.0": { + "needs": { + "doc_getstrt__req__process": { + "docname": "getting_started", + "id": "doc_getstrt__req__process", + "lineno": 1, + "status": "valid", + "title": "Process requirement (stub for tests)", + "type": "doc_req", + "type_name": "doc_req" + }, + "gd_guidl__req__engineering": { + "docname": "guidelines", + "id": "gd_guidl__req__engineering", + "lineno": 1, + "status": "valid", + "title": "Engineering guideline requirement (stub for tests)", + "type": "gd_req", + "type_name": "gd_req" + } + } + } + } +} diff --git a/src/extensions/score_metamodel/tests/rst/conf.py b/src/extensions/score_metamodel/tests/rst/conf.py index 180333964..d69dd9562 100644 --- a/src/extensions/score_metamodel/tests/rst/conf.py +++ b/src/extensions/score_metamodel/tests/rst/conf.py @@ -21,12 +21,6 @@ "score_metamodel", ] -needs_external_needs = [ - { - "base_url": "https://eclipse-score.github.io/process_description/main/", - "json_url": "https://eclipse-score.github.io/process_description/main/needs.json", - } -] # We add these suppress_warnings here to ease the load of the warnings # In the future we might want to check if ANY warnings comes in the document # And then ensure that we error, as this could also be parsing errors etc. diff --git a/src/extensions/score_metamodel/tests/test_rules_file_based.py b/src/extensions/score_metamodel/tests/test_rules_file_based.py index b80527446..d618b14e0 100644 --- a/src/extensions/score_metamodel/tests/test_rules_file_based.py +++ b/src/extensions/score_metamodel/tests/test_rules_file_based.py @@ -287,6 +287,20 @@ def test_rst_files( # Build the documentation with the enabled checks app.config.score_metamodel_checks = rst_data.enabled_checks + + # Replace any network json_url with a local json_path to avoid network I/O in tests + local_needs = RST_DIR / Path(rst_file).parent / "needs.json" + if local_needs.exists(): + shutil.copy(local_needs, app.srcdir) + app.config.needs_external_needs = [ + {k: v for k, v in ext.items() if k != "json_url"} | {"json_path": "needs.json"} + if "json_url" in ext + else ext + for ext in (app.config.needs_external_needs or []) + ] + else: + app.config.needs_external_needs = [] + app.build() # Collect the warnings From a862bea94a2caa7064ac31ebb2a213c21152eee6 Mon Sep 17 00:00:00 2001 From: Andreas Zwinkau Date: Fri, 29 May 2026 16:41:05 +0200 Subject: [PATCH 3/3] chore: remove pointless size attributes --- src/extensions/score_metamodel/BUILD | 5 ----- .../score_metamodel/tests/test_rules_file_based.py | 3 ++- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/extensions/score_metamodel/BUILD b/src/extensions/score_metamodel/BUILD index 0e30e9bad..dd991fe03 100644 --- a/src/extensions/score_metamodel/BUILD +++ b/src/extensions/score_metamodel/BUILD @@ -75,7 +75,6 @@ score_pytest( score_pytest( name = "file_based_tests_architecture", - size = "medium", srcs = ["tests/test_rules_file_based.py"], data = glob(["tests/rst/architecture/*.rst"]) + ["tests/rst/conf.py"], pytest_config = "//:pyproject.toml", @@ -84,7 +83,6 @@ score_pytest( score_pytest( name = "file_based_tests_attributes", - size = "medium", srcs = ["tests/test_rules_file_based.py"], data = glob(["tests/rst/attributes/*.rst"]) + ["tests/rst/conf.py", "tests/rst/attributes/needs.json"], pytest_config = "//:pyproject.toml", @@ -93,7 +91,6 @@ score_pytest( score_pytest( name = "file_based_tests_graph", - size = "medium", srcs = ["tests/test_rules_file_based.py"], data = glob(["tests/rst/graph/*.rst"]) + ["tests/rst/conf.py"], pytest_config = "//:pyproject.toml", @@ -102,7 +99,6 @@ score_pytest( score_pytest( name = "file_based_tests_id_contains_feature", - size = "medium", srcs = ["tests/test_rules_file_based.py"], data = glob(["tests/rst/id_contains_feature/*.rst"]) + ["tests/rst/conf.py"], pytest_config = "//:pyproject.toml", @@ -111,7 +107,6 @@ score_pytest( score_pytest( name = "file_based_tests_options", - size = "medium", srcs = ["tests/test_rules_file_based.py"], data = glob(["tests/rst/options/*.rst"]) + ["tests/rst/conf.py"], pytest_config = "//:pyproject.toml", diff --git a/src/extensions/score_metamodel/tests/test_rules_file_based.py b/src/extensions/score_metamodel/tests/test_rules_file_based.py index d618b14e0..53728e3af 100644 --- a/src/extensions/score_metamodel/tests/test_rules_file_based.py +++ b/src/extensions/score_metamodel/tests/test_rules_file_based.py @@ -293,7 +293,8 @@ def test_rst_files( if local_needs.exists(): shutil.copy(local_needs, app.srcdir) app.config.needs_external_needs = [ - {k: v for k, v in ext.items() if k != "json_url"} | {"json_path": "needs.json"} + {k: v for k, v in ext.items() if k != "json_url"} + | {"json_path": "needs.json"} if "json_url" in ext else ext for ext in (app.config.needs_external_needs or [])