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

Commit

Permalink
Add logic to generate Renovate postUpgradeTasks
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
simu committed Mar 18, 2022
1 parent 62158bc commit 7da8104
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
11 changes: 6 additions & 5 deletions config_defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
feature_goUnitTests: false
feature_goldenTests: false
componentName: ""
testMatrix: {}
# key: provider
# entries:
# - variant1
# - variant2

.github/ISSUE_TEMPLATE/config.yml:
contact_links:
Expand All @@ -13,11 +18,7 @@
.github/workflows/test.yaml:
makeTarget: test
goldenTest_makeTarget: golden-diff # Requires `feature_goldenTests`
matrix: {}
# key: provider
# entries:
# - variant1
# - variant2
#matrix: {} # deprecated, use global param `testMatrix`

docs/antora.yml:
version: master
Expand Down
15 changes: 9 additions & 6 deletions moduleroot/.github/workflows/test.yaml.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<%-
@matrix = @configs.key?('matrix') ? @configs['matrix'] : @configs['testMatrix']
-%>
name: Pull Request
on:
pull_request:
Expand Down Expand Up @@ -30,11 +33,11 @@ jobs:
<%- if @configs['feature_componentCompile'] -%>
test:
runs-on: ubuntu-latest
<%- if !@configs['matrix'].empty? -%>
<%- if [email protected]? -%>
strategy:
matrix:
<%= @configs['matrix']['key'] -%>:
<% @configs['matrix']['entries'].each do |entry| -%>
<%= @matrix['key'] -%>:
<% @matrix['entries'].each do |entry| -%>
- <%= entry %>
<% end -%>
<%- end -%>
Expand Down Expand Up @@ -64,11 +67,11 @@ jobs:
<%- if @configs['feature_goldenTests'] -%>
golden:
runs-on: ubuntu-latest
<%- if !@configs['matrix'].empty? -%>
<%- if !@matrix.empty? -%>
strategy:
matrix:
<%= @configs['matrix']['key'] -%>:
<% @configs['matrix']['entries'].each do |entry| -%>
<%= @matrix['key'] -%>:
<% @matrix['entries'].each do |entry| -%>
- <%= entry %>
<% end -%>
<%- end -%>
Expand Down
18 changes: 18 additions & 0 deletions moduleroot/renovate.json.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@
":gitSignOff",
":disableDependencyDashboard"
],
<%- if @configs['feature_goldenTests'] -%>
"postUpgradeTasks": {
<%- if !@configs['testMatrix'].empty? && !@configs['testMatrix']['entries'].empty? -%>
"commands": [
<%- @configs['testMatrix']['entries'].each_with_index do |entry, i| -%>
"make gen-golden -e instance=<%= entry %>"<%- if i < @configs['testMatrix']['entries'].length-1 -%>,<%- end %>
<%- end -%>
]
<%- else -%>
"commands": [
"make gen-golden"
]
<%- end -%>
"fileFilters": [ "tests/golden/**" ],
"executionMode": "update"
},
"suppressNotifications": [ "artifactErrors" ],
<%- end -%>
"labels": [
"dependency"
]
Expand Down

0 comments on commit 7da8104

Please sign in to comment.