Skip to content
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

Fix New-TestResources.ps1 to run pre/post deployment script #1876

Merged
11 commits merged into from
Aug 13, 2021

Conversation

ckairen
Copy link
Member

@ckairen ckairen commented Aug 5, 2021

Fix bug in which New-TestResources.ps1 doesn't call test-resources-pre.ps1 and test-resources-post.ps1 script before and after template deployment from a bicep file.

@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

Copy link
Member

@heaths heaths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall great change. Thank you! I do have a few suggestions.

eng/common/TestResources/New-TestResources.ps1 Outdated Show resolved Hide resolved
Copy link
Member

@weshaggard weshaggard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good but as we talked lets wait until after releases next week before we get this merged, unless there is someone actively blocked by this.

@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

@benbp
Copy link
Member

benbp commented Aug 9, 2021

Thanks for tracking this bug down!

@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

@azure-sdk
Copy link
Collaborator

The following pipelines have been queued for testing:
java - template
java - template - tests
js - template
net - template
net - template - tests
python - template
python - template - tests
You can sign off on the approval gate to test the release stage of each pipeline.
See eng/common workflow

@@ -167,11 +167,9 @@ try {
Get-ChildItem -Path $root -Filter "$_" -Recurse | ForEach-Object {
Write-Verbose "Found template '$($_.FullName)'"
if ($_.Extension -eq '.bicep') {
$templateFile = @{originalFilePath = $_.FullName; jsonFilePath = (BuildBicepFile $_)}
$templateFiles += $templateFile
$templateFiles += (BuildBicepFile $_)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm honestly not a fan of this change, @benbp. The temp file that gets returned and printed everywhere is an implementation detail of this script with no obvious tie-back to the original .bicep file. At the very least BuildBicepFile should print the source and destination paths, but that's still requiring users to look up through the logs to find it. How it was with the object I thought was a great idea, so you could even print both if someone needed to find the actual JSON template (I've ran into a few issues where this was needed with bicep files).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you might be commenting on an outdated commit? Sorry for the messy commits.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, at the time I commented, the variable was just a single string path. You had it as a multi-property object but Ben asked you to change it. Did you chances it back to an object? We shouldn't be printing the path to a temp JSON file that the user can't use to diagnose failures.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is an outdated diff. The main code is object based: https://github.com/Azure/azure-sdk-tools/blob/main/eng/common/TestResources/New-TestResources.ps1#L170-L171

I think it may actually be helpful to print both paths, because when debugging bicep scripts, I often need to see the compiled output to help diagnose the problem.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's what I originally commented as well. The commit that had the original and transformed names as properties was best. My only comment from then was that the message printed when the two were different should list both. From the number of people I help set up their test resources (rather, customize them) it's clear expecting them to know how it works e.g., that it transforms the bicep file into json behind the scenes would be unnecessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep makes sense. I plan to roll in those changes with my fix to #1824 (I promise I'll get to it @pakrym, just dealing with weird windows encryption API issues).

@ghost
Copy link

ghost commented Aug 13, 2021

Hello @azure-sdk!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 0157b11 into Azure:main Aug 13, 2021
ghost pushed a commit that referenced this pull request Aug 27, 2021
New-TestResources.ps1 was storing the .env file at the temp folder if the service uses bicep files. This bug fix stores the .env file at the correct service directory.

(also pushed in logging request in #1876)
@ckairen ckairen deleted the albertcheng/new-testresources.ps1 branch November 22, 2021 21:33
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New-TestResources.ps1 doesn't run post-deployment script when using a bicep file
5 participants