-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Enable skip of CI deployment tests #4203
base: main
Are you sure you want to change the base?
feat: Enable skip of CI deployment tests #4203
Conversation
.github/actions/templates/avm-validateModuleDeployment/action.yml
Outdated
Show resolved
Hide resolved
@@ -180,3 +180,4 @@ | |||
/avm/res/web/static-site/ @Azure/avm-res-web-staticsite-module-owners-bicep @Azure/avm-module-reviewers-bicep | |||
/avm/utl/types/avm-common-types/ @Azure/avm-utl-types-avmcommontypes-module-owners-bicep @Azure/avm-module-reviewers-bicep | |||
*avm.core.team.tests.ps1 @Azure/avm-core-team-technical-bicep | |||
*.e2eignore @Azure/avm-core-team-technical-bicep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking forward to discussing, great work meanwhile!
The main suggestion I'd have for now is to add tests. At least one pipeline run with one deployment test skipped and one base case pipeline with no test skipped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @eriqua.
I am not sure I understand your remark. You mean we should have a failed test before the test can be excluded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ReneHezser exactly, suggested full test coverage for CI updates before they are introduced.
- Static validation: we introduced 2 pester tests so we need:
- module run with no test skipped --> should pass
- module run where deployment tests are skipped as intended--> should pass
- module run with one test skipped incorrectly (.e2eignore added in defaults or waf-aligned test) --> should fail pester test 1
- module run with one test skipped incorrectly (.e2eignore is empty) --> should fail pester test 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @eriqua
I added testcases for the mentioned scenarios. Before merging, I need to remove the tests again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ReneHezser, thanks. To show that the Pester test fails as intended, we need a link to the corresponding failing pipeline(s). Could you please attach a link to the failing pipeline runs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I already did, but probably forgot to save the update on the description. Sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but still don't see them. Looking for specific pipeline runs, validating the four cases above, not pipeline badges.
.github/actions/templates/avm-validateModuleDeployment/action.yml
Outdated
Show resolved
Hide resolved
.github/actions/templates/avm-validateModuleDeployment/action.yml
Outdated
Show resolved
Hide resolved
.github/actions/templates/avm-validateModuleDeployment/action.yml
Outdated
Show resolved
Hide resolved
[string] $moduleFolderPath | ||
) | ||
|
||
$e2eTestFolderPathList = Get-ChildItem -Directory (Join-Path -Path $moduleFolderPath 'tests' 'e2e') | Where-Object { $_.Name -in 'defaults', 'waf-aligned' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if that's a good check. Our convention is not that the folders must be called defaults
, but that there must be a test folder that ends with that in the name (same for waf).
You can find an example for this in e.g., the res/compute/virtual-machine
module.
Also there the test in this file calls this out
"Module should contain a [
tests/e2e/*defaults
] folder."
A fix would be as easy as to thest that the name matches either defaults/waf-aligned (you could check for both in the same regex if you want).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I understand that some other test already failed over this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we may want to also have the same logic for the waf-aligned
test? I.e., -like '*waf-aligned'
?
$passCiFilePath = Join-Path $moduleTestFolderPath '.e2eignore' | ||
if (Test-Path $passCiFilePath) { | ||
Write-Output "File '.e2eignore' exists in the folder: $moduleTestFolderPath" | ||
# end here, as the test should be bypassed | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we must have it in here, please make it conditional via a switch statement the user must enable.
Where I to run tests locally, this would prevent me from running the test case even if I wanted to and would anyways only make sense if the user did not specify a single test file. Would feel very odd if I specifically provide a test file that happens to have the .e2eignore
file in the folder (which may not work in the CI/AVM subscription, but may in mine), yet I cannot test it with this script 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Co-authored-by: Alexander Sehr <[email protected]>
Co-authored-by: Alexander Sehr <[email protected]>
Co-authored-by: Alexander Sehr <[email protected]>
Co-authored-by: Alexander Sehr <[email protected]>
foreach ($e2eTestFolderPath in $e2eTestFolderPathList) { | ||
$filePath = Join-Path -Path $e2eTestFolderPath '.e2eignore' | ||
if (Test-Path $filePath) { | ||
$incorrectParameters += $e2eTestFolderPath.Name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's more like 'incorrectFolders', not 'incorrectParameters'
if ($pathExisting) { | ||
$fileContent = Get-Content -Path $filePath | ||
if (-not $fileContent) { | ||
$incorrectParameters += $e2eTestFolderPath.Name + '\.e2eignore' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
@@ -234,8 +235,18 @@ function Test-ModuleLocally { | |||
# ------------------------- | |||
if ((Get-Item -Path $ModuleTestFilePath) -is [System.IO.DirectoryInfo]) { | |||
$moduleTestFiles = (Get-ChildItem -Path $ModuleTestFilePath -File).FullName | |||
$moduleTestFolderPath = $ModuleTestFilePath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beware, moduleTestFiles
is an array in this case and this logic should not work. Did you validate how this behaves? Your logic would need to run below in the loops across the test files.
@@ -19,7 +19,7 @@ Optional. A string array that can be specified to run only Pester tests with the | |||
Optional. A switch parameter that triggers a Pester test for the module | |||
|
|||
.PARAMETER ValidateOrDeployParameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, we don't inject the new condition into this object as it represents the parameters that are passed into the Test-TemplateDeployment
& New-TemplateDeployment
scripts (i.e., we want to be as close to the workflow as possible). I'd instead recommend an additional parameter. For example,
[Parameter(Mandatory = $false)]
[switch] $RespectE2eIgnoreFlag,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still very much an active comment 😉
Description
Allow testcases to be excluded from deplyoments by the CI deployment.
Azure/Azure-Verified-Modules#1796
Pipeline Reference
Type of Change
version.json
:version.json
.version.json
.Checklist
Set-AVMModule
locally to generate the supporting module files.