-
Notifications
You must be signed in to change notification settings - Fork 952
Build.ps1 improvements #15017
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
Build.ps1 improvements #15017
Changes from 7 commits
aeba2bc
e30aa13
571016c
be31548
85af8fb
3974e70
acb98d7
475ab48
c1a1822
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,20 @@ | ||
| #Requires -Version 7.0 | ||
| param($filter, [switch]$vet, [switch]$generate, [switch]$skipBuild, $parallel = 5) | ||
| param($filter, [switch]$clean, [switch]$vet, [switch]$generate, [switch]$skipBuild) | ||
|
|
||
| $startingDirectory = Get-Location | ||
| $root = Resolve-Path ($PSScriptRoot + "/../..") | ||
| Set-Location $root | ||
| $sdks = @{}; | ||
|
|
||
| foreach ($sdk in (./eng/scripts/get_module_dirs.ps1 -serviceDir 'sdk/...')) { | ||
| $name = $sdk | split-path -leaf | ||
| $sdks[$name] = @{ | ||
| 'path' = $sdk; | ||
| 'path' = $sdk; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there an intent to eventually have sdk/local config specific values for these instead of using the ones in the global scope?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I originally needed to do this when it was parallel because the global scope variables were empty FWICT. Now that it is not parallel, I guess it is not needed. |
||
| 'clean' = $clean; | ||
| 'vet' = $vet; | ||
| 'generate' = $generate; | ||
| 'skipBuild' = $skipBuild; | ||
| 'root' = $root; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -16,19 +24,33 @@ if (![string]::IsNullOrWhiteSpace($filter)) { | |
| $keys = $keys.Where( { $_ -match $filter }) | ||
| } | ||
|
|
||
| $keys | ForEach-Object { $sdks[$_] } | ForEach-Object -Parallel { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is no longer parallel, will this fail fast on the first codegen/build failure, or still run through all of them (might be cumbersome to go through new build/codegen failures run by run as opposed to getting them all at once).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will fail on first one I believe. |
||
| $keys | ForEach-Object { $sdks[$_] } | ForEach-Object { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to my above comment, the script is small right now so I don't think it matters, but I would consider moving all the script logic into various functions before it gets too large. At least on the engsys side we have some really hard to maintain scripts right now that have grown very large without any refactoring. |
||
| Push-Location $_.path | ||
|
|
||
| if (!$skipBuild) { | ||
| if ($_.clean) { | ||
| Write-Host "##[command]Executing go clean -v ./... in " $_.path | ||
| go clean -v ./... | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: the number of newlines between if blocks don't match. |
||
| if ($_.generate) { | ||
| Write-Host "##[command]Executing autorest.go in " $_.path | ||
| $autorestPath = $_.path + "\autorest.md" | ||
| $autorestVersion = "@autorest/[email protected]" | ||
| $outputFolder = $_.path | ||
| $root = $_.root | ||
| autorest --use=$autorestVersion --go --track2 --go-sdk-folder=$root --output-folder=$outputFolder --file-prefix="zz_generated_" --clear-output-folder=false $autorestPath | ||
| } | ||
| if (!$_.skipBuild) { | ||
| Write-Host "##[command]Executing go build -v ./... in " $_.path | ||
| go build -v ./... | ||
| go build -x -v ./... | ||
| Write-Host "##[command]Build Complete!" | ||
|
|
||
| } | ||
| if ($vet) { | ||
| if ($_.vet) { | ||
| Write-Host "##[command]Executing go vet ./... in " $_.path | ||
| go vet ./... | ||
| } | ||
| if ($generate) { | ||
| Write-Host "##[command]Executing autorest.go in " $_.path | ||
| # TODO | ||
| } | ||
| } -ThrottleLimit $parallel | ||
| Pop-Location | ||
| } | ||
|
|
||
| Set-Location $startingDirectory | ||
chamons marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| ### AutoRest Configuration | ||
| > see https://aka.ms/autorest | ||
|
|
||
| ``` yaml | ||
| tag: package-2020-05-12-preview | ||
| require: | ||
| - https://github.com/Azure/azure-rest-api-specs/blob/9875f8eebd8c1392a83c052bc50a79c8251b1174/specification/agfood/resource-manager/readme.md | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
|
||
| // This file enables 'go generate' to regenerate this specific SDK | ||
| //go:generate pwsh.exe ..\..\..\eng\scripts\build.ps1 -skipBuild -generate armagfood | ||
|
|
||
| package armagfood |
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 don't think it matters much right now, but depending on whether get_module_dirs is also called outside of powershell, it may be a better pattern (for readability, maintenance, etc.) to import functions from this as a module instead of calling out to the scripts.
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'm not opposed to this, i just didn't know you could do that.