-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
DPG best-practice and automation template #28016
Conversation
API change check for API changes have been detected in |
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.
Please add a link to the issue in the PR description.
sdk/template/Azure.ServiceTemplate.Template/tests/TemplateClientTest.cs
Outdated
Show resolved
Hide resolved
For the content\ci.yml files you might need to rename them so that our automation that sets up pipelines doesn't try to setup a pipeline for them. Perhaps we can name them ci.yml.template or something like that and as part of the template generation process rename the file to ci.yml. |
FYI @ArthurMa1978 given that this change impacts the mgmt template as well. |
|
This pull request is protected by Check Enforcer. |
9569995
to
aabcdb8
Compare
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 suggest converting this to a full PR instead of a draft. It'll run more checks that would've cause various syntax errors I noticed. We typically only use draft PRs when you basically want to try out some idea and make sure it's obvious it shouldn't be merged yet, even if reviewed and approved.
sdk/template/Azure.Template/.content/samples/Sample1_HelloWorld.md
Outdated
Show resolved
Hide resolved
sdk/template/Azure.Template/tests/Samples/Sample1_HelloWorld.cs
Outdated
Show resolved
Hide resolved
sdk/template/Azure.Template/tests/Samples/Sample1_HelloWorldAsync.cs
Outdated
Show resolved
Hide resolved
876aa27
to
9a5c884
Compare
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.
When I install the template from your PR and create a new project, I still see a number of issues:
- Lowercase project name, which will impact the output file name and other issues:
- The README and CHANGELOG.md files were in the current directory. You need to create a subdirectory for the calculated Package name. For example, if I run
dotnet new azsdkdpg -g Test -li Sample -s local.json
in sdk/test then I should see a number of files in sdk/test but then also an Azure.Test.Sample directory that has the src, tests, etc. directories. - If I search sdk/test (from my example above) for "template", I still find a lot of links with "template" in the URL:
If you checkout main and create a new project with the old sdk/template these all get cleaned up. Take a look at all the replacements I do:azure-sdk-for-net/sdk/template/.template.config/template.json
Lines 28 to 91 in dfcc122
"ProjectNameUnderscored": { "type": "generated", "generator": "regex", "parameters": { "source": "ProjectName", "steps": [ { "regex": "\\.", "replacement": "_" } ] }, "replaces": "Azure_Template" }, "ServiceDirectoryPath": { "type": "generated", "generator": "join", "parameters": { "symbols": [ { "type": "const", "value": "sdk/" }, { "type": "ref", "value": "ServiceDirectory" } ], "separator": "" }, "replaces": "sdk/template" }, "SafeProjectName": { "type": "generated", "generator": "regex", "parameters": { "source": "ProjectName", "steps": [ { "regex": "\\.", "replacement": "" } ] }, "replaces": "AzureTemplate" }, "YamlServiceDirectory": { "type": "generated", "generator": "join", "parameters": { "symbols": [ { "type": "const", "value": "ServiceDirectory: " }, { "type": "ref", "value": "ServiceDirectory" } ], "separator": "" }, "replaces": "ServiceDirectory: template" }
Everywhere you see "replaces" I'm replacing patterns. You do a great job of adding placeholders, but those need to be used in more places or just replace "sdk/template" with "sdk/{ServiceDirectory}" where "ServiceDirectory" is one of the required inputs I take. In fact, I was able to calculate just about everything with only 2 inputs but you could use the separate GroupName and LibraryName you do now - just add a calculated field that combines "Azure.{GroupName}.{LibraryName" into one symbol you replace "Azure.Template", create another replacement with "Azure{GroupName}{LibraryName}" for "AzureTemplate" (the "safe" name, as I called it), etc.
I recommend using dotnet new azsdkdpg
in a directory. What comes out should match the same structure we use for any track 2 SDK e.g.,
- sdk/
- {ServiceDirectory}/
- Azure.{GroupName}.{LibraryName}/
- src/
- Azure.{GroupName}.{LibraryName}.csproj
- (other files)
- tests/
- Azure.{GroupName}.{LibraryName}.Tests.csproj
- (other files)
- perf/ (and other directories, with proper project names)
- Azure.{GroupName}.{LibraryName}.sln
- README.md
- CHANGELOG.md
- src/
- Directory.Build.props
- test-resources.json
- ci.yml
- tests.yml
- Azure.{GroupName}.{LibraryName}/
- {ServiceDirectory}/
@chunyu3 to help us see what the final output is could you please run the template generation step and push the changes to another branch so we can see what it contains. Also list the exact generation command you used to generate it here. |
Hi @weshaggard @heaths I updated the dpg template according to our discussion in the meeting. And I generated two sample SDKs via azsdkdpg template. You can specify
The generated SDK is https://github.com/chunyu3/azure-sdk-for-net/tree/TemplateSample/sdk/sample
The generated SDK is https://github.com/chunyu3/azure-sdk-for-net/tree/TemplateSample/sdk/test |
Also, we can run pwsh eng/scripts/automation/Invoke-DataPlaneGenerateSDKPackage.ps1 -service test -namespace Azure.Identity.MySample -sdkPath ./azure-sdk-for-net -inputfiles https://github.com/dpokluda/azure-rest-api-specs/blob/be397aa65510bd4e8f87da539af2b0025f6f44ca/specification/deviceupdate/data-plane/Microsoft.DeviceUpdate/preview/2020-09-01/deviceupdate.json -securityScope https://myservice/.default |
* Add request condition argument check * resolve build failure * remove unused import * remove unused Azure.Core dependency * move eng template to sdk * update sample template to DPG + growup * update test cases * remove the templates from eng directory * update Azure.ServiceTemplate.Template * merge Azure.ServiceTemplate.Template with Azure.Template * update api * resolve rebase conflict * complete Azure.Template to match DPG guideline * refine template samples * update template content * remove project file in template content * refine snippet in Readme * resolve inner scope conflict issule * refine test * remove duplicate snippet * update template sample * update script to use the Azure.Template * add function to update ci.yml * remove log in script * resolve comments * use actual type instead of var * resolve comments * refine readme files, add error checking in outer script * add Azure.Template as the content of template * move .content folder out of Azure.Template
* Add request condition argument check * resolve build failure * remove unused import * remove unused Azure.Core dependency * move eng template to sdk * update sample template to DPG + growup * update test cases * remove the templates from eng directory * update Azure.ServiceTemplate.Template * merge Azure.ServiceTemplate.Template with Azure.Template * update api * resolve rebase conflict * complete Azure.Template to match DPG guideline * refine template samples * update template content * remove project file in template content * refine snippet in Readme * resolve inner scope conflict issule * refine test * remove duplicate snippet * update template sample * update script to use the Azure.Template * add function to update ci.yml * remove log in script * resolve comments * use actual type instead of var * resolve comments * refine readme files, add error checking in outer script * add Azure.Template as the content of template * move .content folder out of Azure.Template
Contributing to the Azure SDK
Please see our CONTRIBUTING.md if you are not familiar with contributing to this repository or have questions.
For specific information about pull request etiquette and best practices, see this section.
As part of the DPG effort, we are providing a DPG template as a tool and guidance to our service team partners:
That has all the information they need to follow Azure SDK best practices to create tests, samples, and other customer-facing documents in a matter of days