Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.

Commit c712142

Browse files
committed
Add logic to generate Renovate postUpgradeTasks
Previously the test matrix was defined in a local variable and only accessible in the `.github/workflows/test.yaml` template. However, we now also need access to the test matrix in the `renovate.json` template, so that we can generate the correct list of `make gen-golden` commands as Renovate post-upgrade tasks. To allow this we move the test matrix configuration to global variable `testMatrix`. During a transitional period, the GitHub actions template will continue to read the test matrix from the file-level variable `matrix`, but will fall back to the global variable `testMatrix` if the file-level variable is missing. All already onboarded components should migrate their test matrix (if any) to global parametr `testMatrix`, to take advantage of having their golden test outputs updated in Renovate PRs.
1 parent 62158bc commit c712142

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

config_defaults.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
feature_goUnitTests: false
44
feature_goldenTests: false
55
componentName: ""
6+
testMatrix: {}
7+
# key: provider
8+
# entries:
9+
# - variant1
10+
# - variant2
611

712
.github/ISSUE_TEMPLATE/config.yml:
813
contact_links:
@@ -13,11 +18,7 @@
1318
.github/workflows/test.yaml:
1419
makeTarget: test
1520
goldenTest_makeTarget: golden-diff # Requires `feature_goldenTests`
16-
matrix: {}
17-
# key: provider
18-
# entries:
19-
# - variant1
20-
# - variant2
21+
#matrix: {} # deprecated, use global param `testMatrix`
2122

2223
docs/antora.yml:
2324
version: master

moduleroot/.github/workflows/test.yaml.erb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
<%-
2+
@matrix = @configs.key?('matrix') ? @configs['matrix'] : @configs['testMatrix']
3+
-%>
14
name: Pull Request
25
on:
36
pull_request:
@@ -30,11 +33,11 @@ jobs:
3033
<%- if @configs['feature_componentCompile'] -%>
3134
test:
3235
runs-on: ubuntu-latest
33-
<%- if !@configs['matrix'].empty? -%>
36+
<%- if [email protected]? -%>
3437
strategy:
3538
matrix:
36-
<%= @configs['matrix']['key'] -%>:
37-
<% @configs['matrix']['entries'].each do |entry| -%>
39+
<%= @matrix['key'] -%>:
40+
<% @matrix['entries'].each do |entry| -%>
3841
- <%= entry %>
3942
<% end -%>
4043
<%- end -%>
@@ -64,11 +67,11 @@ jobs:
6467
<%- if @configs['feature_goldenTests'] -%>
6568
golden:
6669
runs-on: ubuntu-latest
67-
<%- if !@configs['matrix'].empty? -%>
70+
<%- if !@matrix.empty? -%>
6871
strategy:
6972
matrix:
70-
<%= @configs['matrix']['key'] -%>:
71-
<% @configs['matrix']['entries'].each do |entry| -%>
73+
<%= @matrix['key'] -%>:
74+
<% @matrix['entries'].each do |entry| -%>
7275
- <%= entry %>
7376
<% end -%>
7477
<%- end -%>

moduleroot/renovate.json.erb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@
44
":gitSignOff",
55
":disableDependencyDashboard"
66
],
7+
<%- if @configs['feature_goldenTests'] -%>
8+
"postUpgradeTasks": {
9+
<%- if !@configs['testMatrix'].empty? && !@configs['testMatrix']['entries'].empty? -%>
10+
"commands": [
11+
<%- @configs['testMatrix']['entries'].each_with_index do |entry, i| -%>
12+
"make gen-golden -e instance=<%= entry %>"<%- if i < @configs['testMatrix']['entries'].length-1 -%>,<%- end %>
13+
<%- end -%>
14+
]
15+
<%- else -%>
16+
"commands": [
17+
"make gen-golden"
18+
]
19+
<%- end -%>
20+
"fileFilters": [ "tests/golden/**" ],
21+
"executionMode": "update"
22+
},
23+
<%- end -%>
724
"labels": [
825
"dependency"
926
]

0 commit comments

Comments
 (0)