From fa1ade50a7114c5bd74069a93e7b2cdd7fc177cf Mon Sep 17 00:00:00 2001 From: Simon Gerber Date: Fri, 18 Mar 2022 11:42:01 +0100 Subject: [PATCH] Update component template modulesync config structure This commit adjusts the initial modulesync config generated by the component template to match the changes introduced by https://github.com/projectsyn/modulesync-control/pull/62 which facilitate keeping the Renovate `postUpgradeTasks` updated when new matrix tests are added. --- .../{{ cookiecutter.slug }}/.sync.yml | 19 +++++++++++-------- tests/test_component_template.py | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/commodore/component-template/{{ cookiecutter.slug }}/.sync.yml b/commodore/component-template/{{ cookiecutter.slug }}/.sync.yml index 56009ef91..5fb29257d 100644 --- a/commodore/component-template/{{ cookiecutter.slug }}/.sync.yml +++ b/commodore/component-template/{{ cookiecutter.slug }}/.sync.yml @@ -1,19 +1,22 @@ :global: componentName: {{ cookiecutter.name }} - feature_goldenTests: true + feature_goldenTests: {% if cookiecutter.add_golden == "y" %}true{% else %}false{% endif %} +{%- if cookiecutter.add_matrix == "y" %} + testMatrix: + key: instance + entries: + - defaults + +{%- endif %} docs/antora.yml: name: {{ cookiecutter.slug }} title: {{ cookiecutter.name }} -{% if cookiecutter.add_matrix == "y" -%} +{%- if cookiecutter.add_matrix == "y" %} .github/workflows/test.yaml: test_makeTarget: test -e instance={% raw %}${{ matrix.instance }}{% endraw %} {%- if cookiecutter.add_golden == "y" %} goldenTest_makeTarget: golden-diff -e instance={% raw %}${{ matrix.instance }}{% endraw %} -{%- endif %} - matrix: - key: instance - entries: - - defaults -{% endif -%} +{%- endif -%} +{% endif %} diff --git a/tests/test_component_template.py b/tests/test_component_template.py index 38b368cff..a8337f0eb 100644 --- a/tests/test_component_template.py +++ b/tests/test_component_template.py @@ -141,6 +141,23 @@ def test_run_component_new_command( else: assert run_step["run"] == "make golden-diff" + with open(tmp_path / "dependencies" / component_name / ".sync.yml") as syncyml: + syncconfig = yaml.safe_load(syncyml) + assert ":global" in syncconfig + + globalconfig = syncconfig[":global"] + assert "componentName" in globalconfig + assert "feature_goldenTests" in globalconfig + assert ("testMatrix" in globalconfig) == has_matrix + + assert globalconfig["componentName"] == component_name + assert globalconfig["feature_goldenTests"] == has_golden + + assert (".github/workflows/test.yaml" in syncconfig) == has_matrix + if has_matrix: + ghconfig = syncconfig[".github/workflows/test.yaml"] + assert ("goldenTest_makeTarget" in ghconfig) == has_golden + with open( tmp_path / "dependencies" / component_name / "renovate.json" ) as renovatejson: