From 6ae1474dcac05fa31ac0b441e357918777e4dded Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Tue, 23 Jul 2024 10:10:28 +0200 Subject: [PATCH] fix: Added baseTime parameter overwrite to CI (#2740) ## Description Many of our test cases implement the parameter `param baseTime string = utcNow('u')` to generate unique names. While a good idea in theory, it has the flaw that also each retry will lead to a new value which can cause re-runs to fail if for example a key vault referenced for CMK suddenly changes. The proposed solution is to set the value once per pipeline run in the workflow and hence overwrite the default value of each template IF the template contains the `baseTime` parameter. ## Pipeline Reference | Pipeline | | -------- | | [![avm.res.compute.disk-encryption-set](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.compute.disk-encryption-set.yml/badge.svg?branch=users%2Falsehr%2FbaseTimeOverwrite&event=workflow_dispatch)](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.compute.disk-encryption-set.yml) (has `baseTime` parameter) | | [![avm.res.analysis-services.server](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.analysis-services.server.yml/badge.svg?branch=users%2Falsehr%2FbaseTimeOverwrite&event=workflow_dispatch)](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.analysis-services.server.yml) (does not have the `baseTime` parameter) | ## Type of Change - [x] Update to CI Environment or utilities (Non-module affecting changes) - [ ] Azure Verified Module updates: - [ ] Bugfix containing backwards-compatible bug fixes, and I have NOT bumped the MAJOR or MINOR version in `version.json`: - [ ] Someone has opened a bug report issue, and I have included "Closes #{bug_report_issue_number}" in the PR description. - [ ] The bug was found by the module author, and no one has opened an issue to report it yet. - [ ] Feature update backwards compatible feature updates, and I have bumped the MINOR version in `version.json`. - [ ] Breaking changes and I have bumped the MAJOR version in `version.json`. - [ ] Update to documentation --------- Co-authored-by: Erika Gressi <56914614+eriqua@users.noreply.github.com> Co-authored-by: Maher Aldineh --- .../templates/avm-validateModuleDeployment/action.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/actions/templates/avm-validateModuleDeployment/action.yml b/.github/actions/templates/avm-validateModuleDeployment/action.yml index b6e1145f7d..f73968f350 100644 --- a/.github/actions/templates/avm-validateModuleDeployment/action.yml +++ b/.github/actions/templates/avm-validateModuleDeployment/action.yml @@ -213,6 +213,11 @@ runs: resourceLocation = '${{ steps.get-resource-location.outputs.resourceLocation }}' } } + if($moduleTemplatePossibleParameters -contains 'baseTime') { + $functionInput.AdditionalParameters += @{ + baseTime = (Get-Date).ToString('u') # Setting base time explicitly so that any potential retry will reuse the same timestamp + } + } Write-Verbose 'Invoke task with' -Verbose Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose @@ -269,6 +274,11 @@ runs: resourceLocation = '${{ steps.get-resource-location.outputs.resourceLocation }}' } } + if($moduleTemplatePossibleParameters -contains 'baseTime') { + $functionInput.AdditionalParameters += @{ + baseTime = (Get-Date).ToString('u') # Setting base time explicitly so that any potential retry will reuse the same timestamp + } + } Write-Verbose 'Invoke task with' -Verbose Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose