Skip to content

Commit

Permalink
Add logic to generate Renovate postUpgradeTasks
Browse files Browse the repository at this point in the history
This commit adds logic to the `renovate.json` template in the component
template to generate section `postUpgradeTasks` when golden tests are
enabled when creating a component with `commodore component new`.
  • Loading branch information
simu committed Mar 18, 2022
1 parent 85a9972 commit 5df533e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
14 changes: 14 additions & 0 deletions commodore/component-template/{{ cookiecutter.slug }}/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
":gitSignOff",
":disableDependencyDashboard"
],
{%- if cookiecutter.add_golden == "y" %}
"postUpgradeTasks": {
"commands": [
{%- if cookiecutter.add_matrix == "y" %}
"make gen-golden -e instance=defaults"
{%- else %}
"make gen-golden"
{%- endif %}
],
"fileFilters": [ "tests/golden/**" ],
"executionMode": "update"
},
"suppressNotifications": [ "artifactErrors" ],
{%- endif %}
"labels": [
"dependency"
]
Expand Down
15 changes: 15 additions & 0 deletions tests/test_component_template.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tests for component new command
"""
import json
import os
import pytest
import yaml
Expand Down Expand Up @@ -140,6 +141,20 @@ def test_run_component_new_command(
else:
assert run_step["run"] == "make golden-diff"

with open(
tmp_path / "dependencies" / component_name / "renovate.json"
) as renovatejson:
renovateconfig = json.load(renovatejson)
assert ("postUpgradeTasks" in renovateconfig) == has_golden
if has_golden:
assert len(renovateconfig["postUpgradeTasks"]["commands"]) == 1
cmd = renovateconfig["postUpgradeTasks"]["commands"][0]
expected_cmd = {
"--matrix-tests": "make gen-golden -e instance=defaults",
"--no-matrix-tests": "make gen-golden",
}
assert cmd == expected_cmd[matrix]


def test_run_component_new_command_with_name(tmp_path: P):
"""
Expand Down

0 comments on commit 5df533e

Please sign in to comment.